feat(SNNBot): upgrade bot API, fix debug overlay and aiming lines

- Upgrade to robocode_tankroyale_botapi v1.0.7 (SVG viewBox fix)
- Fix Y-axis mirror in aiming line toXY helper
- Resize debug panel to half arena width/height
- Replace neuron boxes with barcode-style spike lines
- Thickness-encoded weight connections (all 216 lines)
- Add aiming line legend (top-left, white text)
- Dynamic aiming line length (distance + 50px overshoot)
This commit is contained in:
2026-09-13 10:24:20 +02:00
parent 57a1915b10
commit c038128c2f
12 changed files with 404 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
## Integration test: SNNBot vs SittingDuck.
## Requires a running TR server (set TR_SERVER_JAR / TR_BATTLE_RUNNER env vars).
## Also includes an offline parseServerOutput unit test — no Java needed.
import std/[os, unittest]
import test_framework/battle_result
# ---------- offline unit test (no server needed) ----------
suite "parseServerOutput":
test "parses a 1-round battle fixture":
const fixture = """
{"event":"game_started","bots":["SNNBot","SittingDuck"]}
{"event":"round_ended","round":1,"results":[{"name":"SNNBot","score":100,"rank":1,"survived":true},{"name":"SittingDuck","score":0,"rank":2,"survived":false}]}
{"event":"battle_ended","results":[{"name":"SNNBot","totalScore":100,"rank":1,"firstPlaces":1,"survivalCount":1},{"name":"SittingDuck","totalScore":0,"rank":2,"firstPlaces":0,"survivalCount":0}]}
"""
let r = parseServerOutput(fixture)
check r.bots == @["SNNBot", "SittingDuck"]
check r.rounds.len == 1
check r.rounds[0].results[0].name == "SNNBot"
check r.rounds[0].results[0].survived == true
check r.results.len == 2
check r.winners == @["SNNBot"]
# ---------- integration tests (require TR server + BattleRunner JARs) ----------
const
DefaultServerJar = "/home/davide/Projects/tank-royale/server/build/libs/robocode-tankroyale-server-0.35.5-all.jar"
DefaultRunnerJar = "/home/davide/Projects/tank-royale/runner/examples/lib/robocode-tankroyale-runner.jar"
let serverJar = getEnv("TR_SERVER_JAR", DefaultServerJar)
let runnerJar = getEnv("TR_BATTLE_RUNNER", DefaultRunnerJar)
if not fileExists(serverJar) or not fileExists(runnerJar):
echo "Skipping integration tests: JAR files not found (set TR_SERVER_JAR / TR_BATTLE_RUNNER to override)"
quit(0)
import test_framework/test_framework
const
snnbotDir = currentSourcePath().parentDir.parentDir
sittingDuckDir = currentSourcePath().parentDir.parentDir.parentDir /
"common_libs" / "test_framework" / "adversaries" / "SittingDuck"
suite "SNNBot integration battles":
test "completes 1 round vs SittingDuck without crashing":
let r = runBattle(@[snnbotDir, sittingDuckDir], rounds = 1)
check r.rounds.len == 1
check r.results.len == 2
var snn, duck: BotResult
for b in r.results:
if b.name == "SNNBot": snn = b
if b.name == "SittingDuck": duck = b
check snn.name == "SNNBot"
check duck.name == "SittingDuck"
# Just assert it completed and scored something — no aiming quality check
check snn.totalScore >= 0
check duck.totalScore >= 0
for rnd in r.rounds:
check rnd.results.len == 2
for br in rnd.results:
check br.score >= 0