From fbf941437576e34002a9d6998358c205793bf9c9 Mon Sep 17 00:00:00 2001 From: Davide Cappellini Date: Sun, 20 Sep 2026 01:46:52 +0200 Subject: [PATCH] feat(ModularBot): rammer movement + averaged-lead gun, 12 guns - Ram movement: drive straight at enemy (not wired, needs selector) - Averaged-lead gun: mean of linear+circular+wall-bounce predictions - 12 guns total, battle-tested Co-Authored-By: Claude Sonnet 4.6 --- ModularBot_garage/src/ModularBot.nim | 15 ++++++++--- common_libs/guns/averaged_lead.nim | 37 ++++++++++++++++++++++++++++ common_libs/movements/rammer.nim | 31 +++++++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 common_libs/guns/averaged_lead.nim create mode 100644 common_libs/movements/rammer.nim diff --git a/ModularBot_garage/src/ModularBot.nim b/ModularBot_garage/src/ModularBot.nim index cc8ba17..0785716 100644 --- a/ModularBot_garage/src/ModularBot.nim +++ b/ModularBot_garage/src/ModularBot.nim @@ -1,5 +1,5 @@ ## ModularBot — plugin gun architecture tracer bullet. -## Guns: HeadOnGun (0), LinearGun (1), TsetlinGun (2), CircularGun (3), GFGun (4), PatternMatcherGun (5), AntiSurferGun (6), WallBounceGun (7), AccelGun (8), StopShotGun (9) via GunHarness. +## Guns: HeadOnGun (0), LinearGun (1), TsetlinGun (2), CircularGun (3), GFGun (4), PatternMatcherGun (5), AntiSurferGun (6), WallBounceGun (7), AccelGun (8), StopShotGun (9), DisplacementGun (10), AveragedLeadGun (11) via GunHarness. ## Radar: RadarLockModule via radar harness. ## Movement: OscillatorModule (perpendicular strafing). @@ -21,12 +21,13 @@ import guns/wall_bounce import guns/accel_predictor import guns/stop_shot import guns/displacement +import guns/averaged_lead import movements/phantom_meteor const botJsonPath = currentSourcePath().parentDir / "ModularBot.json" const DebugVBullets = false const DebugCircular = false -const GunNames = ["HeadOn", "Linear", "Tsetlin", "Circular", "GuessFactor", "Pattern", "AntiSurf", "WallBounce", "Accel", "StopShot", "Displace"] +const GunNames = ["HeadOn", "Linear", "Tsetlin", "Circular", "GuessFactor", "Pattern", "AntiSurf", "WallBounce", "Accel", "StopShot", "Displace", "AvgLead"] type ModularBot = ref object of Bot @@ -46,6 +47,7 @@ type accelGun: AccelGun stopShot: StopShotGun displace: DisplacementGun + avgLead: AveragedLeadGun mover: PhantomMeteorModule virtualHits: int virtualMiss: int @@ -87,6 +89,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) = var acPreds: array[len(PowerBins), GunPrediction] var ssPreds: array[len(PowerBins), GunPrediction] var dsPreds: array[len(PowerBins), GunPrediction] + var alPreds: array[len(PowerBins), GunPrediction] for i in 0.. 180.0: delta -= 360.0 + while delta < -180.0: delta += 360.0 + + # If enemy is behind (|delta| > 90°), reverse to avoid U-turn + let (speed, turnDelta) = + if abs(delta) <= 90.0: + (MaxSpeed, delta) + else: + let backDelta = if delta > 0.0: delta - 180.0 else: delta + 180.0 + (-MaxSpeed, backDelta) + + (speed: speed, turnRate: turnDelta.clamp(-10.0, 10.0))