j134 fire fix: share ONE fire_tracker across tfil/ring/strafe/learned/surf (TR_FIRE_FIX, default on); env-gated TR_FIRE_DIAG alignment trace

This commit is contained in:
2026-09-26 12:40:19 +02:00
parent bd57db6d63
commit 6ad5d99922
11 changed files with 435 additions and 214 deletions
+24 -7
View File
@@ -125,6 +125,10 @@ let VBulletAdmitOnly* =
## tfil_ring — the new RANGE-WEIGHTED mover (movements/the_floor_is_lava_ring).
## UNPROVEN: it must never become the default silently.
let MovementName* = getEnv("TR_MOVEMENT", "strafe").strip().toLowerAscii()
## TEMPORARY j134 diagnostic (TASK B): when `TR_FIRE_DIAG` is set, print the tick
## of every enemy-hit / our-hit EVENT so it can be checked against the energy
## reading tick logged by the mover. OFF by default; observability only.
let FireDiag* = existsEnv("TR_FIRE_DIAG")
## Per-process output paths so concurrent A/B runs do not clobber each other.
let GunStatsPath = getEnv("GUN_STATS_PATH", "/tmp/gun_stats.jsonl")
let ShotLogPath = getEnv("GUN_SHOTLOG_PATH", "/tmp/shot_log.jsonl")
@@ -599,10 +603,17 @@ method onBulletFired*(bot: ModularBot, e: BulletFiredEvent) =
method onBulletHit*(bot: ModularBot, e: BulletHitBotEvent) =
inc bot.realHits
# j133 fire-detection fix: our damage to the enemy inflates the enemy's
# energy drop this tick (it can push the enemy's own fire past the 3.0 power
# cap and get it rejected). Tell the strafe detector, which undoes it.
# j134 fire-detection fix (shared by EVERY mover): our damage to the enemy
# inflates the enemy's energy drop this tick (it can push the enemy's own
# fire past the 3.0 power cap and get it rejected). Each mover's detector
# undoes it.
bot.mover.noteDamageDealt(e.damage)
bot.ringMover.noteDamageDealt(e.damage)
bot.strafeMover.noteDamageDealt(e.damage)
bot.surfMover.noteDamageDealt(e.damage)
bot.learnedMover.noteDamageDealt(e.damage)
if FireDiag:
echo "[firediag] EV dmg tick=", bot.tick, " damage=", e.damage
# Capture the rack BEFORE resolveOwnBullet drops the bullet's mode slot.
let hitMode = bot.bulletMode.getOrDefault(e.bullet.bulletId, vb.rm1v1)
# onBulletHit only fires for our own bullets (victimId != myId); see json_parse.nim.
@@ -652,11 +663,17 @@ method onBulletHitBullet*(bot: ModularBot, e: BulletHitBulletEvent) =
e.hitBullet.ownerId, bot.tick, false)
method onHitByBullet*(bot: ModularBot, e: HitByBulletEvent) =
# j133 fire-detection fix: server rules.kt gives the SHOOTER a `3*power`
# energy bonus when its bullet hits us, which masks the cost of a fire in the
# same tick. Forward the enemy bullet's power so the strafe detector adds it
# back before classifying the energy delta.
# j134 fire-detection fix (shared by EVERY mover): server rules.kt gives the
# SHOOTER a `3*power` energy bonus when its bullet hits us, which masks the
# cost of a fire in the same tick. Forward the enemy bullet's power to every
# detector, which adds it back before classifying the energy delta.
bot.mover.noteEnemyBulletHit(e.bullet.power)
bot.ringMover.noteEnemyBulletHit(e.bullet.power)
bot.strafeMover.noteEnemyBulletHit(e.bullet.power)
bot.surfMover.noteEnemyBulletHit(e.bullet.power)
bot.learnedMover.noteEnemyBulletHit(e.bullet.power)
if FireDiag:
echo "[firediag] EV hit tick=", bot.tick, " power=", e.bullet.power
# Feeds the ram bullet-rain abort window. Accumulate REAL ENERGY (the server's
# 4p/6p-2 damage), not raw firepower, so `damageRatePerTurn` is a real
# energy/turn rate (see movements/ram_decision.bulletDamage).