feat(ModularBot): anti-surfer gun + wave-surf movement module
- Anti-surfer gun: inverse GF targeting for wave-surfing enemies - Wave-surf movement: danger histogram dodge (not wired yet, needs movement selector) - 7 guns total, battle-tested Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
## ModularBot — plugin gun architecture tracer bullet.
|
||||
## Guns: HeadOnGun (0), LinearGun (1), TsetlinGun (2), CircularGun (3), GFGun (4), PatternMatcherGun (5) via GunHarness.
|
||||
## Guns: HeadOnGun (0), LinearGun (1), TsetlinGun (2), CircularGun (3), GFGun (4), PatternMatcherGun (5), AntiSurferGun (6) via GunHarness.
|
||||
## Radar: RadarLockModule via radar harness.
|
||||
## Movement: OscillatorModule (perpendicular strafing).
|
||||
|
||||
@@ -16,12 +16,13 @@ import guns/circular
|
||||
import guns/tsetlin
|
||||
import guns/guess_factor
|
||||
import guns/pattern_matcher
|
||||
import guns/anti_surfer
|
||||
import movements/phantom_meteor
|
||||
|
||||
const botJsonPath = currentSourcePath().parentDir / "ModularBot.json"
|
||||
const DebugVBullets = false
|
||||
const DebugCircular = false
|
||||
const GunNames = ["HeadOn", "Linear", "Tsetlin", "Circular", "GuessFactor", "Pattern"]
|
||||
const GunNames = ["HeadOn", "Linear", "Tsetlin", "Circular", "GuessFactor", "Pattern", "AntiSurf"]
|
||||
|
||||
type
|
||||
ModularBot = ref object of Bot
|
||||
@@ -36,6 +37,7 @@ type
|
||||
tsetlin: TsetlinGun
|
||||
guessFactor: GFGun
|
||||
patternMatcher: PatternMatcherGun
|
||||
antiSurfer: AntiSurferGun
|
||||
mover: PhantomMeteorModule
|
||||
virtualHits: int
|
||||
virtualMiss: int
|
||||
@@ -72,6 +74,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
|
||||
var circPreds: array[len(PowerBins), GunPrediction]
|
||||
var gfPreds: array[len(PowerBins), GunPrediction]
|
||||
var pmPreds: array[len(PowerBins), GunPrediction]
|
||||
var asPreds: array[len(PowerBins), GunPrediction]
|
||||
for i in 0..<len(PowerBins):
|
||||
headsUp[i] = bot.headOn.predict(bot.lastState, bulletSpeed(PowerBins[i]))
|
||||
linPreds[i] = bot.linear.predict(bot.lastState, bulletSpeed(PowerBins[i]))
|
||||
@@ -79,6 +82,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
|
||||
circPreds[i] = bot.circular.predict(bot.lastState, bulletSpeed(PowerBins[i]))
|
||||
gfPreds[i] = bot.guessFactor.predict(bot.lastState, bulletSpeed(PowerBins[i]))
|
||||
pmPreds[i] = bot.patternMatcher.predict(bot.lastState, bulletSpeed(PowerBins[i]))
|
||||
asPreds[i] = bot.antiSurfer.predict(bot.lastState, bulletSpeed(PowerBins[i]))
|
||||
|
||||
bot.tracker.spawnBullets(0, headsUp, bot.lastState)
|
||||
bot.tracker.spawnBullets(1, linPreds, bot.lastState)
|
||||
@@ -88,6 +92,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
|
||||
bot.tracker.spawnBullets(3, circPreds, bot.lastState)
|
||||
bot.tracker.spawnBullets(4, gfPreds, bot.lastState)
|
||||
bot.tracker.spawnBullets(5, pmPreds, bot.lastState)
|
||||
bot.tracker.spawnBullets(6, asPreds, bot.lastState)
|
||||
|
||||
# Resolve bullets that have travelled far enough
|
||||
let st = bot.lastState
|
||||
@@ -104,6 +109,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
|
||||
echo fmt"[circ-vb] predicted=({fe.prediction.x:.0f},{fe.prediction.y:.0f}) actual=({ax:.0f},{ay:.0f}) miss={fe.missDistance:.1f}px hit={fe.hit}"
|
||||
of 4: bot.guessFactor.onResult(fe)
|
||||
of 5: bot.patternMatcher.onResult(fe)
|
||||
of 6: bot.antiSurfer.onResult(fe)
|
||||
else: discard
|
||||
if fe.hit: inc bot.virtualHits else: inc bot.virtualMiss
|
||||
when DebugVBullets:
|
||||
@@ -126,6 +132,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
|
||||
of 3: setTurretColor("#33CC33"); setBulletColor("#66FF66") # Circular: emerald
|
||||
of 4: setTurretColor("#FFCC00"); setBulletColor("#FFE066") # GuessFactor: yellow
|
||||
of 5: setTurretColor("#FF6600"); setBulletColor("#FF9944") # Pattern: orange
|
||||
of 6: setTurretColor("#00CCFF"); setBulletColor("#66DDFF") # AntiSurf: cyan
|
||||
else: discard
|
||||
|
||||
let pred = case selectedGun
|
||||
@@ -134,6 +141,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
|
||||
of 3: bot.circular.predict(bot.lastState, bulletSpeed(power))
|
||||
of 4: bot.guessFactor.predict(bot.lastState, bulletSpeed(power))
|
||||
of 5: bot.patternMatcher.predict(bot.lastState, bulletSpeed(power))
|
||||
of 6: bot.antiSurfer.predict(bot.lastState, bulletSpeed(power))
|
||||
else: bot.headOn.predict(bot.lastState, bulletSpeed(power))
|
||||
let target = aimAngle(getX(), getY(), pred.x, pred.y)
|
||||
|
||||
@@ -193,13 +201,14 @@ method run*(bot: ModularBot) =
|
||||
|
||||
when isMainModule:
|
||||
var bot = ModularBot(
|
||||
tracker: vb.initTracker(6), # 0: HeadOn, 1: Linear, 2: Tsetlin, 3: Circular, 4: GuessFactor, 5: Pattern
|
||||
tracker: vb.initTracker(7), # 0: HeadOn, 1: Linear, 2: Tsetlin, 3: Circular, 4: GuessFactor, 5: Pattern, 6: AntiSurf
|
||||
headOn: HeadOnGun(),
|
||||
linear: LinearGun(),
|
||||
circular: CircularGun(),
|
||||
tsetlin: initTsetlinGun(),
|
||||
guessFactor: initGFGun(),
|
||||
patternMatcher: PatternMatcherGun(),
|
||||
antiSurfer: initAntiSurferGun(),
|
||||
radar: RadarLockModule(),
|
||||
mover: initPhantomMeteor(),
|
||||
currentGun: -1,
|
||||
|
||||
Reference in New Issue
Block a user