Spec: GA_Gun only — virtual bullets, tick-speed training, hit% fitness #115
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
EvoBot's GA_Gun currently trains in a background thread using a replay tape of past enemy states. This introduces complexity (thread synchronization, replay tape management, staleness) and decouples training from the actual game dynamics. The gun also outputs only a guess factor — bullet power is a hardcoded distance formula, leaving optimization on the table.
Solution
Replace the background-thread evolution with tick-speed training via virtual bullets. Every GA candidate fires a virtual bullet each tick; after enough bullets resolve, hit% becomes the fitness signal. The champion is hot-swapped into the live gun immediately. The ANN gains a second output for bullet power. No multi-gun selector, no CMA-ES, no replay tape — one gun, one optimizer, one loop.
User Stories
Implementation Decisions
weights/ga_gun.weights(or similar) when champion changes. Load at startup. Single global file, no per-opponent.power = 0.1 + (tanh_output + 1) / 2 × 2.9maps [-1, +1] → [0.1, 3.0].Testing Decisions
What makes a good test
Tests assert external behavior of modules, not internal state. Feed inputs → check outputs. No mocking internal functions.
Seam 1: GA_Gun module boundary (primary)
Feed tick data and enemy states into the GA_Gun module. Assert:
This exercises ANN inference, virtual bullet spawning, GA loop, and champion swap end-to-end.
Seam 2: Virtual bullet hit detection (secondary)
Pure geometry test. Feed known bullet trajectories (position, velocity vector) and enemy positions/sizes. Assert:
This is isolated because circle-rect intersection is a known bug magnet in Robocode bots.
Prior art
tests/handler_seam_v2.nim— existing integration test pattern using event handler seams. New tests should follow the same assert-based self-check style (no test framework, just assert + runnable main).Out of Scope
Further Notes