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:
@@ -9,3 +9,4 @@ when withDir(thisDir(), system.fileExists("nimble.paths")):
|
|||||||
# Use the repo-vendored Tank Royale bot API (libs/) instead of the nimble pkg.
|
# Use the repo-vendored Tank Royale bot API (libs/) instead of the nimble pkg.
|
||||||
# Must come AFTER the nimble.paths include: later --path wins the import search.
|
# Must come AFTER the nimble.paths include: later --path wins the import search.
|
||||||
switch("path", thisDir() & "/../libs/tankroyale_botapi")
|
switch("path", thisDir() & "/../libs/tankroyale_botapi")
|
||||||
|
switch("path", thisDir() & "/../libs/radar_lock")
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
@@ -1,4 +1,60 @@
|
|||||||
## SAC_LSTM_Bot — placeholder main module.
|
## SAC_LSTM_Bot — skeleton: radar lock + "Recurrent Royalty" color scheme.
|
||||||
## SAC (Soft Actor-Critic) + LSTM Tank Royale bot.
|
## 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)
|
||||||
|
|||||||
Reference in New Issue
Block a user