Fortify

THE BATTLEFIELD

The Crossing

Verdant Order
Your army
10
00:00PLANNING
10
Iron Company
Computer rival
WEST KEEP
EAST KEEP
Select a soldier to inspect

Battle log

ROUND 1

    FIELD GUIDE

    How to play

    1. Choose terrain and a rival, or set both armies’ code in local two-player mode.
    2. Click a soldier to edit its program. Use a starter or write your own. The soldier reads the board and returns a fresh action several times a second.
    3. Deploy and watch. Rocks and barricades block movement. Archers and catapults can lob over low barricades. Wardens can intercept arrows and bolts. Move out of a stone’s marked landing zone before it hits.

    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.

    Code reference

    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.

    Board data
    self, allies, enemies, obstacles, time, board and incoming. Each incoming stone exposes x, y, radius and seconds. Soldiers expose id, slot, type, x, y, hp, maxHP, range, speed, ready, shielding, and guarding. Obstacles expose x, y, kind, and radius. Each side sees its own keep on the low-x side. board.width and board.height describe the layout, and board.bridges lists crossings with y and width.
    Targeting and cover
    nearest(list, origin) defaults to self. find(list, "warden") finds the nearest matching type. weakest(list) uses remaining HP. distance(a, b), canSee(target), canAttack(target), and inCover(foe) check range or cover. A warden in the path can still intercept an arrow.
    Positioning
    point(x, y), behind(ally, foe, gap), away(from, foe, gap). Use board.minX, board.maxX, board.minY, and board.maxY for movement bounds.
    Actions
    return move(position, "optional label") walks around obstacles. advance(foe) closes in. attack(foe) explicitly orders a shot or strike. aim(foe) steadies the weapon without firing. Check self.aimTarget and self.aimSeconds before firing. skirmish(foe, gap) moves to maintain distance. guard() reduces damage and lets Wardens intercept. A Medic can aid(ally) within range.
    Ammunition
    Every shot uses ammo, including misses. Check self.ammo and ammoCaches. Choose a cache, move(cache) into board.resupplyRange, then return resupply(cache). Each supply charge restores the unit’s ammo.
    Memory and math
    remember("key", value), recall("key", default), min(a, b), max(a, b), abs(n). Memory is individual to each soldier and resets each match.

    Edit map

    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.

    Evolution lab

    Test mutations of this soldier’s numeric values. Each generation keeps the best-scoring variant against the current opponent and terrain.

    Draft army

    Return a troop type for each of ten slots. Your code can read slot, board, obstacles, and selected (the types already chosen).

    Adaptation series

    After each battle, the coach reads the loser’s report and tests rewritten programs. The winner carries its exact code into the next round.