Files
SirRoboGarage/ModularBot_garage/tests/test_modularbot_battle.nim
T
SirStone 254c7dc997 feat(ModularBot): pluggable bot with 4 guns, phantom meteor movement, radar harness
- Gun harness: virtual bullet tracker, rolling fitness, auto-selector
- Guns: head-on, linear (extrapolation), circular (integrated formula), tsetlin machine (learning)
- Movement: phantom meteor gravity engine (danger histograms, phantom bullets, fire detection)
- Radar: harness + radar_lock adapter
- Color-coded modules: turret/bullet color per gun, body per movement, scan per radar
- Beats Target, SpinBot, Crazy, TrackFire in 10-round battles
2026-09-20 00:37:10 +02:00

71 lines
2.3 KiB
Nim

import std/[os, 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
check r.rounds.len == 1
check r.results.len == 2
check "ModularBot" in r.bots
check "SittingDuck" in r.bots
# 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