DevControlBot 1.2.0: TFIL survival movement + universal battle runner

Ported "the floor is lava" (TFIL) movement into DevControlBot as a
self-contained module, DevControlBot/modules/tfil.nim. It has no runtime
dependency on common_libs/: the port is a standalone implementation,
parity-verified against the common_libs original over 2000 differential
ticks with zero divergences. Do not re-introduce the dependency and do
not edit the original to match.

Debug graphics (per-tile lava heat, tracked bullets and their danger
corridors, enemy core/aura, reachable hull, committed tile) are OFF by
default and compile-time gated behind -d:tfilDebug; see README.md for
the plain `nim c` invocation, since nimble runBot does not forward
compile flags.

Wired into DevControlBot.nim: movement computed between commandRadar()
and go(), fire-event tracking wired up, staleness handling for scanned
enemies, and body colour set to BLACK at init (movement and radar both
claim colour now).

Also adds tools/test_runner, a shared battle-test runner usable by any
garage, with an Observer adversary for quick floor checks.
This commit is contained in:
2026-10-04 18:16:24 +02:00
parent de0dd50d6e
commit 67d185880d
17 changed files with 1666 additions and 25 deletions
+154
View File
@@ -0,0 +1,154 @@
# tools/test_runner — universal battle-test runner
One command for **every** garage in the repo. Lives under `tools/` because root
`AGENTS.md` defines it as *"generic tools valid for all bots (battle runners,
scripts, etc.)"* — there is no root `test/` folder and none is allowed.
It **builds on** `common_libs/test_framework` — it does not reimplement it:
| Need | Reused from |
|---|---|
| server lifecycle, compile, runner subprocess | `runBattle()` in `test_framework.nim` |
| offline log parsing | `parseServerOutput()` in `battle_result.nim` |
| adversaries | `common_libs/test_framework/adversaries/` + `adversaries/Observer/` |
Nothing in `common_libs/` is modified, moved or deleted.
---
## Usage
```sh
nim c --path:common_libs tools/test_runner/runner.nim
./tools/test_runner/runner --bot DevControlBot_garage --opponents GAUNTLET
./tools/test_runner/runner --bot X_garage --rounds 5 --json out.json
./tools/test_runner/runner --bot X_garage --offline captured.jsonl # no Java
./tools/test_runner/runner --bot X_garage --dry-run # matrix only
```
`--help` prints the full option list.
### Exit codes
| Code | Meaning |
|---|---|
| 0 | pass **or SKIP** (JARs absent) |
| 1 | test failure (a matchup below threshold) |
| 2 | harness error — `OSError` (bot compile failed), `IOError` (runner exited non-zero / bad setup), `TimeoutError` (server startup, compile, or runner timeout); each prints its own message |
### Env gating (SKIP, not failure)
Reads `TR_SERVER_JAR` (default: `DefaultServerJar` in `server_manager.nim`) and
`TR_BATTLE_RUNNER` (default: same path as `runner_process.nim`). If either file
is missing, the runner prints a SKIP banner and **exits 0**. This is the pattern
root `AGENTS.md` prescribes and that no garage implemented. `--server-jar` /
`--runner-jar` override the env explicitly so a driver can force a run.
---
## `.battletest.json` — per-garage overrides
Drop next to the bot dir:
```json
{ "rounds": 20, "opponents": ["../GotoTest_garage"] }
```
Garages can act as opponents: `--opponents <path>` takes any directory, and
`--bot` accepts a garage (`X_garage`) or a bot dir.
---
## Why `stage.nim` exists (do not "simplify" this away)
`tools/battle_runner/TestBattleRunner.java:51` derives each bot's identity JSON
filename **from the directory name**:
```java
var jsonPath = path.resolve(path.getFileName() + ".json");
```
So a bot in `DevControlBot_garage/` is looked up as `DevControlBot_garage.json`,
which does not exist. The result is a **ghost**: the battle runs, no error is
reported, and the bot simply never boots. Confirmed live in `/tmp/dcbv/stage`
— `stage/Observer/` works (dir name == stem), `stage/DbgBot/` does not.
`stageOne()` therefore builds `<tmp>/<Stem>/` containing `<Stem>` and
`<Stem>.json` and asserts `dirName == stem` plus both files existing, raising a
message naming the exact reason otherwise. If the bot dir is *already* named
after its stem (e.g. `DevControlBot_garage/DevControlBot/`), it is used in
place and not staged.
Adversaries that ship a `<Stem>.sh` launcher get a regenerated one in the staged
dir — the original execs `./out/<Stem>`, which a staged flat dir does not have.
---
## Report
One row per matchup: `opponent | score | rank | 1st | survivedRounds/rounds | status`.
**PRIMARY metric = `survivalCount`** (these bots are survival movers), then
`firstPlaces`, then `score`. A matchup fails when the survival rate is below
`--survival-threshold` (default `0.6`), when fewer rounds were recorded than
requested, or when the bot's name is **absent from `r.results`** — searching by
name returns a zero-initialised `BotResult` with no error, the trap called out
in the test-framework README.
### ⚠ SittingDuck is DEGENERATE in this harness
A matchup against `SittingDuck` reports **score 0 / survival 0 for both bots
regardless of play**. Observed live: `DevControlBot vs SittingDuck` →
`score 1 vs 0, survivalCount 0`. Therefore:
- `survivalCount` against SittingDuck is **NO-SIGNAL** and is shown as
`n/a(no-signal)`.
- Such a matchup is **never able to fail the run** — it is flagged
`NO-SIGNAL (not a gate)` and its score differential is reported for
information only. A 0-0 draw must not be reported as a regression.
- Use `OscillatorBot` / `Observer` for real survival signal.
---
## `adversaries/Observer`
Promoted from `/tmp/dcbv/observer`. It never fires, only spins its radar at
45°/tick, and:
- appends every scan to `scans.csv` (turn, id, name, x, y),
- appends the opponent position to `obs.csv` (turn, x, y),
- accumulates the Euclidean distance the **opponent** travels between
consecutive scans, written to `obs_result.txt` on round end.
That travelled distance is the metric that actually proves a bot MOVES — score
and survival counters do not. A prior run measured ~6600 units across the
1200×1200 arena.
Output paths are parameters, not the old hardcoded `/tmp/dcbv/*.csv`:
| Env | Default | File |
|---|---|---|
| `OBS_OUT_DIR` | process cwd | directory for `scans.csv`, `obs.csv` |
| `OBS_FILE` | `$OBS_OUT_DIR/obs_result.txt` | one-line result |
```sh
OBS_OUT_DIR=/tmp/obs ./tools/test_runner/runner \
--bot DevControlBot_garage --opponents tools/test_runner/adversaries/Observer
```
---
## Files
| File | Role |
|---|---|
| `runner.nim` | CLI entry (main), wiring only |
| `resolve.nim` | stem derivation, `.battletest.json`, env gating |
| `stage.nim` | staging dir builder + dir-name assertion |
| `suites.nim` | `baseline` / `all` / `GAUNTLET` opponent matrices |
| `report.nim` | table renderer, JSON output, exit-code policy |
| `adversaries/Observer/` | promoted measurement bot |
`stage.nim` and `suites.nim` are self-checking (`nim c -r` runs assertions on
the dir-name invariant and the matrix logic).