diff --git a/ModularBot_garage/src/ModularBot.nim b/ModularBot_garage/src/ModularBot.nim index 0785716..9c97f94 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), DisplacementGun (10), AveragedLeadGun (11) 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), DecayGFGun (12) via GunHarness. ## Radar: RadarLockModule via radar harness. ## Movement: OscillatorModule (perpendicular strafing). @@ -22,12 +22,13 @@ import guns/accel_predictor import guns/stop_shot import guns/displacement import guns/averaged_lead +import guns/decay_gf 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", "AvgLead"] +const GunNames = ["HeadOn", "Linear", "Tsetlin", "Circular", "GuessFactor", "Pattern", "AntiSurf", "WallBounce", "Accel", "StopShot", "Displace", "AvgLead", "DecayGF"] type ModularBot = ref object of Bot @@ -48,6 +49,7 @@ type stopShot: StopShotGun displace: DisplacementGun avgLead: AveragedLeadGun + decayGF: DecayGFGun mover: PhantomMeteorModule virtualHits: int virtualMiss: int @@ -90,6 +92,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) = var ssPreds: array[len(PowerBins), GunPrediction] var dsPreds: array[len(PowerBins), GunPrediction] var alPreds: array[len(PowerBins), GunPrediction] + var dgPreds: array[len(PowerBins), GunPrediction] for i in 0.. g.bins[best]: + best = i + best + +proc predict*(g: var DecayGFGun, state: WorldState, bulletSpeed: float): GunPrediction = + if bulletSpeed <= 0.0: + return GunPrediction(x: state.enemyX, y: state.enemyY) + + let dx = state.enemyX - state.selfX + let dy = state.enemyY - state.selfY + let dist = sqrt(dx*dx + dy*dy) + let bearing = arctan2(dy, dx) + let mea = arcsin(clamp(8.0 / bulletSpeed, -1.0, 1.0)) + + if state.tick != g.cachedTick: + # Decay all bins once per tick + for i in 0.. PI: bearingDelta -= 2.0*PI + while bearingDelta < -PI: bearingDelta += 2.0*PI + + let gf = if mea > 1e-10: clamp(bearingDelta / mea, -1.0, 1.0) else: 0.0 + let centerIdx = gfToIndex(gf) + + for i in 0..