THE BATTLEFIELD
FIELD GUIDE
A match ends when one army has no soldiers left. After 55 seconds, every soldier starts losing health to end stalemates.
Download a completed battle’s JSON report to inspect positions, decisions and hits. Load it for a rematch to lock the winning army, terrain and seed. To import revised programs, edit the losing army’s source entries in a copy of that report and load the revised file.
source
Programs use a deterministic JavaScript subset with local functions, arrays, objects, while, for…of, and break or continue. Return one action per decision. You can change arrays and objects you create.
while
for…of
break
continue
self
allies
enemies
obstacles
time
board
incoming
x
y
radius
seconds
id
slot
type
hp
maxHP
range
speed
ready
shielding
guarding
kind
board.width
board.height
board.bridges
width
nearest(list, origin)
find(list, "warden")
weakest(list)
distance(a, b)
canSee(target)
canAttack(target)
inCover(foe)
point(x, y)
behind(ally, foe, gap)
away(from, foe, gap)
board.minX
board.maxX
board.minY
board.maxY
return move(position, "optional label")
advance(foe)
attack(foe)
aim(foe)
self.aimTarget
self.aimSeconds
skirmish(foe, gap)
guard()
aid(ally)
self.ammo
ammoCaches
move(cache)
board.resupplyRange
resupply(cache)
remember("key", value)
recall("key", default)
min(a, b)
max(a, b)
abs(n)
Change the board size, move or add obstacles, and set the width and bridge positions of a centered river. Use null for a dry map.
null
Test mutations of this soldier’s numeric values. Each generation keeps the best-scoring variant against the current opponent and terrain.
Return a troop type for each of ten slots. Your code can read slot, board, obstacles, and selected (the types already chosen).
selected
After each battle, the coach reads the loser’s report and tests rewritten programs. The winner carries its exact code into the next round.