feat(ModularBot): decay-GF gun (recency-weighted), 13 guns total

- Decay-GF: exponential decay on GF histogram (0.998/tick, ~350-tick half-life)
- Adapts faster to mid-battle strategy changes than standard GF
- Battle-tested vs WaveSurfer, Crazy, RandomMover
This commit is contained in:
2026-09-20 01:52:22 +02:00
parent 3a1149359d
commit c94ba1f2fe
3 changed files with 135 additions and 3 deletions
+12 -3
View File
@@ -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..<len(PowerBins):
headsUp[i] = bot.headOn.predict(bot.lastState, bulletSpeed(PowerBins[i]))
linPreds[i] = bot.linear.predict(bot.lastState, bulletSpeed(PowerBins[i]))
@@ -103,6 +106,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
ssPreds[i] = bot.stopShot.predict(bot.lastState, bulletSpeed(PowerBins[i]))
dsPreds[i] = bot.displace.predict(bot.lastState, bulletSpeed(PowerBins[i]))
alPreds[i] = bot.avgLead.predict(bot.lastState, bulletSpeed(PowerBins[i]))
dgPreds[i] = bot.decayGF.predict(bot.lastState, bulletSpeed(PowerBins[i]))
bot.tracker.spawnBullets(0, headsUp, bot.lastState)
bot.tracker.spawnBullets(1, linPreds, bot.lastState)
@@ -118,6 +122,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
bot.tracker.spawnBullets(9, ssPreds, bot.lastState)
bot.tracker.spawnBullets(10, dsPreds, bot.lastState)
bot.tracker.spawnBullets(11, alPreds, bot.lastState)
bot.tracker.spawnBullets(12, dgPreds, bot.lastState)
# Resolve bullets that have travelled far enough
let st = bot.lastState
@@ -140,6 +145,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
of 9: bot.stopShot.onResult(fe)
of 10: bot.displace.onResult(fe)
of 11: bot.avgLead.onResult(fe)
of 12: bot.decayGF.onResult(fe)
else: discard
if fe.hit: inc bot.virtualHits else: inc bot.virtualMiss
when DebugVBullets:
@@ -168,6 +174,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
of 9: setTurretColor("#990000"); setBulletColor("#CC3333") # StopShot: dark red
of 10: setTurretColor("#006600"); setBulletColor("#009900") # Displace: dark green
of 11: setTurretColor("#996633"); setBulletColor("#CC9966") # AvgLead: brown
of 12: setTurretColor("#008888"); setBulletColor("#00AAAA") # DecayGF: dark cyan
else: discard
let pred = case selectedGun
@@ -182,6 +189,7 @@ method onScannedBot*(bot: ModularBot, e: ScannedBotEvent) =
of 9: bot.stopShot.predict(bot.lastState, bulletSpeed(power))
of 10: bot.displace.predict(bot.lastState, bulletSpeed(power))
of 11: bot.avgLead.predict(bot.lastState, bulletSpeed(power))
of 12: bot.decayGF.predict(bot.lastState, bulletSpeed(power))
else: bot.headOn.predict(bot.lastState, bulletSpeed(power))
let target = aimAngle(getX(), getY(), pred.x, pred.y)
@@ -241,7 +249,7 @@ method run*(bot: ModularBot) =
when isMainModule:
var bot = ModularBot(
tracker: vb.initTracker(12), # 0: HeadOn, 1: Linear, 2: Tsetlin, 3: Circular, 4: GuessFactor, 5: Pattern, 6: AntiSurf, 7: WallBounce, 8: Accel, 9: StopShot, 10: Displace, 11: AvgLead
tracker: vb.initTracker(13), # 0: HeadOn, 1: Linear, 2: Tsetlin, 3: Circular, 4: GuessFactor, 5: Pattern, 6: AntiSurf, 7: WallBounce, 8: Accel, 9: StopShot, 10: Displace, 11: AvgLead, 12: DecayGF
headOn: HeadOnGun(),
linear: LinearGun(),
circular: CircularGun(),
@@ -254,6 +262,7 @@ when isMainModule:
stopShot: initStopShotGun(),
displace: initDisplacementGun(),
avgLead: initAveragedLeadGun(),
decayGF: initDecayGFGun(),
radar: RadarLockModule(),
mover: initPhantomMeteor(),
currentGun: -1,