feat(SAC_LSTM_Bot): skeleton bot with radar lock and colors (#40)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 23:37:50 +02:00
parent 7d73d32c85
commit a0a3840980
3 changed files with 71 additions and 3 deletions
+11
View File
@@ -0,0 +1,11 @@
{
"name": "Recurrent Royalty",
"version": "0.1.0",
"authors": ["Davide Cappellini"],
"description": "SAC+LSTM Tank Royale bot — skeleton with radar lock",
"homepage": "",
"countryCodes": ["IT"],
"gameTypes": ["classic", "melee", "1v1"],
"platform": "Nim",
"programmingLang": "Nim"
}
+59 -3
View File
@@ -1,4 +1,60 @@
## SAC_LSTM_Bot — placeholder main module.
## SAC (Soft Actor-Critic) + LSTM Tank Royale bot.
## SAC_LSTM_Bot — skeleton: radar lock + "Recurrent Royalty" color scheme.
## No RL yet. Connects, sets colors, locks radar onto enemy.
echo "SAC_LSTM_Bot scaffold"
import std/os
import tankroyale_botapi
import radar_lock
const botJsonPath = currentSourcePath().parentDir / "SAC_LSTM_Bot.json"
# ── Colors (Recurrent Royalty palette) ───────────────────────────────────────
const
ColBody = fromHex("#7B2FBE")
ColTurret = fromHex("#FFD700")
ColGun = fromHex("#4A0E6B")
ColRadar = fromHex("#FFD700")
ColScan = fromHex("#FFB000")
ColBullet = fromHex("#FFC125")
ColTracks = fromHex("#2C2C34")
proc applyColors() =
setBodyColor(ColBody)
setTurretColor(ColTurret)
setGunColor(ColGun)
setRadarColor(ColRadar)
setScanColor(ColScan)
setBulletColor(ColBullet)
setTracksColor(ColTracks)
# ── Bot type ──────────────────────────────────────────────────────────────────
type SacBot = ref object of Bot
enemyBearing: float # last known absolute bearing to enemy
# ── Event handlers ────────────────────────────────────────────────────────────
method onRoundStarted*(bot: SacBot, e: RoundStartedEvent) =
setAdjustRadarForBodyTurn(true)
setAdjustRadarForGunTurn(true)
radar_lock.init()
applyColors()
method onScannedBot*(bot: SacBot, e: ScannedBotEvent) =
bot.enemyBearing = directionTo(getX(), getY(), e.x, e.y)
# Same-tick radar lock: apply turn rate immediately so it takes effect this tick.
setRadarTurnRate(radar_lock.doRadar(getRadarDirection(), bot.enemyBearing))
# ── Run loop ──────────────────────────────────────────────────────────────────
method run(bot: SacBot) =
while isRunning():
# Spin radar when no enemy is visible (full sweep).
if bot.enemyBearing == 0.0:
setRadarTurnRate(45.0)
go()
# ── Entry point ───────────────────────────────────────────────────────────────
when isMainModule:
var bot = SacBot()
start(bot, botJsonPath)