simplify(BNNBot): raw 10-bit binary encoding, clean output

- Replace population/thermometer/signed-thermometer encoding with simple 10-bit binary per value
- 5 values × 10 bits = 50 bits total (was 112)
- Each value normalized to 0-1023, then bit-extracted MSB-first
- Output is now just tick and raw binary string (no field labels, no debug log)
- Remove file logging entirely; stdout only

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 22:24:52 +02:00
parent 808ae44703
commit b31d1bf99f
2 changed files with 32 additions and 126 deletions
+4 -21
View File
@@ -1,22 +1,13 @@
# BNNBot — binary encoding data collector.
# Radar lock on enemy, converts each scan to a 112-bit BinaryVector, logs + prints it.
# Radar lock on enemy, converts each scan to a 50-bit BinaryVector, prints it.
# No aiming, no firing — pure scan visualization for BNN research.
import std/[math, strformat, os]
import std/[math, os]
import robocode_tankroyale_botapi
import radar_lock/radar_lock as radar_lock
import binary_encoding
const botJsonPath = currentSourcePath().parentDir / "BNNBot.json"
const scanLog = "/tmp/bnnbot_scan.log"
proc appendLog(s: string) =
try:
let f = open(scanLog, fmAppend)
f.writeLine(s)
f.close()
except:
discard
type
BNNBot = ref object of Bot
@@ -53,10 +44,7 @@ method onScannedBot*(bot: BNNBot, e: ScannedBotEvent) =
speed: bot.speed,
)
let vec = encode(scan)
let fmt = formatBinary(vec)
let line = fmt"t={bot.tick} bear={bot.enemyBearing:.1f} dist={bot.distance:.0f} vel={bot.velocity:.2f} head={bot.heading:.1f} spd={bot.speed:.2f} pop={popcount(vec)} {fmt}"
echo line
appendLog(line)
echo $bot.tick, " ", formatBinary(vec)
method onRoundStarted*(bot: BNNBot, e: RoundStartedEvent) =
setAdjustGunForBodyTurn(true)
@@ -70,12 +58,7 @@ method onRoundStarted*(bot: BNNBot, e: RoundStartedEvent) =
setTurnRate(0.0)
method onGameStarted*(bot: BNNBot, e: GameStartedEventForBot) =
# Truncate log on game start
try:
let f = open(scanLog, fmWrite)
f.close()
except:
discard
discard
method run*(bot: BNNBot) =
while isRunning():