DevControlBot 1.2.0: TFIL survival movement + universal battle runner
Ported "the floor is lava" (TFIL) movement into DevControlBot as a self-contained module, DevControlBot/modules/tfil.nim. It has no runtime dependency on common_libs/: the port is a standalone implementation, parity-verified against the common_libs original over 2000 differential ticks with zero divergences. Do not re-introduce the dependency and do not edit the original to match. Debug graphics (per-tile lava heat, tracked bullets and their danger corridors, enemy core/aura, reachable hull, committed tile) are OFF by default and compile-time gated behind -d:tfilDebug; see README.md for the plain `nim c` invocation, since nimble runBot does not forward compile flags. Wired into DevControlBot.nim: movement computed between commandRadar() and go(), fire-event tracking wired up, staleness handling for scanned enemies, and body colour set to BLACK at init (movement and radar both claim colour now). Also adds tools/test_runner, a shared battle-test runner usable by any garage, with an Observer adversary for quick floor checks.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Observer",
|
||||
"version": "1.0.0",
|
||||
"authors": ["SirGarage test_runner"],
|
||||
"description": "Radar-only measurement adversary: logs scans as CSV and accumulates opponent travel distance",
|
||||
"gameTypes": ["classic", "1v1"],
|
||||
"platform": "Nim",
|
||||
"programmingLang": "Nim"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
cd "$(dirname "$0")"
|
||||
exec ./out/Observer 2>> "${OBS_OUT_DIR:-/tmp}/observer_stderr.log"
|
||||
@@ -0,0 +1,2 @@
|
||||
--path:"../../../.."
|
||||
switch("outdir", "out")
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Observer",
|
||||
"version": "1.0.0",
|
||||
"authors": ["SirGarage test_runner"],
|
||||
"description": "Radar-only measurement adversary: logs scans as CSV and accumulates opponent travel distance",
|
||||
"gameTypes": ["classic", "1v1"],
|
||||
"platform": "Nim",
|
||||
"programmingLang": "Nim"
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
## Observer — measurement adversary.
|
||||
##
|
||||
## Plays radar-only: spins its radar so it re-scans the opponent every tick,
|
||||
## logs every scan as CSV and accumulates the Euclidean distance the OPPONENT
|
||||
## travels between consecutive scans. That travelled distance is the metric that
|
||||
## actually proves a bot MOVES (a prior run measured ~6600 units across the
|
||||
## 1200x1200 arena); score and survival counters do not.
|
||||
##
|
||||
## Output location is a parameter, not a hardcoded /tmp path:
|
||||
## OBS_OUT_DIR directory for scans.csv / obs.csv / obs_result.txt
|
||||
## (default: the process working directory)
|
||||
## OBS_FILE file for the one-line result (default: <OBS_OUT_DIR>/obs_result.txt)
|
||||
|
||||
import std/[os, math, strformat]
|
||||
import robocode_tankroyale_botapi
|
||||
|
||||
type Observer = ref object of Bot
|
||||
samples: int
|
||||
dist: float
|
||||
lastX, lastY: float
|
||||
have: bool
|
||||
|
||||
proc appendLine(path, line: string) =
|
||||
let f = open(path, fmAppend)
|
||||
defer: f.close()
|
||||
f.writeLine line
|
||||
|
||||
proc outDir(): string =
|
||||
result = getEnv("OBS_OUT_DIR", getCurrentDir())
|
||||
createDir(result)
|
||||
|
||||
method onScannedBot(bot: Observer, e: ScannedBotEvent) =
|
||||
if e.scannedBotId == getMyId(): return # 2-bot battle: only the other bot matters
|
||||
|
||||
let d = outDir()
|
||||
appendLine(d / "scans.csv",
|
||||
&"{getTurn()} id={e.scannedBotId} name={getBotName(e.scannedBotId)} x={e.x} y={e.y}")
|
||||
appendLine(d / "obs.csv", &"{getTurn()},{e.x},{e.y}")
|
||||
|
||||
inc bot.samples
|
||||
if bot.have:
|
||||
bot.dist += hypot(e.x - bot.lastX, e.y - bot.lastY)
|
||||
bot.lastX = e.x; bot.lastY = e.y; bot.have = true
|
||||
|
||||
method onTick(bot: Observer, e: TickEventForBot) =
|
||||
## Spin the radar so the opponent is re-scanned every tick — that cadence is
|
||||
## what makes the accumulated travel distance meaningful.
|
||||
setRadarTurnRate(45)
|
||||
|
||||
method onRoundEnded(bot: Observer, e: RoundEndedEventForBot) =
|
||||
let d = outDir()
|
||||
writeFile(getEnv("OBS_FILE", d / "obs_result.txt"),
|
||||
&"OBS samples={bot.samples} dist={bot.dist:.3f}")
|
||||
|
||||
when isMainModule:
|
||||
let jsonPath =
|
||||
if paramCount() >= 1: paramStr(1)
|
||||
else: currentSourcePath().parentDir / "Observer.json"
|
||||
start(Observer(), jsonPath)
|
||||
Reference in New Issue
Block a user