feat(ModularBot): anti-surfer gun + wave-surf movement module
- Anti-surfer gun: inverse GF targeting for wave-surfing enemies - Wave-surf movement: danger histogram dodge (not wired yet, needs movement selector) - 7 guns total, battle-tested Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
## Gauntlet: ModularBot vs WaveSurfer, SpinBot, Crazy — 10 rounds each.
|
||||
## Captures [gun] lines and scores. Run with:
|
||||
## nim c -r --path:../../common_libs tests/test_gauntlet.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"
|
||||
waveSurferDir = "/home/davide/Projects/SirRoboGarage/WaveSurfer_garage"
|
||||
spinBotDir = samplesDir / "SpinBot"
|
||||
crazyDir = samplesDir / "Crazy"
|
||||
|
||||
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 = 240000)
|
||||
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 WaveSurfer", "WaveSurfer", waveSurferDir)
|
||||
runAndReport("Battle 2/3: vs SpinBot", "SpinBot", spinBotDir)
|
||||
runAndReport("Battle 3/3: vs Crazy", "Crazy", crazyDir)
|
||||
echo "\nGauntlet complete."
|
||||
@@ -0,0 +1,68 @@
|
||||
## Gauntlet with [gun] line capture via raw runner output.
|
||||
## nim c -r --path:../../common_libs tests/test_gauntlet_guns.nim
|
||||
|
||||
import std/[os, strutils, strformat, tables]
|
||||
import test_framework/server_manager
|
||||
import test_framework/bot_compiler
|
||||
import test_framework/runner_process
|
||||
import test_framework/battle_result
|
||||
|
||||
const
|
||||
modularBotDir = currentSourcePath().parentDir.parentDir
|
||||
samplesDir = "/home/davide/Downloads/robocode-tankroyale/sample-bots-nim-linux-1.0.7"
|
||||
waveSurferDir = "/home/davide/Projects/SirRoboGarage/WaveSurfer_garage"
|
||||
spinBotDir = samplesDir / "SpinBot"
|
||||
crazyDir = samplesDir / "Crazy"
|
||||
|
||||
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 gunCounts(raw: string): Table[string, int] =
|
||||
## Count [gun] switched: <Name> occurrences
|
||||
for line in raw.splitLines():
|
||||
if "[gun] switched:" in line:
|
||||
let parts = line.split(":")
|
||||
if parts.len >= 2:
|
||||
let name = parts[^1].strip()
|
||||
result[name] = result.getOrDefault(name, 0) + 1
|
||||
|
||||
proc runAndReport(label, enemyName, enemyDir: string) =
|
||||
let sep = "=".repeat(50)
|
||||
echo "\n" & sep
|
||||
echo " " & label
|
||||
echo sep
|
||||
let bots = @[modularBotDir, enemyDir]
|
||||
discard compileBots(bots)
|
||||
let raw = runBattleRunner(getServerUrl(), bots, 10, 240000, true)
|
||||
let r = parseServerOutput(raw)
|
||||
|
||||
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 " Score: ModularBot " & $mbScore & " " & enemyName & " " & $enScore & " -> " & winner & " wins"
|
||||
|
||||
let guns = gunCounts(raw)
|
||||
if guns.len > 0:
|
||||
echo " Gun switches:"
|
||||
for name, count in guns.pairs:
|
||||
echo fmt" [gun] {name}: {count}x"
|
||||
else:
|
||||
echo " (no [gun] switch lines in output)"
|
||||
|
||||
# Show all [gun] lines for visibility
|
||||
var gunLines: seq[string]
|
||||
for line in raw.splitLines():
|
||||
if line.contains("[gun]"): gunLines.add(line.strip())
|
||||
if gunLines.len > 0:
|
||||
echo fmt" First 20 [gun] lines:"
|
||||
for l in gunLines[0..min(19, gunLines.high)]: echo fmt" {l}"
|
||||
|
||||
ensureServer()
|
||||
runAndReport("Battle 1/3: vs WaveSurfer", "WaveSurfer", waveSurferDir)
|
||||
runAndReport("Battle 2/3: vs SpinBot", "SpinBot", spinBotDir)
|
||||
runAndReport("Battle 3/3: vs Crazy", "Crazy", crazyDir)
|
||||
echo "\nGauntlet complete."
|
||||
Reference in New Issue
Block a user