Next Move: Computer Opponents for Turn-Based Tactics
README.md
turnAiKit.sim
A tiny self-contained square-grid skirmish model and a turnAiKit adapter over
it: units with hp / range / damage / aim / move, walls that give cover
(Sim.cover), Bresenham line of sight (Sim.canSee), 8-way movement
(Sim.reachable), attack / heal / grenade options, and a seeded RNG for
resolving shots. Used by the turnAiKit tests and demo, and the reference to
copy when writing an adapter for your own game.
Main calls: Sim.new(spec), Sim.skirmish(seed?, swapFirst?) (the default
12x9 board), Sim.unit(archetype, id, side, q, r) (rifle, grenadier, blade,
medic, captain), Sim.adapter(state), Sim.apply(state, side, action),
Sim.beginTurn, Sim.playTurn(state, side, brainOpts),
Sim.playGame(spec, { [side] = brainOpts }, maxRounds), Sim.winner,
Sim.hpOf, Sim.clone. Maps can be written as strings: # wall, O
objective cell. Moving costs 1 AP; attacking, healing or throwing ends the
unit's turn; each side gets 2 AP per unit per turn.