Spec: Evo_Bot TOPO_Gun implementation #80
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
Evo_Bot needs a working gun system that predicts enemy dodge behavior using a neuroevolution approach. The architecture is locked (ADR 0001, wayfinder maps #61 and #74), the GA+ANN pipeline is validated (spike in
prototypes/ga_gun_spike/), but no bot code exists yet — there is nosrc/directory. The bot needs to be built from scratch, integrating all decided subsystems into a Robocode Tank Royale bot written in Nim.Solution
Build Evo_Bot as a modular Robocode Tank Royale bot in Nim with a TOPO_Gun (fixed-topology ANN evolved by mutation-only GA), Virtual Guns system, confidence-based firing discipline, and per-opponent weight persistence. The bot predicts enemy dodge behavior via guess factor targeting and adapts mid-match through parallel evolution.
User Stories
forward(weights, inputs) → floatinterface, so that the gun can predict guess factors from the sliding window.power = clamp(3.0 - (distance - 150) / 400, 0.5, 3.0)applied before GF prediction, so that power is mechanical and the ANN only predicts direction.MEA = arcsin(8.0 / bullet_speed),aim_angle = bearing_to_enemy + gf × MEA, so that the ANN's output maps to a firing angle.power = formula_power × clamp(hit_rate / 0.3, 0.3, 1.0), so that uncertain guns fire weaker to conserve energy.Implementation Decisions
Architecture (from ADR 0001 and wayfinder maps #61, #74)
feed(state)/aim() → (angle, power)— black-box module, bot doesn't know internals.lateral_vel / 8.0([-1,1]),heading_delta / π([-1,1]),wall_distance / 1000.0([0,1]). Mixed ranges are fine — tanh needs bounded magnitude, not symmetry. The GA compensates.power = clamp(3.0 - (distance - 150) / 400, 0.5, 3.0). Applied first; ANN predicts GF within the resulting MEA arc. ANN never sees or controls power.bullet_speed = 20 - 3 × power,MEA = arcsin(8.0 / bullet_speed),aim_angle = bearing_to_enemy + gf × MEA.Deferred decisions
Nim-specific
Testing Decisions
Test philosophy
when isMainModuleself-check block with assertions, following the pattern established byprototypes/ga_gun_spike/ga_spike.nim.doAssertfor checks that must survive-d:releasebuilds. Useassertfor development-only checks.-d:dangerduring testing or training — it disables all runtime safety checks including bounds checking.Module self-checks
Integration testing
Out of Scope
Further Notes
prototypes/ga_gun_spike/ga_spike.nim) validates the core GA+ANN pipeline on sin(x) prediction. It achieved MSE < 0.0002 in 200 generations with a 10→4→1 network. The real bot scales this to 91→8→1 with the same mechanics.docs/adr/0001-neuroevolution-gun-fixed-topology-ann-evolved-by-ga.mdCONTEXT.mddocs/research/ga-parameters-neuroevolution.md