ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
Inspired by wub's thread on the Heroes Community forums, http://heroescommunity.com/viewthread.php3?TID=47397
2
Results obtained from script written in tcl, previous versions:
3
2022-06-21
https://pastebin.com/xqP4hxrN
4
2022-07-06
https://pastebin.com/hHvbu7FV
5
2022-07-28
https://pastebin.com/pwYuvchJ
6
2026-02-17
https://pastebin.com/wvWann0T
https://pastebin.com/4tgCHG65
Uploaded in two pastes because otherwise it triggers the "smart" filter
7
to run the script, you'll need a Tcl compiler installed
8
Windows: either https://core.tcl-lang.org/tcl/download or https://www.activestate.com/products/tcl/
9
linux: apt install tcl
10
you'll also need to download the three creature sheets from here as csv files, and name them "creatures-hota.csv", "creatures-sod.csv", and "creatures-roe.csv"
11
save the tcl script in the same folder as e.g battle tcl, and then run via the command line "tclsh battle.tcl"
12
13
How x,y,z coordinates work for the two-dimensional battlefield:
0,0,0 is the centre
y = 0 is a horizontal line; top row is y = -5, bottom row is y = +5
x = 0 runs from upper right to lower left; max x in bottom right corner is 10, min x in top left corner is -9
z is the mirror of x
x = y + z for any valid coordinate
14
15
Main battle logic
16
Decision logic (from "proc do_auto_action"), applied whenever it's a creature/unit/stack's turn to perform some action
17
creature = the creature performing the action, enemy = the opponent
18
distance = the distance required to move from one battlefield cell to another, so if there's one cell separating the two units, then the distance is actually 2
19
A battle to the death is where each creature just takes turn melee attacking the other, no waiting, no defending, no moving, no shooting
20
A full battle simulation simulates the entire battle as if a creature had chosen a particular action, including this logic recursively in any subsequent rounds
21
22
The creature is ranged if either of the following is true:
23
it has a ranged attack, and has any shots left
24
it can attack and return (i.e harpies)
25
If the creature is currently hypnotized: move to an adjacent unoccupied square
26
If the creature has a spell it can use (i.e Faerie Dragon, and the enemy is not immune): cast spell
27
If the creature is ranged and either the distance is greater than 1, or the creature is faster than the enemy:
28
choose a ranged action; or
29
engage in melee battle
30
otherwise:
31
choose a melee action; or
32
engage in melee battle
33
34
Ranged action logic
35
creature can wait if all of the following is true:
36
the creature has not yet waited
37
the creature is not slower than the enemy
38
either the creature is faster than the enemy, or the enemy has not already acted
39
the range of the creature/enemy is either 10, for ranged creatures, or the speed of the creature + 1 for harpies
40
41
if the creature can wait, and the distance is greater than the creature's range, and the enemy is not ranged, and the distance is greater than the enemy's speed + 1: wait
42
if the enemy is ranged, and the distance is greater than 1, and the creature is a harpy/harpy hag:
43
if the enemy is within striking distance:
44
if this is HoTA: attack and don't retreat
45
otherwise: move adjacent to the enemy
46
Otherwise: move closer to the enemy, with the minimum number of moves, without moving within the enemy's range if possible
47
If enemy is also ranged and distance is greater than 1:
48
simulate a battle to the death, both creatures using their ranged attack - who wins?
49
if the creature would win: use ranged attack
50
If the distance is greater than the creature's range, but not greater than the enemy's range:
51
if the creature can wait: wait
52
otherwise: move within range if possible, otherwise as close as possible
53
otherwise:
54
simulate approaching the enemy and engaging in melee battle - who wins?
55
if the creature would win:
56
if the enemy is within striking distance: attack (melee)
57
Otherwise: move closer to the enemy, with the minimum number of moves, without moving within the enemy's range if possible
58
otherwise: use ranged attack
59
if the distance is greater than the enemy's speed + 1: use ranged attack
60
otherwise:
61
simulate a melee battle to the death - who wins?
62
if the creature would win:
63
if the distance is 1: engage in melee battle
64
otherwise: use ranged attack
65
otherwise:
66
if one attack will kill the enemy: use ranged attack
67
otherwise:
68
choose a kiting action, or
69
if the distance is greater than 1: use ranged attack
70
otherwise: engage in melee battle
71
72
Melee action logic
73
creature can wait if all of the following is true:
74
the creature has not yet waited
75
the creature is not slower than the enemy
76
either the creature is faster than the enemy, or the enemy has not already acted
77
creature can move if not affected by binding (from dendroids)
78
The creature is ranged if either of the following is true:
79
it has a ranged attack, and has any shots left
80
it can attack and return (i.e harpies)
81
the range of the enemy is either 10, for ranged enemies, or the speed of the enemy + 1 for harpies
82
83
if the creature can wait, and the enemy is not ranged, and the distance is greater than the enemy's speed + 1: wait
84
if the creature can wait, and the enemy is ranged, and the enemy is not within striking distance, and the distance is greater than the enemy's range: wait
85
if the enemy is not ranged, and the enemy is not within striking distance, but the enemy can reach the creature:
86
simulate a battle to the death, assuming the enemy gets a free attack, and then attacks first in each subsequent round - who wins?
87
if the creature would win: move towards the enemy, ideally moving the enemy into range, and maximising the number of hexes within range of both the creature and the enemy
88
otherwise: defend
89
if the enemy is not within striking distance:
90
Determine how close to move to the enemy:
91
If the enemy has a ranged attack, and the distance to the enemy is greater than the enemy's range penalty distance, and if moving as far as possible would move the creature to less than the enemy's range penalty distance:
92
If moving to just outside the enemy's range penalty distance would not require additional moves to reach the enemy's current location: move to just outside the enemy's range penalty distance
93
Otherwise: move as close as possible
94
If the enemy does not have a ranged attack, and the enemy cannot reach the creature in one turn, and moving as close as possible would put the creature within the enemy's striking distance: move to just outside the enemy's movement distance
95
Otherwise: move as close as possible to the enemy
96
If the distance to move is zero, and the enemy is not ranged, and the creature and the enemy have the same speed:
97
In a battle to the death, if the enemy attacks first, who wins
98
If the creature would: move forward as far as possible
99
Otherwise:
100
If an impasse has not been declared: defend