1ed7797cb6
- New guns: guess-factor (GF histogram), pattern-matcher (movement tape replay) - New modules: minimum-risk melee movement, spinning melee radar - New test bots: PatternMover, RandomMover, WaveSurfer - Fixed: FeedbackEvent now carries actualX/actualY for proper GF learning - Fixed: TM gun warmup gating + directional residuals - Fixed: circular gun integrated formula + multi-bin omega cache - Fixed: oscillator wall-bounce lockout - Fixed: phantom meteor perpendicular body orientation - 6/6 battle wins across all enemy types
47 lines
1.3 KiB
Nim
47 lines
1.3 KiB
Nim
# RandomMover — random speed/turn with persistence, head-on firing.
|
|
# Purpose: test guns against unpredictable movement.
|
|
|
|
import std/[math, os, random]
|
|
import tankroyale_botapi
|
|
|
|
const botJsonPath = currentSourcePath().parentDir / "RandomMover.json"
|
|
|
|
type RandomMover = ref object of Bot
|
|
currentSpeed: float
|
|
currentTurn: float
|
|
ticksUntilChange: int
|
|
|
|
proc newDirection(bot: RandomMover) =
|
|
bot.currentSpeed = rand(-8.0..8.0)
|
|
bot.currentTurn = rand(-10.0..10.0)
|
|
bot.ticksUntilChange = rand(10..20)
|
|
|
|
method onRoundStarted*(bot: RandomMover, e: RoundStartedEvent) =
|
|
randomize()
|
|
setAdjustGunForBodyTurn(true)
|
|
setAdjustRadarForBodyTurn(true)
|
|
setAdjustRadarForGunTurn(true)
|
|
newDirection(bot)
|
|
|
|
method onScannedBot*(bot: RandomMover, e: ScannedBotEvent) =
|
|
let bearing = directionTo(getX(), getY(), e.x, e.y)
|
|
let gunDelta = normalizeRelativeAngle(bearing - getGunDirection())
|
|
setGunTurnRate(gunDelta.clamp(-MAX_GUN_TURN_RATE, MAX_GUN_TURN_RATE))
|
|
if abs(gunDelta) < 10.0 and getGunHeat() <= 0.0:
|
|
discard setFire(1.0)
|
|
|
|
method run*(bot: RandomMover) =
|
|
while isRunning():
|
|
dec bot.ticksUntilChange
|
|
if bot.ticksUntilChange <= 0:
|
|
newDirection(bot)
|
|
|
|
setTargetSpeed(bot.currentSpeed)
|
|
setTurnRate(bot.currentTurn)
|
|
setRadarTurnRate(45.0)
|
|
go()
|
|
|
|
when isMainModule:
|
|
var bot = RandomMover()
|
|
start(bot, botJsonPath)
|