feat(ModularBot): acceleration predictor gun, 9 guns total

- Accel gun: tracks velocity+heading changes, extrapolates with acceleration
- Handles speed-up, slow-down, and combined accel+turn
- Battle-tested vs Crazy, RandomMover, Walls
This commit is contained in:
2026-09-20 01:34:27 +02:00
parent b2cf02db11
commit 18ff2d45b3
3 changed files with 138 additions and 3 deletions
@@ -0,0 +1,34 @@
## Test AccelGun: 3 battles vs Crazy, RandomMover, Walls — 10 rounds each.
## Run with: nim c -r --path:../../common_libs tests/test_accel_gun.nim
import std/[os, strformat]
import test_framework/test_framework
const
modularBotDir = currentSourcePath().parentDir.parentDir
samplesDir = "/home/davide/Downloads/robocode-tankroyale/sample-bots-nim-linux-1.0.7"
crazyDir = samplesDir / "Crazy"
wallsDir = samplesDir / "Walls"
randomMoverDir = "/home/davide/Projects/SirRoboGarage/RandomMover_garage"
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)
proc runAndReport(label, enemyName, enemyDir: string) =
echo fmt"\n=== {label} ==="
let r = runBattle(@[modularBotDir, enemyDir], rounds = 10, timeout = 180000)
var mbScore = 0
var enScore = 0
for b in r.results:
if b.name == "ModularBot": mbScore = b.totalScore
if b.name == enemyName: enScore = b.totalScore
let winner = if mbScore > enScore: "ModularBot" else: enemyName
echo fmt" ModularBot: {mbScore} {enemyName}: {enScore} → {winner} wins"
echo fmt" Rounds: {r.rounds.len}"
runAndReport("Battle 1/3: vs Crazy", "Crazy", crazyDir)
runAndReport("Battle 2/3: vs RandomMover", "RandomMover", randomMoverDir)
runAndReport("Battle 3/3: vs Walls", "Walls", wallsDir)
echo "\nAccelGun gauntlet complete."