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))