c034eb9d25
- fix(ModularBot): onBulletHitBot → onBulletHit (real hits were never tracked) - feat(ModularBot): per-round gun stats dump to /tmp/gun_stats.jsonl - feat(ModularBot): gun selection counter per round - fix(tests): adversary paths _garage suffix removed from 7 test files - feat(tests): test_gauntlet_5bots.nim — 10-round gauntlet vs all 5 adversaries - feat(tests): analyze_gun_stats.nim — JSONL parser for gun performance tables - docs: gun_rack_analysis.md — full per-gun performance report - docs: gun_rack_summary.md — TL;DR verdict table (keep/drop/tune) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
2.3 KiB
Nim
72 lines
2.3 KiB
Nim
import std/[os, sequtils, unittest]
|
|
import test_framework/test_framework
|
|
import test_framework/battle_result
|
|
import test_framework/server_manager
|
|
import test_framework/bot_compiler
|
|
import test_framework/runner_process
|
|
|
|
const
|
|
modularBotDir = currentSourcePath().parentDir.parentDir
|
|
tfAdversaries = currentSourcePath().parentDir.parentDir.parentDir /
|
|
"common_libs" / "test_framework" / "adversaries"
|
|
sittingDuck = tfAdversaries / "SittingDuck"
|
|
|
|
# Skip if JARs are missing
|
|
if not fileExists("/home/davide/Projects/tank-royale/server/build/libs/robocode-tankroyale-server-0.35.5-all.jar") or
|
|
not fileExists("/home/davide/Projects/tank-royale/runner/examples/lib/robocode-tankroyale-runner.jar"):
|
|
echo "Skipping: Tank Royale JARs not found"
|
|
quit(0)
|
|
|
|
suite "ModularBot basic battle":
|
|
test "beats SittingDuck in 1 round":
|
|
# Debug: manually compile and check
|
|
try:
|
|
let compiledBots = compileBots(@[modularBotDir, sittingDuck])
|
|
echo "Compiled bots: ", compiledBots
|
|
for bot in compiledBots:
|
|
if fileExists(bot):
|
|
echo " ✓ ", bot
|
|
else:
|
|
echo " ✗ MISSING: ", bot
|
|
except CatchableError as e:
|
|
echo "Compilation error: ", e.msg
|
|
raise
|
|
|
|
# Now run battle with longer timeout for ModularBot boot
|
|
ensureServer()
|
|
let stdout = runBattleRunner(getServerUrl(), @[modularBotDir, sittingDuck], 1, 180000, true)
|
|
echo ""
|
|
echo "Raw battle runner output:"
|
|
echo stdout
|
|
echo ""
|
|
|
|
let r = parseServerOutput(stdout)
|
|
|
|
echo ""
|
|
echo "=== Battle Result ==="
|
|
echo "Rounds: ", r.rounds.len
|
|
echo "Bots: ", r.bots
|
|
echo ""
|
|
echo "Final standings:"
|
|
for result in r.results:
|
|
echo " ", result.name, ": rank=", result.rank, " score=", result.totalScore,
|
|
" survived=", result.survivalCount, " first=", result.firstPlaces
|
|
echo ""
|
|
echo "Winners: ", r.winners
|
|
echo ""
|
|
|
|
# Basic checks
|
|
let botNames = r.results.mapIt(it.name)
|
|
check r.rounds.len == 1
|
|
check r.results.len == 2
|
|
check "ModularBot" in botNames
|
|
check "SittingDuck" in botNames
|
|
|
|
# ModularBot should win
|
|
var modularResult: BotResult
|
|
for b in r.results:
|
|
if b.name == "ModularBot": modularResult = b
|
|
check modularResult.name == "ModularBot"
|
|
check modularResult.rank == 1
|
|
check "ModularBot" in r.winners
|