Commit Graph
8 Commits
Author SHA1 Message Date
SirStone 1c7083ab75 elm_bench: online-learning battle runner and analysis 2026-10-06 19:37:38 +02:00
SirStone 9f09204c40 elm_bench: relabel to true-impact movement correction
Add extract_predict.py, which builds the movement-prediction corpus: for each
sampled tick with the shooter fixed to DevControlBot (power 2), the label is
wrap(trueImpactBearing - geometricInterceptBearing), solved against the
observer's true trajectory. Unlike the old opponent-aim-error label this is
centred near zero (mean -0.33 deg, sd 18.3 deg).

Add train_predict.nim: round-group 5-fold evaluation, baselines (plain
intercept / constant), small H x lambda sweep, prediction-mean centring check,
and a |correction|>tau gate calibrated on held-out folds, then export.

Delete the old train_elm_gun.nim (it wrote the live weights from the old label)
and mark extract_realistic.py deprecated.
2026-10-06 09:00:39 +02:00
SirStone 9f37db7523 Add geometric gate for ELM gun
Measure the ELM gun against the plain geometric gun on the three classic
geometric-movement bots (Target, Walls, SpinBot), 20 rounds each, RawRecord
observer ground truth. Verdict: ELM passes only Target (105.5 vs 104.5
dmg/round, within noise); fails Walls (13.5 vs 76.0) and SpinBot (11.0 vs
43.0). score_battles.py extended with damage/round, round wins and the
aim-error-at-fire distribution (vs the true geometric intercept).

Also confirms the corpus and live feature builder both use bulletSpeed =
power*10, so there is no train/inference feature mismatch.
2026-10-06 08:37:17 +02:00
SirStone dacb650692 DevControlBot: an ELM gun, its geometric baseline, and an honest null result
Firing wired in behind a compile-time A/B switch (-d:baselineGun): both guns go
through the same predictAim() call and differ only by the learned correction, so
the measured difference is attributable. radar.nim now keeps the two most recent
scans (velocity, scan age, own displacement).

Measured over 20 recorded rounds each vs DrussGT, CassiusClay, Komarious and
Phoenix: the ELM gun LOSES to the geometric baseline on three of four opponents
(Phoenix 51.0% vs 99.5% hit rate). README has the table, the diagnosis and the
two in-game-only bugs measuring exposed (degrees/radians, and features whose
in-game range lies outside the corpus).
2026-10-05 23:48:58 +02:00
SirStone 818bad50fd Train the aim-error ELM on the pooled 9-opponent corpus and export it
train_elm_gun.nim trains H=128, lambda=1e-2, decay=1.0 over every opponent in
tools/elm_bench/gen and writes modules/ELM/elm_gun_weights.txt (trainRmse 0.431
vs a constant baseline 0.933). Pooled is the point: the gun meets opponents it
was not fitted on.
2026-10-05 23:48:58 +02:00
SirStone 16c71c527a tools/elm_bench: ring label experiment — the ring label is NOT learnable
Gate question: can a ring-based label (a 2-D offset from the belief centre to
where a ray ring touches the enemy) be predicted from our own belief state?
extract_ring.py + bench_ring.nim answer it by MERGING the ring label into
samples_realistic.ndjson, so the ring label and the incumbent 1-D aim-error
label are scored on the SAME rows, the SAME features and the SAME round-group
folds. 8119 of 8676 DrussGT shot rows get a ring label.

Verdict: worse, not richer.

  * The spike's headline is an artifact. The belief is already accurate to
    under 3 px, so a belief-anchored ring touches the enemy on its FIRST ray
    step: ringK = 1.0000 for all 172723 extracted events. The "100% at power
    <= 1.5, 0.2% at power 3.0" pattern is just whether 1 * bulletSpeed fits
    inside the +-18 px belief-error ball. The literal ring label is the 1-tick
    belief extrapolation error, clipped to BotRadius.
  * Same-tick it scores better than the 1-D label (ELM/const 0.2628 vs 0.3629)
    but a single feature, beliefTgtLatVel, already gets -71.8 of the -73.7
    points: the model is re-deriving beliefTgtLatVel * age / beliefDist, i.e.
    its own inputs.
  * Under --prev it collapses to ratio 0.9819 (-1.8%). It depends MORE on the
    same-tick assumption than the 1-D label (-63.7% -> -1.0%), not less.
  * Repaired (--kintercept: k = round(believed range / bullet speed), mean k 42,
    no clipping, 60 px spread) the label is well posed and completely
    unpredictable: best feature +0.5%, best ELM -0.4%, best |corr| 0.09.

So: the belief-extrapolation error at intercept time is not a function of what
we believed, it is the opponent's unmodelled acceleration. Do not ship a ring
label. common_libs/guns/waveelm.nim is the right shape for the same idea and
is a different thing: it fires the ring from the SHOOTER, so the ring measures
an interception radius and bearing and the ELM learns a bias correction to it.
2026-10-05 22:59:41 +02:00
SirStone 8e6af386fc tools/elm_bench/README: activation sweep (tanh / relu / step)
Full 60-config grid per activation on the same features, folds and seed, so
the three runs are directly comparable (act_sweep.log):

  tanh (default)  0.4218 mean per-fold RMSE   (constant 1.1406)
  relu            0.4338  (+2.8%)
  step            0.7476  (+77.3%)

The activation only matters where there is nonlinear structure to expose: on
base 6 and on scan-age alone all three agree to 0.0002 and are all worthless.
tanh stays the default because it is never worse, and because every other
number in this README was produced with it.

Also records why there is no RBF/gaussian option: g(b*||x - a||) reads the
distance to a centre in input space, so it needs centre + width parameters,
its own init and its own Thm 2.2 validation - a different node architecture,
not a different nonlinearity. It would buy nothing here anyway: the signal is
one linear term in beliefPredErr.
2026-10-05 22:59:10 +02:00
SirStone 6d0dd987ca tools/elm_bench: aim-error ELM benchmark suite + findings
Extractors, benchmarks and analysis for "can we predict an opponent's aim
error from our own belief state?". All labels come from BulletFiredEvents;
all features come only from the shooter's own state and its ScannedBotEvent
history (the target's true state is used for the label and never for a
feature, verified by a ground-truth-poisoning re-extraction).

  extract.py / extract_realistic.py   label + oracle features / realistic ones
  gen_analysis.py, analyse_realistic.py, audit_independent.py
  bench.nim, bench_realistic.nim, cross_opponent.nim, online.nim
  gen/*.ndjson                          the per-opponent sample tables
  README.md                             the write-up, ~1200 lines

Headline: DrussGT applies about 13% of the correct lead, and that 13% is
computable from one feature (beliefPredErr) as label ~ 0.8663*predErr +
0.0418. ELM ALL-21 pools to RMSE 0.4220 against a constant 1.1463 (-63%).
The network is not the finding; the single linear term is. Cross-opponent,
--prev leakage audit and an independent re-derivation are in the README.

The top-level samples_realistic*.ndjson are byte-identical to gen/DrussGT* and
are gitignored; gen/ is the authoritative copy.
2026-10-05 22:42:39 +02:00