diff --git a/.claude/agents/cleaner-fix.md b/.claude/agents/cleaner-fix.md new file mode 100644 index 000000000..16ca758ad --- /dev/null +++ b/.claude/agents/cleaner-fix.md @@ -0,0 +1,34 @@ +--- +name: cleaner-fix +description: Applies the free (libre) findings of a `cleaner` report that the developer selected, in an isolated worktree. Launch ONLY after the developer chose findings from a cleaner report, always with isolation worktree. Never invoke proactively, never suggest it. +tools: Read, Grep, Glob, Bash, Edit, Write +isolation: worktree +--- + +# Cleaner fix — apply selected free findings + +## Input + +The prompt carries the selected findings verbatim (table rows from `cleaner`: file:line, rule, +finding, proposed fix, class). Only rows of class **libre** are accepted. + +## Rules + +- You run in an isolated git worktree. Never touch the main checkout, never push, never merge. +- Apply exactly the listed fixes. Nothing adjacent: no extra cleanup, no reformulation of + untouched code, no new feature. +- Code rules of `CLAUDE.md` apply to what you write (one-line comments at most, naming, no + signature in commits). +- Stop on a row that turns out to need more than its stated fix, to touch a shared surface + (`docs/design_doctrine.md` vocabulary), or to change behaviour: skip it, report it as + « reclassé gate Gx » with the reason. Never resolve a gate yourself. +- Verification: `.venv/bin/pre-commit run --files ` for formatting; if C++ + changed, build and run the tests (`ctest`) of the touched modules (skill `build` / + `final-check` procedures). A failing check is reported as such, with its output. +- Never commit: leave the changes uncommitted in the worktree; the main session asks the developer. + +## Output (French, to the main session) + +Branch name and worktree path; per finding `#`: appliqué / sauté (raison) / reclassé gate Gx; +verification result (passed / failed with output); per coherent change, a proposed Conventional +Commits message (`type(scope): subject`, English, imperative, no signature). diff --git a/.claude/agents/cleaner.md b/.claude/agents/cleaner.md new file mode 100644 index 000000000..03c10b17a --- /dev/null +++ b/.claude/agents/cleaner.md @@ -0,0 +1,62 @@ +--- +name: cleaner +description: Read-only audit of a given scope of ArenAI files (code, build scripts, public docs) against the project rules; returns the list of verified violations, each tagged free or gated. Invoke ONLY when the developer explicitly asks for it (« nettoyeur », « nettoie X », « passe le nettoyeur sur X »). Never invoke proactively, never suggest it. +tools: Read, Grep, Glob, Bash +--- + +# Cleaner — audit a scope against the project rules + +You audit; you never edit, build, commit or launch anything. Your report goes to the main +session, which relays it to the developer. + +## Input + +- **Scope**: given in the prompt — paths, globs, module names (`arenai_agent`…), or a git range + (`..`, files changed since ``). Resolve it to a file list first; report that list's + size. No scope in the prompt ⟹ return « scope manquant » and stop. +- **Out of scope, always** (harness, owned by `kaizen` and `harness-improvement`): `CLAUDE.md`, `.claude/**`, memory, + every `docs/*.md` whose header says `Audience: Claude`. Also `outputs/`, `build*/`, + `cmake-build-*/`, `_deps/`, generated files. + +## Rule sources (read before auditing) + +`CLAUDE.md` (sections Design, Code rules, Architecture, Build/test/run) and +`docs/design_doctrine.md`. Rules to check, cite each by its id: + +| id | rule | source | +|---|---|---| +| I1–I4 | tell don't ask, constructor injection, no usage leak, minimal signatures | doctrine | +| FROZEN | no field added to `TorchAction`/`TorchState`/`TorchStep`; no disable option, « 0 = off », fallback for old configs/checkpoints | doctrine | +| DEP | dependency order `utils, controller → view → model → core → agent → desktop`; RmlUi types outside `arenai_desktop/src/gui/`; training-only signal in `arenai_model` | CLAUDE.md, doctrine | +| JUDGE | single responsibility, cohesion, composition over inheritance, `const`/no output parameter, pure computations, explicit ownership, leanest variant, sibling symmetry | doctrine | +| COMMENT | comment > 1 line, paraphrase, justification, comment made false by the code | CLAUDE.md | +| NAME | `PascalCase` classes, `snake_case` functions/variables, `SCREAMING_CASE` constants, `arenai::` namespaces, `ARENAI__H` guards, "algorithm" instead of "agent" | CLAUDE.md | +| METRIC | diagnostic metric outside `get_csv_only_metrics` | CLAUDE.md | +| DOCS | `docs/` not in English (the developer's verbatim excepted); `ARCHITECTURE.md`, `BUILD.md`, `USAGE.md` out of sync with the code (module, public header, executable, CLI option or default, CMake option, flow); `CHANGELOG.md` with an Unreleased section | CLAUDE.md | +| DEAD | dead code, unused include, duplicated logic across siblings | doctrine (leanest, symmetry) | + +Formatting (clang-format) is not a finding: the hook owns it. + +## Procedure + +1. Resolve the scope to files. +2. Per file, read it whole; for I1/I3/DEAD/symmetry, `grep` the call sites and siblings before + concluding. A finding without the evidence that proves it (call site, sibling, doc line vs + code line) is dropped. No speculation, no style taste beyond the table. +3. Per finding, classify the fix: + - **libre** — stays inside one class's private part or one `.cpp`/doc, changes neither a + contract nor an intended behaviour (comment, naming of a local, dead include, doc sync, + private refactor); + - **gate Gx** — the fix touches a shared surface (G1), a feature/option/default (G2), a + formulation (G3), or you doubt the right design (G6). Name the gate. +4. Sort: gated by severity first (I1–I4, FROZEN, DEP), then free. + +## Output (French, to the main session) + +First line: `N constats (L libres, G gated) sur F fichiers.` Then one table: + +| # | fichier:ligne | règle | constat | correction proposée | classe | +|---|---|---|---|---|---| + +`constat`: one line, the fact with its evidence (« `get_x()` puis calcul dans `foo.cpp:42` »). +`correction proposée`: one line, the concrete change. Nothing else: no summary, no advice. diff --git a/.claude/knowledge/INDEX.md b/.claude/knowledge/INDEX.md new file mode 100644 index 000000000..0770a091d --- /dev/null +++ b/.claude/knowledge/INDEX.md @@ -0,0 +1,222 @@ +# Knowledge index + +One line per run note of this directory. Game verdicts: `game_labels.md`. A note is a dated +fact: reward, economy, observation and defaults are read in the code at the relevant commit, and +`docs/decisions.md` prevails on what is refused, removed or validated. + +- [SAC train 293 diagnosis](runs/undated/sac-train-293-diagnosis.md) — 97 % of deaths by starvation; reward scale inflated Q ×25 and detuned the α clamp + grad clip; γ 0.99 + scale removed +- [SAC train 309 diagnosis](runs/undated/sac-train-309-diagnosis.md) — hits only in the initial high-entropy phase; α collapsed in 30k steps; buffer = 10 episodes; spray+starvation = positive local optimum +- [PPO train 326 diagnosis](runs/undated/ppo-train-326-diagnosis.md) — vanilla Beta: no inference shell; Hc≈0.65 = near-uniform → in-game mode/argmax ≠ sampled policy; read Hc/Hd to predict game behaviour; "hidden_sizes" landmine fixed 2026-09-17 (native JSON config, required fields) +- [PPO train 337 diagnosis](runs/undated/ppo-train-337-diagnosis.md) — skip+large CNN: clip 0.33 / KL > target / 25-45 % of epochs cut, hit declines after 700k; save_2/3 best +- [PPO train 339 diagnosis](runs/undated/ppo-train-339-diagnosis.md) — 337 + epochs 2: KL fixed, clip 0.15-0.2, curriculum stuck at D=700, hit ~0.08, ev unstable, transient crash at 4.3M +- [PPO train 344 diagnosis](runs/undated/ppo-train-344-diagnosis.md) — liquid, fixed entropy 0.001: peak 0.3-0.7M (save_3-6) then regression, D 550→350, Hc → −1.9; follow-up: state-independent σ + factors 0.01 (liquid only) +- [PPO train 345 diagnosis](runs/undated/ppo-train-345-diagnosis.md) — liquid state-independent σ + entropy 0.01: curriculum 250→900 without regression (kill ~4.4), D=950 at 25M, hit flat 0.075 since 1M; aim σ ~0.73 (≈4.4°/frame) ≫ target; 4x2 flatten CNN too coarse to aim +- [PPO train 353 (ElMatador)](runs/undated/ppo-train-353-diagnosis.md) — 2026-08-19 shell-damage fix: death needs 5 hits on one part; discrete head inert; σ↔skip loop; best phases at σ≈0.65; 349/350 comparison void +- [PPO train 364 diagnosis](runs/undated/ppo-train-364-diagnosis.md) — impala: ev 0.7 (critic ≫ vanilla) but Hc → −0.25 from 150k without hit gain, curriculum frozen D=250, 2.2× slower; minibatch 128 suspect +- [PPO train 368 diagnosis](runs/undated/ppo-train-368-diagnosis.md) — impala rollout 30 (480 rows): skip 0.7, kl ≫ target, ev = 0.000 (constant critic), Hc −1, Hd 0.12, hit 0.02 → 0.007 +- [PPO train 369 diagnosis](runs/undated/ppo-train-369-diagnosis.md) — rollout 300 + entropy 0.01: frozen policy (kl 3e-4), ev ≤ 0; only 364 (true minibatches) has a learning critic (ev 0.69) → full-batch = too few steps +- [PPO train 371 diagnosis](runs/undated/ppo-train-371-diagnosis.md) — 370/371: critic OK (ev 0.8); actor burns its KL budget on noise, σ frozen at init (entropy 0.01), Hd = ln2, lives = out_of_shells suicide at 23.5 s, hit ≈ random +- [PPO train 372 diagnosis](runs/undated/ppo-train-372-diagnosis.md) — entropy c 0.001/target_kl 0.02: clip 0.25, σ drops without hit gain, random fire, shell-dump suicide unchanged +- [PPO train 373 diagnosis](runs/undated/ppo-train-373-diagnosis.md) — A3+B2: r_aim ×2 but miss 30 m while σ collapses (3rd time impala); aim signal ≈ 0.1 σ of advantage, 10× under the random ±0.3 +- [PPO train 378 diagnosis](runs/undated/ppo-train-378-diagnosis.md) — shell crossing the terrain, 20 s flight, ~85 % of decisions with empty reserve, P(fire) → 0.98, hit = random; corrects the reading of s in 371 +- [PPO train 382 diagnosis](runs/undated/ppo-train-382-diagnosis.md) — curriculum rises 250→500 on the random floor (threshold 0.06 < random hit ~0.05 at D=250); Bernoulli bias unchanged, state logits saturated (Hd 0.15); σ frozen 0.5; 0 kill in game; **follow-up: σ₀ 0.05 + entropy c 0.001 (3 agents), out_of_shells -0.1** +- [PPO train 383 diagnosis](runs/undated/ppo-train-383-diagnosis.md) — σ₀ 0.05: PPO makes σ state-dependent (σ head weights ×60, bias unchanged), σ 0.05→0.24→0.02, clip 0.35/skip 0.7, hit 0.065→0.025 below the random floor; lr/KL calibrated for σ 0.5 +- [PPO train 384 diagnosis](runs/undated/ppo-train-384-diagnosis.md) — free σ + lr 1e-4: σ holds at 0.05, skip 0; but miss ∝ D (23 m at 200k, marker missed), hit 0.06, μ uniform on the 4 axes → exploration noise was not the lock +- [PPO train 385 diagnosis](runs/undated/ppo-train-385-diagnosis.md) — dense aim reward re-enabled (a185f109): r_aim flat at the random baseline 0.005/step, miss/hit identical to 384; 0.1/shell oracle too weak vs death/received; next test = dominant oracle or perception probe +- [PPO train 388-390, Sep 2026 runs (ElMatador)](runs/undated/ppo-train-390-diagnosis.md) — same-numbered Sep runs: linear spawn curriculum unlearns; aim baseline 0.5 = inert tax, cancelled; adaptive SpawnCurriculum 2026-09-05 +- [PPO train 388 diagnosis](runs/undated/ppo-train-388-diagnosis.md) — γ 0.99/λ 0.95/σ₀ 0.3: hit 0.10 at D=400, D→550, ev 0.57; kill flat = curriculum + kill ∝ hit³ (5 HP per part); periodic fire/hit dips, skip 0.33 +- [PPO train 389 diagnosis](runs/undated/ppo-train-389-diagnosis.md) — 388 + recharge +10: kill 1.5-2.1 at equal D, shots/life ~14, hit held, miss unchanged (volume, not aim); re-read after 237k +- [PPO train 390 diagnosis](runs/undated/ppo-train-390-diagnosis.md) — liquid p(fire) 0.5: 10 shells in ~3 s, hit flat 0.065; reco --initial_fire_proba 0.1 (floor 0.05, 30 s starvation); Hd dominated by zoom +- [PPG train 392 diagnosis](runs/undated/ppg-train-392-diagnosis.md) — 1st long run with fire cost: fire 1.0 → 0 between 120k and 160k, silent arena, starvation for all, D 350→250; fire economy negative at the random floor, not a PPG problem (in phases with no visible effect) +- [PPG train 395 diagnosis](runs/undated/ppg-train-395-diagnosis.md) — hit 0.077 → 0.03 locked on D 250→300 while r rises; tipping-point economy (pair exchange ≤ 0), Cauchy and PPG ruled out; **2026-11-02: hit +0.3 / received -0.2** +- [PPO liquid train 407 (ElMatador)](runs/undated/ppo-liquid-train-407-diagnosis.md) — 7-conv 128ch CNN: accel unlearned after entropy collapse ~2.5M; save_30 = immobile camper; CSV blind to it +- [SAC train 411 diagnosis](runs/undated/sac-train-411-diagnosis.md) — 33k steps: Q = pure entropy (≈12, follows α), actor at max entropy (Hc 2.73, σ≈0.9), aim at random floor, fire 0.6→0.3/s because empty reserve = cut without bootstrap; options to validate: α₀ 0.01, truncation bootstrap, UTD +- [SAC train 412 diagnosis](runs/undated/sac-train-412-diagnosis.md) — α₀ 0.01: Q ≈ 0.9 (vs 12), fire holds, Hc leaves the max, hit 0.046 below the floor; stopped at 45k; 413 (batch 8192, small network) = 10× slower, same number of updates → lever = gradient_steps +- [PPO liquid train 414/415 (ElMatador)](runs/undated/ppo-liquid-train-414-diagnosis.md) — first curriculum finish D=1000 (hit 0.081/kill 10.1); plateau from 2.8M; Hc→~0 in <1M whatever σ_init; kl 16× under target +- [SAC train 414 diagnosis](runs/2026-11-09-21-19-59_the-machine_train_414_sac/run.md) — 1st SAC above the floor: nothing learns while α > ~5e-4 (45k steps of α decay), hit peak 0.117 at D=300 (save_3, 81k) then regression 0.067 at D=350, Q overestimated +0.4, q ×6 +- [SAC train 415 diagnosis](runs/2026-11-10-08-30-12_the-machine_train_415_sac/run.md) — α₀ 5e-4: dead phase removed, hit 0.12 at D=350 / 0.11 at D=400; probe: unconditional fire, aim uncorrelated with error, hit = fortuitous alignment; Q drifts to −0.34 vs V ≈ +0.4; probe supports SAC (uncommitted) +- [SAC train 416 diagnosis](runs/2026-11-10-15-31-00_the-machine_train_416_sac/run.md) — 415 + σ target 0.3 + 70 % stratified replay + σ ceiling 0.7: regression from D=350 (hit 0.103, kill 8 vs 12); probe: canon σ at ceiling 0.7 (94 %), angle at fire 19.6° vs 11.8°, p(fire) 0.88 and dry 84 % of the time; the post-tanh entropy target is bypassed by saturation (μ in 415, σ in 416) +- [PPO liquid train 416 (ElMatador)](runs/undated/ppo-liquid-train-416-diagnosis.md) — skip+CNN6+LTC512+epochs4 at once: kl 0.06, skip 27-43%, under 414 at every D; epochs 4 = cause (see 417) +- [SAC train 417 diagnosis](runs/2026-11-10-23-58-03_the-machine_train_417_sac/run.md) — 415 + stratified + σ ceiling: curriculum 2× slower, hit 0.10 → 0.072 at D=350; attribution impossible (no seed, 416 fast despite stratification); only robust fact = corr(μ, error) ≈ 0; **∂Q/∂a_canon random (50 % right direction) even armed near the target → critic blind to aim** +- [PPO liquid train 417 (ElMatador)](runs/undated/ppo-liquid-train-417-diagnosis.md) — 416 with epochs 2: best early start (D=250 kill 9.82/hit 0.089), kl 0.007-0.015, skip 0 +- [PPO liquid train 418 (ElMatador)](runs/undated/ppo-liquid-train-418-diagnosis.md) — duplicate of 417: peak then plateau from 1.1M; actor diffuses (random-walk ratio 0.26), CNN learned nothing; hit ceiling ~8% +- [PPO liquid train 419 (ElMatador)](runs/undated/ppo-liquid-train-419-diagnosis.md) — critic lr 1e-4: lead held to D=400 (0.089/9.68) then same ceiling; actor unchanged ⟹ "critic makes actor diffuse" refuted +- [SAC train 419 diagnosis](runs/2026-11-11-11-08-12_the-machine_train_419_sac/run.md) — 417 + n_step 10: at 17k Hc at target from 12k, q loss ×8, Q unbiased, hit at floor; **probe save_1: ∂Q/∂a still without direction (0.51 armed, = 417), amplitude ×3; Q1/Q2 sign disagreement (0.5) → ∂Q/∂a = fitting noise; SAC vision features (actor and critics) do not encode the target bearing (R² ≤ 0.16, not improving)** +- [SAC train 420 diagnosis](runs/2026-11-11-14-21-42_the-machine_train_420_sac/run.md) — folder train_20_sac; shared encoder: ∂Q/∂a_canon still without direction at save_1, selective trigger (ratio 2.2, no 419 reference), Hc < target by direction-μ saturation +- [PPG train 421 diagnosis](runs/2026-11-11-22-10-42_the-machine_train_421_ppg/run.md) — absolute command (cos/sin/pitch) + MIN_ALPHA 1e-4: D=400 at 145k then stuck, hit/fire 0.086 → 0.077, kill ×2 by cadence alone, Hc → −1 without gain +- [PPG train 423 diagnosis](runs/2026-11-12-23-46-38_the-machine_train_423_ppg/run.md) — gun laying + aim advantage φ + per-group KL stop: 1st run at D=1000 (429k), hit 0.13 → 0.20; probe save_21: ratio 4.9/7.5, hit/shell 0.2, dump removed, but corr(μ canon, error) ≈ 0 +- [PPG train 428 diagnosis](runs/2026-11-15-00-01-45_the-machine_train_428_ppg/run.md) — discrete target 0.01 + γ 0.998 (confounded): α_fire at floor, fire 0.9→0.3, hit 0.26, kill 22→15; probe save_27: selectivity ×2-3 by off-axis extinction, p_al ÷2, deterministic mute; save_49: h<5° 0.43-0.47 (record), zoom abandoned, chassis turns in circles +- [PPO liquid train 429 (ElMatador)](runs/undated/ppo-liquid-train-429-diagnosis.md) — 10 Hz: ≡ 428 at equal D, peak 4-5M (kill 3.75, D 700) then Hc 0.28→0.05; fire ≈1.1/s ammo-capped; then regen removed, reserve 20 +- [PPO liquid train 430 (ElMatador)](runs/undated/ppo-liquid-train-430-diagnosis.md) — no regen, reserve 20: ~18 shells fired in ~7 s then idle; hit 5-6% unchanged, kills ÷2-3 vs 429 +- [PPO liquid train 432 diagnosis](runs/2026-11-22-13-31-42_the-machine_train_432_ppo_liquid/run.md) — single optimisation group: bearing learned before 27k (corr −0.3 under 45°, 5 % of error closed/decision) then flat gain; measure per error slice, right direction = negative corr, probe save_0 as reference +- [PPO liquid train 433 diagnosis](runs/2026-11-23-22-49-10_the-machine_train_433_ppo_liquid/run.md) — 4 blocks + spatial softmax: position present at the policy input (0.87/1.51/4.18°, ≥ 552) but aim unchanged at save_14 (turret<5° 0.13-0.19, null corr > 200 m, ρ ≈ 0); compare to 552 at D 1000 +- [PPO liquid train 433, Oct 2026 run (ElMatador)](runs/undated/ppo-liquid-train-433-diagnosis.md) — no continuous entropy + epochs 6: D stuck 250, σ 0.5→0.1, skip 68%, kl>target; confounded, 435 is the real A/B +- [PPO liquid train 437 (ElMatador)](runs/undated/ppo-liquid-train-437-diagnosis.md) — empty reserve = suicide −1: still dumps 20 shells at ~0.82/s, dies ~24 s; ≡ 435; penalty alone does not ration +- [PPO liquid train 439 (ElMatador)](runs/undated/ppo-liquid-train-439-diagnosis.md) — 5 changes at once, D stuck 250 over 1.75M; peak 375-525k then collapse; Hc→−0.35; nothing attributable +- [PPO liquid train 441 (ElMatador)](runs/undated/ppo-liquid-train-441-diagnosis.md) — peak 1.3-1.5M, D 450 at 2.1M then curriculum back to 300; KL regime (kl 0.07, skip 41%); a D drop = regression +- [PPO liquid IMPALA train 449 (ElMatador)](runs/undated/ppo-liquid-train-449-diagnosis.md) — target_kl 0.02 + epochs 8: skip 30→96%, σ 0.5→0.08, ~3 actor steps/rollout; hit 1-2%, D stuck 250 +- [PPO liquid IMPALA train 450 (ElMatador)](runs/undated/ppo-liquid-train-450-diagnosis.md) — audit of liquid_impala path: no bug; no run past 470k since 443; entropy bonus 0.01 reverses σ dynamics +- [PPO liquid IMPALA train 451 (ElMatador)](runs/undated/ppo-liquid-train-451-diagnosis.md) — empty reserve = truncation (r −0.003→0) but 449 hyperparams ⟹ same KL regime (skip 0.65, Hc −0.07 in 72k) +- [PPO liquid train 452 (ElMatador)](runs/undated/ppo-liquid-train-452-diagnosis.md) — 32 tanks = ×2 per env step (31-44k steps/h), ~1.4M tank-steps/h unchanged +- [PPO liquid train 465 (ElMatador)](runs/2026-11-01-20-59-17_ElMatador_train_465_ppo_liquid/run.md) — fire cost 0.03 + p_init 0.1: ≡464 to D=550 then fire 1.5→0.03/s, kill 0; gain/shot 3× cost yet trigger killed +- [PPO liquid train 467 (ElMatador)](runs/2026-11-02-10-26-09_ElMatador_train_467_ppo_liquid/run.md) — probe save_3: policy reads bearing but trigger flat (0.74-0.81), turret 20% speed; lock = reward shape ⟹ tolerance 2.5 m+3° (468) +- [PPO liquid train 468 (ElMatador)](runs/2026-11-02-16-02-48_ElMatador_train_468_ppo_liquid/run.md) — tol 2.5 m+3°, fire cost removed: miss 21 m ⟹ exp(-4) aim extinguished; hit 5.8%, kill 0.2, D stuck 300 +- [PPO liquid train 470 (ElMatador)](runs/2026-11-02-22-09-02_ElMatador_train_470_ppo_liquid/run.md) — D 700 at 500k, episode 13-16 s; save_6 trigger flat 0.70-0.74, det dump 6/s; P(hit) 50% aligned+near, 1.2% of shots +- [PPO liquid train 471 (ElMatador)](runs/2026-11-03-09-52-40_ElMatador_train_471_ppo_liquid/run.md) — shot_cost 0.03 at impact: fire 0.57→0.02/s in 100k, kill 0; turret unlearned; uniform cost fails +- [PPO liquid train 472 (ElMatador)](runs/2026-11-03-14-12-01_ElMatador_train_472_ppo_liquid/run.md) — aim-potential shaping tol 2.5 m+3°: trigger extinguished, turret worse than untrained; |F|>0.01 on 5% of decisions ⟹ tol 20° +- [PPO liquid train 473 (ElMatador)](runs/2026-11-03-17-36-54_ElMatador_train_473_ppo_liquid/run.md) — Φ tol 20°, shot_cost 0: trigger back (p_fire 0.73 flat, dump 5 s), phi flat, turret constant rotation, yaw undecodable +- [PPO liquid train 474 (ElMatador)](runs/2026-11-03-19-32-21_ElMatador_train_474_ppo_liquid/run.md) — reserve 30/+20/max 60: kill 7-9/ep, hit 8%; dump in 11 s then 57% of tank-steps unarmed; dump = optimum +- [PPO liquid train 475 (ElMatador)](runs/2026-11-03-22-48-16_ElMatador_train_475_ppo_liquid/run.md) — ADR 0.07/0.10: hit max 0.0998 all run, D=250 over 957k; dead band ⟹ thresholds 0.05/0.08 +- [PPO liquid train 476 (ElMatador)](runs/2026-11-04-07-08-46_ElMatador_train_476_ppo_liquid/run.md) — ADR 0.05/0.08: D 250→500 in 866k but save_8 p_fire 0.99 saturated, empty 4.6 s; D rises on spam plateau +- [PPO liquid train 477 (ElMatador)](runs/2026-11-04-18-57-21_ElMatador_train_477_ppo_liquid/run.md) — centred shot reward: save_1 trigger mute (p_fire 0.06), turret <5° 11.7% (2.3× init), hit/shell 12%; no selectivity +- [PPO liquid train 478 (ElMatador)](runs/2026-11-04-21-37-34_ElMatador_train_478_ppo_liquid/run.md) — health ratios in proprio: best since 417-419 (hit 10%, kill 2-2.7, D 450 at 900k); trigger = dump (empty 2.3 s); trough 620-670k +- [PPO liquid train 479 (ElMatador)](runs/2026-11-05-12-07-36_ElMatador_train_479_ppo_liquid/run.md) — 478 + empty-reserve death −1: trigger extinguished in 100k (p_fire 0.005), kill 0; code reverted +- [PPO liquid train 480 (ElMatador)](runs/2026-11-05-14-57-45_ElMatador_train_480_ppo_liquid/run.md) — 478 + actor_epochs 2: skip 0, kl 0.005, under 478; save_8 first selectivity (p_fire 0.70 <5° vs 0.17 at 20-45°) +- [PPO liquid train 481 (ElMatador)](runs/2026-11-06-00-59-33_ElMatador_train_481_ppo_liquid/run.md) — regen coded then removed; aim paid at fire on predicted trajectory: trigger extinguished in 50k (self-referential EMA baseline) +- [PPO liquid train 482 (ElMatador)](runs/2026-11-06-09-29-55_ElMatador_train_482_ppo_liquid/run.md) — baseline on mean opportunities: no ratchet, save_1 enrichment 2.07 at near-zero level, p_fire 0.005 at 216k; stopped 223k +- [PPO liquid train 483 (ElMatador)](runs/2026-11-06-13-30-33_ElMatador_train_483_ppo_liquid/run.md) — hit_baseline removed (raw hit): kill 2.5 at 70-90k, fire held, p_fire 0.50 flat = dump +- [PPO liquid train 484 (ElMatador)](runs/2026-11-06-15-30-48_ElMatador_train_484_ppo_liquid/run.md) — hit bar on opportunities: save_1 first selective trigger (0.16 vs 0.072, hit/shell 11.7%) then slow extinction +- [PPO liquid train 485 (ElMatador)](runs/2026-11-06-18-57-27_ElMatador_train_485_ppo_liquid/run.md) — hit paid at fire decision on ray predicate, centred on opportunities; gate save_1 p_fire facing >0.3 +- [PPO liquid train 486 (ElMatador)](runs/2026-11-06-21-22-33_ElMatador_train_486_ppo_liquid/run.md) — reward rework (damage fractions, potential, FIRE_COST 0.03, 180 s episodes): CSV fire blind to dump; no restraint +- [PPO liquid train 487 (ElMatador)](runs/2026-11-06-22-15-24_ElMatador_train_487_ppo_liquid/run.md) — fire cost C(1−φ), C 0.05, p_init 0.05: extinction by save_1; mean shot −0.03 sets level, not cost shape +- [PPO liquid train 488 (ElMatador)](runs/2026-11-06-22-57-32_ElMatador_train_488_ppo_liquid/run.md) — C 0.05, p_init 0.5: kill 4.2, hit 22% at 110k then extinction; equilibrium hit ≈(0.8C−0.006)/0.13 ⟹ C 0.03 +- [PPO liquid train 489 (ElMatador)](runs/2026-11-07-08-01-45_ElMatador_train_489_ppo_liquid/run.md) — C 0.03, p_init 0.5: net/shell ≈0, dump = fixed point (p_fire 0.54 flat, empty 2.8 s); Hd ≈ zoom entropy +- [PPO liquid train 490 (ElMatador)](runs/2026-11-07-10-45-28_ElMatador_train_490_ppo_liquid/run.md) — hit/received ×3 and fire cost C 0.09 to raise SNR; gate failed (p_fire flat 0.41-0.485); fire head gets only 2-3 % of decisions +- [PPO liquid train 491 (ElMatador)](runs/2026-11-07-15-07-21_ElMatador_train_491_ppo_liquid/run.md) — respawn in place at empty reserve (truncated): head learns (ratio 2→12) then extinction at 180 k; level/contrast race +- [PPO liquid train 492 (ElMatador)](runs/2026-11-07-17-52-06_ElMatador_train_492_ppo_liquid/run.md) — fire cost C=0 (contrast only); kill 14 at D 250 (record); aligned/off-axis gap plateaus 0.08-0.09; dump persists +- [PPO liquid train 493 (ElMatador)](runs/2026-11-07-20-11-47_ElMatador_train_493_ppo_liquid/run.md) — 492 + curriculum window 8 / boundary 0.5; D 450 at 267 k; gap frozen 0.15-0.19; respawn value bug found +- [PPO liquid train 494 (ElMatador)](runs/2026-11-08-03-31-45_ElMatador_train_494_ppo_liquid/run.md) — bootstrap cut at truncation: gate passed (reserve 9.3 s, ratio 2.5-3, hit/shell 18 %), D 900 at 566 k, then KL regime skip 54 % +- [PPO liquid train 495 (ElMatador)](runs/2026-11-08-14-35-02_ElMatador_train_495_ppo_liquid/run.md) — 494 + entropy 0.01: KL regime avoided but σ canon 0.4-0.5, dump back, D stuck 550 +- [PPO liquid train 496 (ElMatador)](runs/2026-11-08-22-13-47_ElMatador_train_496_ppo_liquid/run.md) — tanh + per-action auto α (target −1): kill ×3 vs 494, but unbounded log α windup ⟹ σ waves +- [PPO liquid train 497 (ElMatador)](runs/2026-11-09-14-12-03_ElMatador_train_497_ppo_liquid/run.md) — Stooke PID α, target −0.5: α ≡ 0 from step 0, D stuck 250 at 114 k +- [PPO liquid train 498 (ElMatador)](runs/2026-11-09-16-22-47_ElMatador_train_498_ppo_liquid/run.md) — 497 + σ_init 0.15: PID holds Hc −0.44 but turret does not learn (hit 4.5 %, <5° 7 %) +- [PPO liquid train 499 (ElMatador)](runs/2026-11-09-17-48-58_ElMatador_train_499_ppo_liquid/run.md) — log α clamp [1e-3, 0] (`2e594069`): no wave to 443 k, but dump 3 s, hit/shell 7 %, D stuck 500 +- [PPO liquid train 500 (ElMatador)](runs/2026-11-09-23-32-50_ElMatador_train_500_ppo_liquid/run.md) — received ×1 / inflicted ×3: D 1000 at 595 k, save_20 record (ratio 4.7, hit/shell 22 %), then σ bimodal waves +- [PPO liquid train 501 (ElMatador)](runs/2026-11-10-09-34-59_ElMatador_train_501_ppo_liquid/run.md) — LOG_SIGMA_MAX → ln 0.7 (`4d7d558c`): wave removed (ratio 9.2 at 351 k), but μ at bounds by 600 k +- [PPO liquid train 502 (ElMatador)](runs/2026-11-10-17-23-50_ElMatador_train_502_ppo_liquid/run.md) — entropy target 0: D 1000 at 538 k; save_20 record 22 % undone by canon_x drift (|μ| 1.17); ≡ 500 at equal D +- [PPO liquid train 503 (ElMatador)](runs/2026-11-11-02-40-59_ElMatador_train_503_ppo_liquid/run.md) — full batch 9600 + lr ×5 + SoftClamp (confounded): ev≈0 for 360 k, hit 15 % at D 550-600 +- [PPO liquid train 504 (ElMatador)](runs/2026-11-11-10-04-54_ElMatador_train_504_ppo_liquid/run.md) — SoftClamp + critic_epochs 8: D 950 at 429 k, ev 0.5-0.68; canon_x σ to ceiling by save_16, no precision signal +- [PPO liquid train 505 (ElMatador)](runs/2026-11-11-18-52-28_ElMatador_train_505_ppo_liquid/run.md) — absolute turret/canon setpoint, yaw (cos,sin) (3rd absolute attempt): setpoint dispersion 73-80°, aim not better +- [PPO liquid train 506 (ElMatador)](runs/2026-11-11-21-59-20_ElMatador_train_506_ppo_liquid/run.md) — 505 + entropy target [0,0,−1,−1,−1]: yaw setpoint = fixed rear bias, turret<5° flat 16-18 %, slowest D +- [PPO liquid train 507 (ElMatador)](runs/2026-11-12-08-13-03_ElMatador_train_507_ppo_liquid/run.md) — velocity command back, Φ tolerance 5 m + 10°: turret <5° ≡ 504 over 4 saves; inconclusive +- [PPO liquid train 508 (ElMatador)](runs/2026-11-12-15-25-35_ElMatador_train_508_ppo_liquid/run.md) — GunLaying stabiliser + 20 Hz hinges: pitch<2° 24-28 %, kills +20-45 %, yaw gain unchanged; credit horizon is the bottleneck +- [PPO liquid train 509 (ElMatador)](runs/2026-11-12-21-36-21_ElMatador_train_509_ppo_liquid/run.md) — factorised aim credit (aim_gae_lambda 0): h<5° 32 % vs 21 %, hit/shell +23-51 %, skip 40 % (canon 77 % of KL) +- [PPO liquid train 510 (ElMatador)](runs/2026-11-12-23-42-54_ElMatador_train_510_ppo_liquid/run.md) — + per-group KL stop (`7422d098`): best run, D 1000 at 428 k, save_28 hit/shell 21/19.5 %, turret 29/23 % +- [PPO liquid train 511 (ElMatador)](runs/2026-11-13-09-13-54_ElMatador_train_511_ppo_liquid/run.md) — no respawn/truncation at empty reserve: reserve 2.3 s, trigger flat (collective dry equilibrium); CSV s/fire blind +- [PPO liquid train 512 (ElMatador)](runs/2026-11-13-12-10-21_ElMatador_train_512_ppo_liquid/run.md) — 10 s delayed respawn (`68b9697d`): breaks 511 equilibrium but behind 510 at D 1000 (ratio 6.2 vs 13.6); reverted +- [PPO liquid train 513 (ElMatador)](runs/2026-11-13-18-55-51_ElMatador_train_513_ppo_liquid/run.md) — 510 rule + economy 5/30 (`b3092240`): trigger lags to save_6, dump resolved; hit/shell 19/16 vs 28/25 +- [PPO liquid train 514 (ElMatador)](runs/2026-11-14-01-17-39_ElMatador_train_514_ppo_liquid/run.md) — a·|a| + centred potential + 10/3/30 (`d1bb4020`): ≡ 510 save_28 at D 1000, fine pitch 1.0-1.2°, no turret gain +- [PPO liquid train 515 (ElMatador)](runs/2026-11-14-12-01-47_ElMatador_train_515_ppo_liquid/run.md) — 514 + gamma 0.998: save_9 hit/shell 17.3/12.5 %, less dump, selectivity not better; stopped at 380 k +- [PPO liquid train 516 (ElMatador)](runs/2026-11-14-16-16-14_ElMatador_train_516_ppo_liquid/run.md) — 256×512 vision, 5-block CNN tail block, zoom removed from agent; throughput −37 % vs 515; stopped +- [PPO liquid train 517 (ElMatador)](runs/2026-11-14-17-27-09_ElMatador_train_517_ppo_liquid/run.md) — stopped at save_1 (37 k): hit 6.4 % vs 8.2-12.2 in 510-516; regression grows with network size, not isolated +- [PPO liquid train 518 (ElMatador)](runs/2026-11-14-19-45-28_ElMatador_train_518_ppo_liquid/run.md) — resolution alone: 515 CNN on 512×256; 2.4-3× slower (~27 k/h); abandoned at save_0 +- [PPO liquid train 519 (ElMatador)](runs/2026-11-14-20-36-48_ElMatador_train_519_ppo_liquid/run.md) — 128×256 3-block CNN trial; misses 1st curriculum step, hit ≈ 515 −1 pt; abandoned, 515 config restored +- [PPO liquid train 520 (ElMatador)](runs/2026-11-14-23-15-13_ElMatador_train_520_ppo_liquid/run.md) — 515 + discrete target 0.01: α_fire at floor, dump gone, hit/shell 24-28 % at D 1000; 2×2×2 oracle ⟹ aim/trigger local optimum +- [PPO liquid train 521 (ElMatador)](runs/2026-11-15-12-04-11_ElMatador_train_521_ppo_liquid/run.md) — 520 + 2 shells/hit: no dump, hit/shell 21 % ≤ 520; volume drift = gradient ascent (corr hit/r_hit −0.79); stopped 752 k +- [PPO liquid train 522 (ElMatador)](runs/2026-11-15-20-08-38_ElMatador_train_522_ppo_liquid/run.md) — 521 + empty-reserve penalty −D/1000: record precision (hit/shell 35-46 %, disarmed ~1 %); yaw undecodable; oracle ×3.5/×4 +- [PPO liquid train 523 (ElMatador)](runs/2026-11-16-21-41-26_ElMatador_train_523_ppo_liquid/run.md) — flat 7-conv CNN + single advantage; 69 k: kill 15.9 at D 350, single KL stop skips 45 %, yaw sign decodable +- [PPO liquid train 524 (ElMatador)](runs/2026-11-16-22-54-41_ElMatador_train_524_ppo_liquid/run.md) — 523 + target_kl 0.10: kill 8 at D 1000, turret<5° 16 → 8 %; aim loss = single advantage, not CNN or skip +- [PPO liquid train 525 (ElMatador)](runs/2026-11-17-08-35-11_ElMatador_train_525_ppo_liquid/run.md) — pure-event reward (Φ removed): ≡ 524, turret sweeps, dwell 0.2 s vs 1.0 s; audit finds no bug; ρ(A, gesture) ≈ 0.02 +- [PPO liquid train 526 (ElMatador)](runs/2026-11-17-13-42-04_ElMatador_train_526_ppo_liquid/run.md) — 525 + actor batch 2400: kl ÷5, kill +60 % via volume (dump), aim unchanged; hits < 50 m only +- [PPO liquid train 527 (ElMatador)](runs/2026-11-17-16-18-49_ElMatador_train_527_ppo_liquid/run.md) — 525 + kills/tank curriculum only (shells_per_hit stayed 2); seed replica at D 250, stopped ~30 k +- [PPO liquid train 528 (ElMatador)](runs/2026-11-17-16-46-52_ElMatador_train_528_ppo_liquid/run.md) — 5 shells/hit + kills/tank curriculum: trigger open at 50-100 m to s9, closes by s14; D frozen 750 +- [PPO liquid train 529 (ElMatador)](runs/2026-11-17-21-49-27_ElMatador_train_529_ppo_liquid/run.md) — 528 + canon σ ceiling 0.25: sweep gone at s5 then returns via μ (s27 3.3°/dec); σ-high hypothesis refuted +- [PPO liquid train 533 (ElMatador)](runs/2026-11-18-20-19-31_ElMatador_train_533_ppo_liquid/run.md) — coloured AR(1) noise + short value head (confounded): s3 corrective μ 0.63-0.65 vs 0.55, skip 55 %; killed 88 k +- [PPO liquid train 534 (ElMatador)](runs/2026-11-18-21-25-45_ElMatador_train_534_ppo_liquid/run.md) — coloured noise alone ≡ 533 at s3 (short head not the lever); KL regime from coloured noise, skip 0.54 at 67 k +- [PPO liquid train 535 (ElMatador)](runs/2026-11-18-22-29-12_ElMatador_train_535_ppo_liquid/run.md) — 534 + actor lr 5e-5: skip curve shifted ~40 k, not bent; ‖mu.weight‖ growth explains KL +- [PPO liquid train 536 (ElMatador)](runs/2026-11-19-00-35-45_ElMatador_train_536_ppo_liquid/run.md) — spatial softmax + lr 1e-4 + a·|a| removed: skip 0.92-0.97, D stuck 250 +- [PPO liquid train 537 (ElMatador)](runs/2026-11-19-07-31-46_ElMatador_train_537_ppo_liquid/run.md) — 534 + batch 2400 + a·|a| removed: KL regime delayed ~60 k not removed; trigger selective at s3 +- [PPO liquid train 538 (ElMatador)](runs/2026-11-19-09-02-57_ElMatador_train_538_ppo_liquid/run.md) — 537 + white noise: white ≥ coloured (yaw<5° 6.9 vs 5.4-5.8 %, kl ×5 lower, skip 0); coloured noise dropped +- [PPO liquid train 539 (ElMatador)](runs/2026-11-19-16-13-05_ElMatador_train_539_ppo_liquid/run.md) — 538 + current-image fix: dwell doubled (0.62-0.73 s), D 800 at 328 k vs 429 k; holding lost at s12 +- [PPO liquid train 541 (ElMatador)](runs/2026-11-20-00-52-37_ElMatador_train_541_ppo_liquid/run.md) — canon credit on critic head H: calm turret, aim from s9; two trigger collapses at D 800 → 850; H credit ρ ≈ 0 +- [PPO liquid train 542 (ElMatador)](runs/2026-11-20-11-46-27_ElMatador_train_542_ppo_liquid/run.md) — 541 + discrete target 0.05: inert until p_fire < 0.05; slow trigger slide at D 950 +- [PPO liquid train 543 (ElMatador)](runs/2026-11-20-18-54-18_ElMatador_train_543_ppo_liquid/run.md) — 541 + constant empty penalty 0.5: dump not resorbed at D 250-450, trigger closes at s13 (D 700) +- [PPO liquid train 544 (ElMatador)](runs/2026-11-21-02-54-30_ElMatador_train_544_ppo_liquid/run.md) — 543 + Φ₂ instead of H; kill 25.7-27.4 at D 300-400, turret<5° 23 % at s3; killed 109 k, replaced by 545 +- [PPO liquid train 545 (ElMatador)](runs/2026-11-21-03-51-46_ElMatador_train_545_ppo_liquid/run.md) — Φ₂ control on 522 settings: kill 22.7 at D 1000 entry (510 17.9, 522 12.3), no trigger closing to 456 k, s16 hit/shell 33 % +- [PPO liquid train 546 (ElMatador)](runs/2026-11-21-12-57-07_ElMatador_train_546_ppo_liquid/run.md) — 545 + arena-exit death + received-shot direction: stronger D 400-600, same cruise; trigger closes; best save s20 +- [PPO liquid train 547 (ElMatador)](runs/2026-11-21-23-26-19_ElMatador_train_547_ppo_liquid/run.md) — 546 twin with 5 shells/hit: delays trigger closing ~150 k, same end state +- [Train 548 temoin_gisement (ElMatador)](runs/2026-11-22-01-55-58_ElMatador_train_548_temoin_gisement/run.md) — control with nearest-enemy bearing as input: no better than 547 at s3/s7/s11 ⟹ "perception = source" refuted +- [PPO liquid train 549 (ElMatador)](runs/2026-11-22-13-20-40_ElMatador_train_549_ppo_liquid/run.md) — Φ₂ + bootstrapped GAE + entropy target −1; σ canon 0.044 at s3; held D 1000 (kill 25-27) +- [PPO liquid train 550 (ElMatador)](runs/2026-11-22-21-49-23_ElMatador_train_550_ppo_liquid/run.md) — single advantage without Φ, penalty 0.25: KL and dump fixed, trigger closed > 100 m, sweep = search; D 900 blocked +- [PPO liquid train 551 (ElMatador)](runs/2026-11-23-07-11-46_ElMatador_train_551_ppo_liquid/run.md) — 550 twin with direct cell branch (later removed): ≡ 550 at D 900 (kill 17-18, fire 0.39, hit 0.25-0.28) +- [PPO liquid train 552 (ElMatador)](runs/2026-11-23-19-27-46_ElMatador_train_552_ppo_liquid/run.md) — 550 + presence head: map learned, 60-100 m engagement 0.57 vs 0.37, no kill gain; head removed; game reference s41 +- [PPO liquid train 553 (ElMatador)](runs/2026-11-24-20-00-09_ElMatador_train_553_ppo_liquid/run.md) — 552 + spatial aim: training metrics misleading; game-rules s36 dry at 10 s 0.30/0.48 vs 0.06/0.08; the developer: bad; code removed +- [PPO liquid train 554 (ElMatador)](runs/2026-11-25-21-06-10_ElMatador_train_554_ppo_liquid/run.md) — 550 + 360° panorama (max agg.): D 950 at 404 k, s17 ≡ 550 s26 in game, no approach; panorama encoder ≡ untrained +- [PPO liquid train 555 (ElMatador)](runs/2026-11-26-08-31-22_ElMatador_train_555_ppo_liquid/run.md) — 554 with mean aggregation: s17 ≡ 554 s17, 552 s41 level; out-of-field bearing not in trunk +- [PPO liquid train 556 (ElMatador)](runs/2026-11-27-02-00-15_ElMatador_train_556_ppo_liquid/run.md) — panorama encoder supervised by visibility mask: D 1000 at 461 k, training kill 21, but in game s17/s21 below 554/555 s17 (dry at 10 s 0.27/0.48, hit/shell 0.18-0.26, gun low); 553 profile +- [PPO liquid train 557 (ElMatador)](runs/2026-11-27-13-44-18_ElMatador_train_557_ppo_liquid/run.md) — 556 twin with hatched wrecks (P4): s11 vs 556 s11 in game holds its reserve better (time dry 0.23 vs 0.47) but aligns 3× less (0.04 vs 0.14) with the gun low; s14 (developer: gun low, close only): far targets >100 m off-axis 85 %, elevation +4-7° low, elevation oracle +9-31 % hits; time dry 0.51 vs 0.23 at s11; P4 point 648 k pending; s21 probe: trigger open (p_al 0.93 / 0.92), no collapse; game s21 (2026-11-30): not above s14, dries sooner (dry at 30 s 0.57 / 0.70 vs 0.30 / 0.47), gun −21° at side 1000 +- [PPO liquid train 558 (ElMatador)](runs/2026-11-27-22-09-19_ElMatador_train_558_ppo_liquid/run.md) — 557 + supervised aim mask (4-block CNN, spatial softmax): mask AUC 0.98 at 100-200 m (s11, side 1000); aligned share 100-200 m 0.36 vs 557 s14 0.15; CSV hit −0.04 but fire ×2.2, miss −24 m at equal D up to 400 k; then curriculum stalls at D 900 (never 950, back to 800 at 1.31 M), kill 23 → 16, fire → 0.3; game s11/s14/s21: gun level, on-target ×3-5 vs 557, s21 passive (kills side 500 0.19 vs 0.39) = trigger collapse s14→s21 (p_al 0.6→0.18, aim up), located in the liquid cell weights (hybrid swaps), not the aim-mask vision; far-shot (≥ 200 m) fire samples pull it down through the cell (−4 se); range is decoded by the cell (AUC 0.94, aliasing refuted) and 557 shows the same far leak at s14: drive interference through the cell undecided (weak, sign swings); established: throttle collapse (dir_y μ≈0, σ 0.09 → 0.025, entropy below target despite α ×18) — 558 tanks stop driving; replay with drive gradient cut does not reproduce the collapse (undecided) but un-collapses the throttle σ; cuts 10-13: KL starvation refuted, collapse specific to the aim-mask lineage (557 s21 p_al 0.92), no information loss in the cell (alignment AUC 0.93 at s21), lock decays with tank age (untested lead); cuts 14-16: p_al drop = half policy, half situations (shadow checkpoint); gun no longer held on close enemies (0.16 → 0.086, 557 0.12 → 0.20); trunk view input locates the target at R² 0.2-0.7; cause open; cuts 17-19: gun parks beside close enemies (−8° at s21, input reads it), hold breaks at s16 (D 900) before the trigger closes at s17, σ canon ×9; per-step gun credit within noise in both lineages; cut 20 (canon gradient attribution s14-s17 vs 557): which force breaks the hold undecided on the canon's own PG; entropy push on the on-target canon σ 6-7× 557's; drive-PG lead (+4.3 se at s16) not replicated on 48 rollouts (cut 21); at s16 no measured term raises the canon σ but entropy; aim-mask loss on the actor's CNN not yet attributed + +## Comparisons and cross-run studies + +- [Shell observability deferred](comparisons/2026-07-26_shell-observability-deferred.md) — 2026-07-26: in-flight shells in observation deferred, to anchor on canon class; cooldown/ammo observed; re-proposal rejected 2026-09-30 +- [Agent does not aim](comparisons/2026-08-17_agent-does-not-aim.md) — Run 344 sprays (turret spins 1 rev/2 s, aim reward 76 % of positive); fire cost 0.2 (345) killed trigger; sqrt tolerance (346) +- [PPO entropy regulation gaps](comparisons/2026-08-17_ppo-entropy-regulation-known-gaps.md) — 336-383: dual-ascent windup, PID/signed α, const 2e-3 holds σ 0.4-0.5, annealing collapses, per-dim targets after 407 +- [Event-only reward refactor](comparisons/2026-09-09_event-only-reward-refactor.md) — Aim shaping removed (camping); timeout ratio off proprio; 398 silu>tanh; starvation = pure truncation, run 400 ev 0.2-0.3 +- [Wrong checkpoint in game](comparisons/2026-09-20_game-does-not-fire-wrong-checkpoint.md) — "No aim/fire in game" = preferences.json pointing at 402 save_0, not a Bernoulli bug; check agent_folder+mtime +- [Absolute-angle regression](comparisons/2026-09-23_absolute-angle-aim-regression.md) — Absolute yaw reverted twice (411, 413): kill 6.3 vs 11.7; 180°/√(κ+1) error; α clamp ≥ 0 is a floor +- [Dead trigger, deterministic threshold](comparisons/2026-09-24_dead-trigger-deterministic-threshold.md) — Run 413 p(fire) 0.39 after 3 M, never crosses 0.5 in game; 414 crosses at ~4 M; weight-only probe recipe unreliable +- [Candidate architecture locks](comparisons/2026-09-27_candidate-architecture-locks.md) — Liquid τ≈0.6 s low-pass, CNN 1×2; hit ceiling 8-9 % common to vanilla/liquid ⟹ no lock demonstrated +- [Continuous entropy bonus 0](comparisons/2026-10-26_continuous-entropy-bonus-zero-sigma-collapse.md) — 430 (0.001) σ 0.45, passes D vs 433-439 (0) σ collapse, D stuck 250; metric_window_size lag pitfall +- [Ammo break-even threshold](comparisons/2026-10-27_ammo-economy-break-even-threshold.md) — 20 shells, +5/hit: needs hit ≥ 20 % vs ceiling 5-6 %; ammo horizon ≡ 30 s starvation ⟹ dumping rational +- [Event density collapse](comparisons/2026-10-29_event-density-collapsed-since-10-21.md) — kills/episode 11 (417-419) → 0.1-0.3 (437+); random hit 6 → 1.8 %; halving tanks halved hit +- [Per-episode efficiency levers](comparisons/2026-10-29_per-episode-efficiency-levers.md) — 32 tanks + aim tolerance 10 m+6° (gradient ×6) applied for run 453; λ/epochs/critic not levers +- [Ammo dump = reward optimum](comparisons/2026-11-02_ammo-dump-is-the-reward-optimum.md) — Run 467: shot +0.06 expectation, −0.5 at empty cheaper than disarmed, γ 0.99 ⟹ no fire cost can ration +- [Aim potential shaping](comparisons/2026-11-03_aim-potential-shaping.md) — γΦ(s′)−Φ(s), Φ=Cauchy of a theoretical shell; implemented 11-03, removed same evening +- [Bearing not decodable (470)](comparisons/2026-11-03_perception-lock-bearing-not-decodable.md) — 470 s6 yaw RMSE 20°=std, AUC 0.5 ≡ untrained CNN; the developer: consequence of event absence, not a CNN lock +- [Potential removed, economy to design](comparisons/2026-11-03_potential-removed-shell-economy-to-design.md) — 088ff389 removes Φ code; reserve 30/+20/60, no death at empty; constraints on any economy proposal +- [Scarcity tied to competence](comparisons/2026-11-03_scarcity-economy-tied-to-competence.md) — Run 475: ADR-driven 30/20/60→8/5/16, γ 0.995, no shot cost; refund 20 = free spam (p·k≥1) +- [Centred shot reward](comparisons/2026-11-04_centred-shot-reward-baseline.md) — Run 477: per-shell reward − ShotBaseline EMA (4096), Cauchy 2.5 m+3°, economy 10/+10/30; zero-expectation shot +- [Peak does not hold (500-502)](comparisons/2026-11-11_peak-does-not-hold-critic-leads-actor-follows.md) — hit peak 22 % at D 1000 undone: ev 0.5→0.2-0.3, Δev leads Δhit 10-20 k; σ frozen by hard clamp; μ saturates +- [Probe step = 0.1 s](comparisons/2026-11-11_probe-step-is-0-1-s-not-0-3.md) — Old probe script converted ×0.3; "empty reserve" seconds in notes before 11-11 are ×3 too large +- [SoftClamp σ](comparisons/2026-11-11_softclamp-sigma-soft-bound.md) — Sigmoid soft bound replaces torch::clamp (80-98 % of states at σ 0.700, zero grad); saves ≤ 502 give wrong σ with new binary +- [Aim diagnosis: μ white noise](comparisons/2026-11-12_aim-diagnosis-mu-white-noise.md) — 507/508: turret jitter from μ itself (8°/decision); ρ(A, aim)=0.003-0.02; finetune with immediate Φ 13→18-19 % +- [Aim diagnosis: range, out of field](comparisons/2026-11-12_aim-diagnosis-range-and-out-of-field.md) — 504/507: hit/shell 40-60 % <50 m vs 7-10 % >100 m; close enemy out of field 65-70 % +- [Aim oracle P0](comparisons/2026-11-12_aim-oracle-p0.md) — perfect shooter 80° = 11.0/8.5 hits/tank/min vs policy 5.4/1.9; elevation is the main loss, camera parallax costs at short range +- [Aim overhaul diagnosis, potential 507](comparisons/2026-11-12_aim-overhaul-diagnosis-potential-507.md) — 10° potential lever inconclusive (turret<5° same as 504); hits are short-range, near enemy out of view; proposals P0-P3 +- [Canon stabiliser](comparisons/2026-11-12_canon-stabiliser-gun-laying.md) — GunLaying 2-axis world setpoint, hinges 2→20 Hz, `aim_target` removed; run 508 vs 507 +- [Factored aim credit + Φ aimed](comparisons/2026-11-12_factored-aim-credit-phi-aimed.md) — Canon on A_vis (λ-return of Φ, λ 0), rest GAE; ρ 0.09-0.11; first run 509 +- [Oracle aim ceiling](comparisons/2026-11-12_oracle-aim-ceiling-elevation-parallax.md) — 507 s12: camera oracle ×2-4.4 policy, 360° +35 %; elevation main lock, parallax −30 % <50 m +- [Delayed respawn](comparisons/2026-11-13_delayed-respawn-cut-at-respawn.md) — Validated, pending 511 s9: 10 s disarmed without cut then respawn truncated + V cut +- [Empty reserve, no respawn](comparisons/2026-11-13_game-rule-empty-reserve-no-respawn.md) — Run 511 = 510 + no respawn/truncated at empty, no penalty; later reverted (decisions 11-22) +- [Per-group KL stop](comparisons/2026-11-13_per-group-kl-stop-skip-canon.md) — GroupKlStop canon/rest in 3 trainers; canon was 77 % of joint KL at stop (509); first run 510 +- [ev per optimiser batch](comparisons/2026-11-14_ev-per-optimiser-batch.md) — CSV `ev` was per GPU micro-batch (−1 to −14 in 516-518); fixed; 516-518 ev uninterpretable, use `v` +- [Forced zoom](comparisons/2026-11-14_forced-zoom-resolution-not-the-lock.md) — Probe --zoom on/off (514 s23, 515 s9): resolution ×2 no gain <100 m, only 100-200 m +- [Trigger entropy regulator](comparisons/2026-11-14_trigger-entropy-regulator-caps-selectivity.md) — 510 s9→32 replay: α_fire ×20 at 540 k loosens trigger; discrete_target_proba 0.01 ⟹ run 520 +- [Zoom usage and fine precision](comparisons/2026-11-14_zoom-usage-and-fine-precision.md) — 510/514/515; zoom selective and follows trigger; forced zoom does not improve aligned precision below 100 m, 512x256 not the lock +- [Agent economy 2/hit](comparisons/2026-11-15_agent-economy-2-shells-per-hit.md) — GAME_SHELL_ECONOMY 10/2/30 for agent in game and training; run 521 = 520 + N=2 +- [Aim/trigger local optimum](comparisons/2026-11-15_local-optimum-aim-trigger-coordination.md) — 520 s37 2×2×2 oracle: no single link pays, only OOO ×1.8/×2.6; confirmed 522 s68; first shot is the bottleneck +- [CNN bench: spatial softmax](comparisons/2026-11-16_cnn-bench-spatial-softmax.md) — 522 s68 images: softmax left/right 0.51 even supervised; flattened 7 convs 0.68 (0.73 <100 m) +- [Hypothesis: canon σ / holding](comparisons/2026-11-17_hypothesis-sigma-canon-target-holding.md) — Holding 1 s = 3 hits but σ 0.5+sweep prevent it; σ cap 0.25; refuted by run 529 +- [524 vs 430 (other PC)](comparisons/2026-11-17_run-524-vs-430-other-pc.md) — single advantage vs separate Φ credit: turret<5° 10 % vs 40 % at s16; flattened CNN not the cause; aim depends on the separate credit +- [Trigger closed at range](comparisons/2026-11-17_trigger-closed-at-range-lock.md) — 524-526 single advantage: hits <50 m only, trigger closes >50 m at 135-243 k ⟹ kills 18→8 +- [Coloured AR(1) noise](comparisons/2026-11-18_coloured-ar1-exploration-noise.md) — ρ 0.9 noise coded for run 533, removed 11-19: white ≥ coloured, policy cancels it +- [Critic blind to aim gesture](comparisons/2026-11-18_critic-blind-to-aiming-gesture.md) — 528/529 V slope ÷10-50; pilots 530-532 negative; lock = alignment SNR in target +- [Single advantage levers: why aim is not learned](comparisons/2026-11-18_single-advantage-levers-why-aim-not-learned.md) — critic blind to aiming gesture; ρ events 0.01-0.03; offline CNN learns alignment only from alignment-dependent target; pilots 530-532 negative +- [Why skip rises, 507-535](comparisons/2026-11-18_skip-kl-rise-507-535.md) — kl ×3 from factorised credit (509); exact KL is 94-100 % μ displacement; ‖mu.weight‖ grows 2x faster since 523, CNN main suspect, never isolated +- [Gesture: state vs events](comparisons/2026-11-19_aim-gesture-state-vs-events-signal.md) — Turret 2.2°/decision vs drift 0.18°; ρ(events, gesture) ≤ 0.03; sweep = acquisition +- [Aim synthesis « the circle »](comparisons/2026-11-19_aim-synthesis-the-circle.md) — 2×2 CNN × credit: only separate credit on Φ held kill 19-22 at D 1000; 523-538 without it +- [Canon credit on shot value H](comparisons/2026-11-19_canon-credit-on-shot-value-b.md) — H = linear critic head (BCE ×0.1), canon on γσ(H′)−σ(H); 540 stopped 147 k; superseded by Φ₂ +- [Image one decision late](comparisons/2026-11-19_image-one-decision-late.md) — draw_and_get_frame read previous render; fixed 11-19; shift image↔geometry for runs ≤ 538 +- [Turret gesture, noise, advantage](comparisons/2026-11-19_turret-gesture-noise-advantage.md) — gesture credit from events ρ≈0.01-0.03; sweep removal lowers hits; image lag fixed gives H slope 0.100 (≥0.08 criterion) +- [Aim/trigger loop diagnosis](comparisons/2026-11-20_aim-trigger-loop-diagnosis.md) — Trigger sorts without Φ, turret lets go on closure; empty penalty ruled out (543); Φ₂ coded; 544, 545 setup +- [Review since v1.3.2](comparisons/2026-11-20_review-since-v1-3-2-h-not-the-lever.md) — 523-542: H calms turret, no aim; empty penalty 40-70 % of r_hit at D 800; constant 0.5 (543) +- [Summary since v1.3.2](comparisons/2026-11-20_summary-since-v1.3.2.md) — 14 changes 523-542 tabulated; no run held D 1000 since 522; H not the aim lever; closing trigger as an equilibrium drop +- [Trigger closure diagnosis 508-543](comparisons/2026-11-20_trigger-closure-diagnosis_508-543.md) — Φ-credit runs 8/8 reach D 1000, event/H runs none; trigger sorts equally well; closure cuts the aim signal when it is not independent of firing +- [Hit-probability potential offline](comparisons/2026-11-21_hit-probability-potential-offline.md) — P ≥ Φ for yaw (0.05-0.18), events ≈ 0; sum with GAE harmless at weight ≤0.25; elevation needs its own term +- [545 vs 546 early](comparisons/2026-11-21_run-545-vs-546-early.md) — 546 (arena-exit death + received-shot direction) at 101 k: fire +40-70 %, kill within noise, kl 0.089 above target; two changes confounded +- [Target localisation not the source](comparisons/2026-11-21_target-localisation-source-cause.md) — Control 548 (bearing as input) s11 D 750 ≡ 547: perception hypothesis refuted +- [Canon σ collapse early](comparisons/2026-11-22_canon-sigma-collapsed-early-in-run.md) — σ canon 0.02-0.04 to 300 k; canon update fits rollout, no generalisation +- [Direct branch in liquid cell](comparisons/2026-11-23_direct-branch-liquid-cell.md) — Skip encoder→heads coded for 551 (twin 550); behaviour ≡ 550; removed 11-23 +- [Presence head on CNNs](comparisons/2026-11-23_presence-head-cnn-enemy-map.md) — 8×16 enemy map on actor+critic CNNs, coded for 552; later removed (decisions 11-25) +- [Origin of the sweep, 551 s20 / 550 s21](comparisons/2026-11-23_sweep-origin.md) — turret bimodal per pass (26 % of passes make 63 % of hits); ignored targets visible but not represented by the CNN; presence map learnable (0.91-0.97 < 200 m) +- [Turret bimodal per pass](comparisons/2026-11-23_turret-bimodal-per-pass-engagement.md) — 550 s21/551 s20: reaction 40/19/11 % at <60/60-100/100-200 m; CNN extraction AUC 0.945 vs 0.745 +- [Aim report run 552](comparisons/2026-11-24_aim-report-run-552.md) — margin = fine aim of visible targets >100 m; fine position at block 4 (0.77-1.34°) blurred by blocks 5-7; oracle yaw+elevation ×1.9-3.1; gesture credit ρ≈0 +- [Game funnel, no approach](comparisons/2026-11-25_game-funnel-no-approach.md) — Side 1000 loses at contact (>100 m 88-97 %); cos≈0; oracles: approach hits 5.2→7.7 +- [Game matches 546/552/553](comparisons/2026-11-25_game-matches-546-552-553.md) — no checkpoint good (47-77 % tanks no hit at side 1000); 552 s41 best; 553 s36 bad (the developer); 546 s20 below 552 s41 +- [Game matches 550/551/552](comparisons/2026-11-25_game-matches-550-551-552.md) — low cannon specific to 552; 552 s41 ≈ 550 s28; 551 direct branch adds nothing; 550 s10 ≥ 546 s20 +- [Game-verdict benchmarks](comparisons/2026-11-25_game-verdict-benchmarks.md) — 553 s35/36 bad; 552 s41 reference (dry@10s 0.06/0.08); 554 s17 ≡ 550 s26; 555 s17 ≡ 554 s17 +- [PPO liquid train 559 (ElMatador)](runs/2026-11-29-07-59-55_ElMatador_train_559_ppo_liquid/run.md) — 558 + actor split into drive/aim liquid cells (`e18fb09c`): at 376 k (D 850) α_dir_y ×9 vs 558 (throttle entropy pressure earlier), miss +9-11 m from D 600, hit/kill/fire ≈ 558; probe s13: throttle σ dir_y 0.073 on 558's trajectory (μ≈0) ⟹ actor-cell interference ruled out as the throttle-collapse cause; trigger less selective than 558 s14 (p_off 0.04 vs 0.01-0.02); s21: trigger collapse as 558 (p_al 0.20/0.25 vs 0.19/0.18), but throttle σ dir_y recovers to 0.101 (558 s21 0.026); game s21 vs 558 s21: dries sooner (dry@30 s 0.24/0.50 vs 0.07/0.27), side 500 kills 0.40 vs 0.19; split reverted +- [Reward landscape 557 / 558](comparisons/2026-11-30_reward-landscape-557-558.md) — event reward speaks on 5-8 % of armed decisions at side 1000 (enemy < 100 m), flat on 46-72 % (≥ 100 m, ≥ 10° off); one-step credit of closing the angle 0.13-0.35 < 100 m, 0.00-0.03 beyond, with or without the aim mask; far shots at the shell-price break-even (p* 0.07-0.12); reward delay and suffered-damage variance ruled out; script `reward_landscape.py` +- [PPO liquid train 560 (ElMatador)](runs/2026-11-30-01-16-21_ElMatador_train_560_ppo_liquid/run.md) — hit-probability potential in the reward, aim mask removed (`8be10f68`, confounded vs 557/558): at 385 k curriculum stuck at D 650 (≥ 104 k, refs left at 281 k), hit 0.10 vs 0.22/0.18 at D 650, trigger not collapsed (Hd 0.56); game s11/s14 below 558 s14 and 557 s14 (hit/shell 0.09/0.17 vs 0.24/0.32), all_dry ends 6/8-8/8, no early dump +- [PPO liquid train 561 (ElMatador)](runs/2026-11-30-08-14-20_ElMatador_train_561_ppo_liquid/run.md) — 557 + hit-probability potential (`bff34760`, single variable vs 557, one seed): curriculum D identical to 557 up to D 950 (429 k), train hit 0.28 vs 0.24 at 460-498 k (smaller side); game s14 = 557 s14 on combat, on-target ×2, gun level (no « canon bas »), dries a bit sooner; s21 vs 557 s21: hit/shell 0.27 / 0.38 vs 0.17 / 0.29 and reserve kept (dry at 30 s 0.28 / 0.37 vs 0.57 / 0.70) beyond sds, kills +0.04 / +0.09 within sds, no all_dry end; P10 literally not met (kills), decision to the developer; developer kept the potential; s30 regresses: trigger shrinks (shells/tank ÷3.5 / ÷1.8), « canon bas » back (−24°), kills 0.12 / 0.36 within sds — s21 is the best save diff --git a/.claude/knowledge/comparisons/2026-07-26_shell-observability-deferred.md b/.claude/knowledge/comparisons/2026-07-26_shell-observability-deferred.md new file mode 100644 index 000000000..203a5e8fd --- /dev/null +++ b/.claude/knowledge/comparisons/2026-07-26_shell-observability-deferred.md @@ -0,0 +1,11 @@ +# Deferred idea: expose in-flight shells + cooldown in the observation (via the canon class) + +Runs: 418 (re-proposal), none specific + +The developer's decision (2026-07-26): do NOT add in-flight shell state / cooldown to the proprioception via `BulletEnemyTank::get_proprioception()` + `ActionStats` (proposal made while debugging PPO convergence). They want to think about integrating it into the canon class (`canon.cpp`), where cooldown and fired shells have their natural place. + +**Context**: the shell reward falls at shell death, seconds after the shot, and nothing in the observation carries the state of in-flight shells → the PPO critic cannot predict these returns (POMDP). Touching `ENEMY_PROPRIOCEPTION_SIZE` breaks existing checkpoints. + +**Rule**: if the subject returns (critic not converging, flat value), recall this lead and the sketched mock-up (K slots relative pos/vel + flag + cooldown fraction), but anchor it on the canon side, not the tank side. Do not re-propose the ActionStats variant. + +**State at 2026-09-30**: cooldown and ammo ARE observed (`get_proprioception` ends with `nb_shells/max_shells` and `curr_cooldown_frame/fire_cooldown_frames`). Still unobserved: **in-flight shells** (relative position/velocity, where they will fall). Re-proposed after 418 then **rejected by the developer**: the shot is visible at the frame (cooldown, image), the LTC can remember it — do not bring it out as an explanation for low ev. (see docs/decisions.md 2026-08-17: training-only signal in arenai_model refused; 2026-11-03 information duplicating the screen refused) diff --git a/.claude/knowledge/comparisons/2026-08-17_agent-does-not-aim.md b/.claude/knowledge/comparisons/2026-08-17_agent-does-not-aim.md new file mode 100644 index 000000000..0b9dd7e73 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-08-17_agent-does-not-aim.md @@ -0,0 +1,23 @@ +# Why the agent sprays instead of aiming — reward decomposition and failed fire cost + +Runs: 344, 345, 346 + +Observation by the developer in game after `train_344`: « il ne tire même pas vers moi ». Not a bug: the agent correctly maximises the reward as written. + +**Measured behaviour.** Continuous μ stuck at the bounds (Hc measured −0.456 at σ = 0.326, below the theoretical value at |μ| = 1, −0.395). The turret is under **velocity control** (`enemy_handler.cpp`, `ENEMY_TURRET_RADIAL_VELOCITY = π` rad/s): saturated μ ⇒ **turret spins continuously, one revolution per 2 s**. Trigger: Hd = 0.363 ⇒ requested fire probability ≈ 0.88, `fire` = 1.47/s, limited by shell reserve not by policy. Precision `hit/fire` ≈ 2.3 %. The ~6-7 kills come from 32 tanks spraying simultaneously. + +**Reward decomposition** (per tank per second, run 344): aim Gaussian **+0.123/s (76 % of gross positive)**, hits + kills +0.038/s, death −0.036/s, hits received −0.003/s. The code comment said the Gaussian was « an order of magnitude under the hit bonus »: true per shell (0.5 vs 1.0), **false in expectation** — 0.087 vs 0.028 per shell, i.e. 3.1× above, because hits are too rare. + +**Failure of the fire cost (`train_345`, `fire_cost = 0.2`).** Calibration error: the 0.115/shell given as « income of a random shot » was the income of the **trained** 344 policy. A fresh policy earns only **0.059/shell**. Cost = 3.4× income, shooting lost from step one, fastest path to better reward = « stop shooting » — learned in ~120 rollouts (fire probability 2.7 %, `hit/fire` 0.00 %). Absorbing state: fewer shots → less aim signal → degrading aim. `discrete_entropy_coefficient` 1e-2 did not hold the trigger. + +**Basic tension: a constant fire cost cannot do both.** Bootstrap needs c ≤ ~0.06, anti-spam needs c > 0.115, and shot income *grows with training*. Would need annealing. The original comment in `jolt_enemy_tank.cpp` (shell reserve rather than per-shot penalty) was right, and 345 confirmed it. + +**Not at fault** (checked line by line): GAE (`dones` mask bootstrap and recursion, normalisation masked by `valids`), the rollout buffer, γ = 0.997 / λ = 0.98, and credit delay — a shell travels ~8 m/frame, so resolution in 6 frames at 44 m, not 40. + +**Retained fix (`train_346`)**: `ratio = 1.5 * miss / sqrt(distance)` instead of `10 * miss / distance`. Tolerance was proportional to range (15 m at 150 m, three tank widths), making long-range crowd fire the cheapest income. The sqrt version keeps 4.4 m at typical engagement distance (44 m — 500×500 arena, 32 tanks) and drops to 8 m at 150 m. Gain vs 344: unchanged at 44 m, ÷8.7 at 100 m, ÷58 at 150 m; a real hit still pays 0.90. + +**Next lead if `hit/fire` stays flat**: the only aim signal is paid at shell death, never during. A dense immediate signal (canon angle / nearest enemy, paid every frame) would give the turret a direct gradient. Not validated by the developer. + +(see docs/decisions.md: dense shaping removed 2026-07, fire cost removed 2026-11-07 / refused 2026-11-09, shell reserve validated 2026-08-06) + +See comparisons/2026-08-17_ppo-entropy-regulation-known-gaps.md for metric reading. diff --git a/.claude/knowledge/comparisons/2026-08-17_ppo-entropy-regulation-known-gaps.md b/.claude/knowledge/comparisons/2026-08-17_ppo-entropy-regulation-known-gaps.md new file mode 100644 index 000000000..e351d3514 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-08-17_ppo-entropy-regulation-known-gaps.md @@ -0,0 +1,118 @@ +# PPO entropy regulation — windup 355, canonical PID, signed α after 375, review 375-379, 383, λ ≥ 0 (Stooke), per-dimension targets + +Runs: 336-343, 344, 355, 358, 359, 367, 368, 374-379, 383, 405, 407 + +Series 336-343: dual ascent on PPO entropy coefficients collapsed in every possible way (limit cycle, windup, α at floor). Closed 2026-08-17 by **constant coefficients**. SAC keeps its dual ascent, intact. Later sections: 2026-08-19/20 return to per-action dual ascent, PID Lagrangian, 2026-08-27 discrete gain, 2026-08-30 signed α, 2026-08-31 review 375-379, 2026-09-01 constant factor 383 and λ ≥ 0 with constant target, 2026-09-21 per-dimension targets (ppo_liquid) after run 407 camping. (see docs/decisions.md 2026-09-01 target-entropy annealing refused; 2026-11-08 entropy coefficient replaced by automatic α per action) + +**What decided it (`train_343`, bonus fully removed).** σ collapsed 0.31 → 0.027, log-ratio exploded (`kl` 0.017 → 0.65, 32× the `1.5 × target_kl` threshold), early-stop bit on almost all minibatches and the actor was left with **1 gradient step per rollout instead of 112**. Kills 4.5 → 0.6. Irreversible lock: low σ → huge KL → early-stop → no step to leave low σ. + +**The diagnosis of 342 was wrong on one key point**: the PPO surrogate does have a downward restoring force on σ, and it is strong. The bonus was not inflating σ — it was preventing its collapse. With constant α there is a real equilibrium (`∂H/∂log σ ≈ 1` pushes up, the surrogate pulls down), unlike dual ascent where α itself diverged. + +**Measured calibration** (α_c sweeps by the dual ascent of 340/341): below ~5e-4 σ drifts down, above ~1.2e-3 it rises. **α_c = 1e-5 is indistinguishable from zero** — the « plateau » read on 342 was a descent over too few rollouts. Retained: `continuous_entropy_coefficient = 2e-3`, placing σ* ≈ 0.4-0.5. + +**Result (`train_344`)**: first run of the series to clearly progress — peaks 6.07 → 7.36 kills, stable troughs ~4.2, best 100-rollout window 7.39 (no previous run above 5.5 at this stage). The run crossed the KL threshold around rollout 900 (`kl` 0.037) **and came back out**: σ rose, `clip` with it. That is the difference with 343. + +**Metric reading pitfalls.** +- `clip` low means nothing alone: recorded **only after** a successful `optimizer->step()`. Low + `kl` low + σ large = diffuse policy, all fine (`corr(σ, kl) = −0.69`, a large σ mechanically crushes `clip` and `kl`). Low + `kl` high = skipped minibatches, frozen actor. The pair matters, never `clip` alone. +- `kl = inf` = underflow of `exp(log_ratio)`, never fixed (`SIGMA_MIN = 1e-4`). 219 rollouts of 2010 in 344. Freezes the actor on those rollouts. +- **`Hc` betrays μ saturation**: compare measured Hc to the theoretical truncated-normal value for the measured σ and |μ| = 0. An Hc below the |μ| = 1 curve means means are stuck at the bounds. See comparisons/2026-08-17_agent-does-not-aim.md. + +**Missing metrics, proposed three times, never added**: `σ_min` (distinguishes uniform collapse from a single recalcitrant dimension) and `|μ|` **per dimension** (Hc is a mean over the 4 dimensions, so cannot say whether turret or chassis). (see CLAUDE.md: no training metric added without validation) + +## Return of dual ascent, per-action (`5f41fc18`, run 355, 2026-08-19/20) + +Constant coefficients were replaced by an α **per continuous action dimension**, as **unbounded** `AlphaParameters` — SAC uses `ClampedAlphaParameters`. Run 355 reproduced the windup identically: α_c starts at 1e-3 and decays **exponentially, one e-fold per ~190k steps**, because the error `H − H_target` stays positive for 2.8M steps (natural σ ≈ 0.5 vs `target_sigma = 0.1`). α_c falls below 5e-7 at 1.59M — 4000× under the constant 2e-3 that worked. Then σ falls to 0.057, `clip` 0.09 → 0.46, `kl` 0.006 → 0.17, `skip` up to 0.52, kills 11.8 → 0.58. The regulator's time constant was of the order of the whole run: it never regulated. + +**The entropy target at current μ is correct** — do not « fix » it. `truncated_normal_entropy(mu.detach(), target_sigma)` cancels the truncation term on both sides, so the constraint does mean « σ ≈ target_sigma » and not « H ≈ constant ». With a fixed target at μ=0, a policy at σ = 0.1 but μ stuck at the bounds reads 0.69 nat missing and inflates σ for nothing. End-of-355 numerical check: σ = 0.099 and Hc = −1.57, vs `H(μ=±1, σ=0.1) = −1.577`. The regulator was exactly at its setpoint. **Comparing Hc to the μ=0 reference is the trap** (the reading that led to a wrong « moving target » diagnosis). + +**SGD does not replace the clamp.** Windup is structural: dual ascent = pure integrator, `log_α += lr·(H−H_target)` in SGD as `≈ lr·sign(…)` in Adam. As long as the error has one sign, it drifts without bound both ways. On 355 the error was ≈ +1.4 nat, so SGD would even have fallen 40 % faster than Adam. What SGD fixes is something else: Adam's scale invariance, giving the same step for 0.001 nat as for 2 nats, so α never settles. + +**Fixes applied 2026-08-20** (pre-commit green): `ClampedAlphaParameters(1e-3, 1e-5, 1e-1)` continuous **and** discrete; `alpha_learning_rate` 2e-4 → **1e-3** (set on the measured e-fold: ~38k steps instead of ~190k); entropy bonus that was **counted twice** outside skip (`actor_loss = -mean(bonus)` then `-= mean(surrogate + bonus)`) brought to once; `kl_exceeded` fallback = **dry skip**. + +**Why dry skip.** The old fallback did a pure-entropy step on the skipped minibatch, moving π away from π_old and raising KL of the following minibatches of the same rollout — positive loop, `skip` up to 0.52. Without an actor step, π stays equal to π_old, next rollout's ratios restart at 1 and the guard relaxes by itself. **Alpha updates continue on a skipped minibatch**: their loss contains no ratio, and it is what makes σ rise. + +**Per-dimension metrics still missing** (4th request). On 355, `α_c` being a mean of exponentials over dimensions, impossible to say which dimension pulled α down at end of run. + +**Why:** the developer changes one variable at a time between runs to keep the comparison clean. **Rule:** facing a collapse, read σ first, then the (`clip`, `kl`) pair, then `Hc` against its theoretical value. `v_μ` losing its signal is a consequence, never a cause. + +## PID Lagrangian: the PID plugged into an integrator (`934b061c`/`93c271a1`, 2026-08-20) + +First PID Lagrangian draft: `pid()` returned `u = k_p·e + k_i·I + k_d·Δe`, but the trainer made it a **loss** `-log_α · u` passed to an SGD → `log_α += lr·u`. `log_α` is thus a second integrator in series with the I term: `log_α = lr·(k_p·Σe + k_i·ΣΣe + k_d·e)`, two poles at z=1, never stable. Plus: `I` unprojected (could dive to −140 with k_i=2.5e-2 and ~14 calls/rollout) and the clamp `[1e-5, 1e-1]` lost in the move from `ClampedAlphaParameters` to `PidLagrangianAlphaParameters`. α → 0, same symptom as 355 but different cause. + +**Fixed (the developer's choice: canonical PID Stooke et al. 2020, per-minibatch cadence kept).** `PidLagrangianAlphaParameters` no longer inherits `AlphaParameters`: no parameter, no optimiser (both `*_alpha_optim` vanished from `PpoTrainer`). α **is** the controller output, and the controller runs **on log α** (the developer's idea): `I ← clamp(I + k_i·e, log α_min, log α_max)`, `log α = k_p·e + I + k_d·max(0, H_prev − H)`, `I₀ = log α₀`. Two consequences justifying log space: +- **positivity is structural** — no clamp on the output, a gain acts multiplicatively on α whatever the decade; +- only **one bound** remains, that of the integral, which is exactly the anti-windup. + +Derivative **on the measurement** not the error: the continuous target moves with μ and would give a parasitic whip. Bounds as `static constexpr` in the class: `MIN_ALPHA = 1e-8`, `MAX_ALPHA = 1`. Gains in the anonymous namespace of `ppo_trainer.cpp`: `k_p = 2e-1`, `k_i = 5e-3`, `k_d = 1`, α₀ = 1e-3. `alpha_learning_rate` (CLI) becomes **unused on the PPO side**. + +**The linear trap, for the record**: without output clamp, as soon as the integral hit its floor only `k_p·e` remained, so α **negative** when H > target — the entropy bonus became a penalty. That symptom triggered the switch to log. + +**Rise time from the floor is the price of anti-windup**: (log range)/(k_i·|e|). With floor 1e-8, rising to 1e-3 = 11.5 nats, ~4600 updates at |e| = 0.5, ≈ 330 rollouts (~300k steps). *Bounded* (the goal) but the same order as 355's calibrated e-fold. Two levers if too slow: raise the floor (`α_c = 1e-5` already indistinguishable from zero per 340/341) or raise `k_i`. + +**The D term is a multiplicative offset, not an integrator**: recomputed every update, never accumulated, so equals `×exp(k_d·ΔH)` with ΔH the inter-minibatch noise. Clipped ≥ 0, it gives a slight constant positive bias on α (a few %), not a drift. If α_c rises for no reason, `ALPHA_K_D = 0` is the first try. + +Covered by 6 tests in `tests_entropy.cpp` (`PidLagrangianAlphaParameterTest`), incl. `StaysPositiveAndFinite` and `RecoversFromSaturationWithoutWindup` locking both failure modes. + +## Discrete gain not at the scale of its error (`train_368`, 2026-08-27) + +The controller was not at fault — the integral clamp **is** the anti-windup, by design. What was wrong: `DISCRETE_ALPHA_K_I = 5e-4`, **10× lower** than continuous while the discrete head's error scale needs ~20× **higher**. + +Structural reason: the discrete target is the binary entropy of `target_fire_proba = 0.02`, i.e. **0.098 nat**, and the whole `Hd` range is [0, ln2 = 0.693]. Errors are intrinsically O(0.03), vs O(0.5–1) continuous. The rise formula `Δlog / (k_i·|e|)` gave, with errors measured on 368: continuous 3 800 updates ≈ **61 k steps** OK, discrete 766 000 updates ≈ **12 M steps** NOT OK (factor 200). `k_p = 2e-1`, identical on both heads, is equally inert on the discrete side: at |e| = 0.03 it moves α by 0.6 %. + +`RecoversFromSaturationWithoutWindup` did not cover this case — it locks `k_i = 5e-3` and `|e| = 0.5`, i.e. the **continuous** head's parameters. + +**Fixes (the developer's choice, pre-commit green)**: `DISCRETE_ALPHA_K_I` 5e-4 → **1e-2** and `MIN_ALPHA` 1e-8 → **1e-6** (shared; 340/341 already gave α = 1e-5 as indistinguishable from zero). Discrete rise reduced to ~23 000 updates ≈ **370 k steps**, in the targeted budget. New test `DiscreteGainRecoversAtItsOwnErrorScale`, failing on both assertions with the old gain. + +**What it does not explain.** On 368 there are **two** breaks, not one. α_d hits the floor at 3.68 M but `Hd` falls below its target only at 5.65 M: between the two the floor is the *correct* output. Only the 2nd break (5.7 M → end: `Hd` 0.17→0.068, `h/k` 19→24, `kl` 0.015→0.024) is windup. The 1st (3.9 → 5.1 M: `ev` 0.48→0.378, `kill` 10.6→6.3, `hit` down, **aim intact** `h/k` 15.6–17.4) remains **unexplained** — the critic degrades before aim. Unexplored lead: env changed between 367 and 368 (hit +1 s/+3 s, kill +5 s/+15 s, timeout penalty `−1` → `1 − steps/max` tending to 0 at end of episode, winner bonus `+4` → `4·(kills + 0.05·hits)`), making hit farming competitive with kills. Coherent symptoms: `s_μ` +3 %, `hit` +9 %, `kill` −29 %, `h/k` +39 %. To compare: 367 rose monotonically to 11.0 kills at 5.2 M, no regression. + +## Signed α as equality constraint, after the collapse of `train_375` (2026-08-30) + +`train_375` (beta law): best start of the series (kill 4.8 from 180k, smoothed peak 9.4 at 1.17M), `Hc` follows the descending target in lockstep from 1.2M to 3.6M **without any help** — α_c at floor all run, the constraint `H ≥ target` never violated. At 3.65M concentration snaps back (`Hc` −0.39 → ~0 in 300k steps) and **nothing holds it**: the one-sided controller (α = exp(log_α) > 0, always a bonus) cannot push entropy down. Self-sustaining loop afterwards: fewer hits → starvation deaths (s → 30 s floor) → signal reduced to the timeout −1 → weak advantages → no pressure to re-concentrate. kill 6→1 in 1M steps, no recovery. Second defect: `Hd` dives to 0.20 vs target 0.41 at 4.35M with α_d ≈ 0 — integral at floor `log(1e-6) = −13.8` makes the controller inert for thousands of updates even under massive violation (`k_p·e ≈ 0.04` vs −13.8). + +**Fix (the developer's choice, pre-commit green, run 376 from scratch)**: PID back to **linear space with signed α** — equality constraint `H = target`. `I ← clamp(I + k_i·e, ±1)`, `α = clamp(k_p·e + I + k_d·(H_prev − H), ±1)` (`MAX_ALPHA_ABS = 1`). Bonus when H < target, **penalty** when H > target: descent locked both ways. The derivative becomes **symmetric** (no more `clamp_min`): it also brakes fast rises — the missing emergency brake at 3.65M. The integral saturates at the output bound itself, so rise from saturation takes (range)/(k_i·|e|) and the P term acts immediately. + +**Not a regression to the pre-log bug of 08/2026**: back then, negative α was an *accident* (unclamped output + integral at −140); here output and integral are bounded at ±1 and the sign is the intended mechanism. The reasoning « positivity is structural in log » (§ canonical PID above) is the one that let the 375 collapse happen. Tests rewritten: `EntropyAboveTargetTurnsAlphaNegative`, `StaysBoundedOnBothSides` (replaces `StaysPositiveAndFinite`), `RecoversFromSaturationWithoutWindup` adapted (rise in ~360 updates instead of ~4600). Alpha modules are not serialised in saves (actor/critic/optims only), so no checkpoint-compat concern. + +Finding that stays true across 374 and 375: even at kill peak, `miss` never moved from ~30 m — gains come from cadence/proximity, not precision. See comparisons/2026-08-17_agent-does-not-aim.md. + +## Cross review 375-379: gamma 0.997 + high continuous entropy (2026-08-31) + +Analysis of `train_379_ppo` (trunc-normal, gamma 0.99, λ 0.98, warmup 7.5M) at 1M steps: decline already begun — kill 6.3 → 3.3 and hit ÷2 over the last 110 k-steps, **with no optimisation-side signal** (clip 0.155 stable, kl 0.011 stable, Hc stuck to target, fire/miss constant). Same early-collapse profile as 375 and 378. Aim decline is silent in the update metrics. + +**Two clean proofs, by controlled pairs:** +- `378_ppo` vs `378_ppo_trunc-normal-alpha-negative` (only gamma/λ differ): moving to gamma 0.99/λ 0.98 **triples the clip fraction from the 1st window** (0.045 → 0.125), collapses v (0.18 → 0.05), degrades ev (0.37 → 0.25) and kills. gamma 0.99 = horizon ~100 steps ≈ 3.3 s at 30 Hz — positioning credit leaves the horizon when a kill needs 5 hits. +- `378_trunc` vs `379` (only warmup differs, 3M vs 7.5M): long warmup helps a bit (5.2 vs 4.3 kills at 1M) but does not compensate gamma. + +**The only run that progresses durably is `377` (beta uniform, gamma 0.997)**: kill 3.4 → 10.6, holds 9.5 at 2.8M steps — and its Hc stayed 0.55-0.59 all run *because the controller could not track the descending target*. Pattern across the 5 runs: each time continuous entropy is effectively pushed down, performance declines; the only spared run is the one where regulation failed. + +**Trunc-normal entropy scale on [-1,1] (μ=0)**: H(σ=0.3) ≈ 0.21, H(σ=0.5) ≈ 0.57, H(σ=1) ≈ 0.68, ceiling ln 2 ≈ 0.693. The old init 0.2 corresponded to σ ≈ 0.3, far from 377's winning regime. + +**Fixes (validated by the developer, pre-commit green, 2026-08-31)** in `ppo_hyperparams.h`: gamma 0.99 → **0.997**, gae_lambda 0.98 → **0.99**, `continuous_target_entropy_init` 0.2 → **0.55**, `initial_sigma` 0.3 → **0.5** (policy starts on its target, no α re-inflation transient at start). + +**`continuous_target_entropy_final` −1 → 0.2 (the developer's choice, 2026-08-31), signed α kept.** −1 was the SAC heuristic (−dim(A), Haarnoja 2018) transplanted out of context — PPO literature uses a fixed small bonus (0.01 Atari, 0 MuJoCo), never a schedule toward determinism. −1 ⇔ σ ≈ 0.09 = death zone documented 3× (343: σ 0.025/kl 1.3 frozen; 355: σ 0.069/kills 0.5; 359: σ 0.166 still 12.5 kills but clip 0.27, at the edge of the lock). Operating zone of all good runs at peak: **σ 0.4–0.8** (Hc measured −0.1 to +0.3); the best run of all time, `train_358` (peak 14.4, end 12.8, never collapsed), ran at σ ≈ 0.77. With signed α, final 0.2 is a *rail*: σ pinned ≈ 0.3 at end of warmup. Known residual risk: around 4-5M the cosine imposes σ ≈ 0.33-0.35, slightly under the golden zone — if the run plateaus at this stage with Hc stuck on target and healthy kl/clip, **raise the target**, do not look elsewhere. Note: post-368 kills not strictly comparable to runs ≤ 367 (env reward change between 367 and 368). + +## The under-calibrated « constant factor » backtrack (`train_383_ppo_constant-entropy`, 2026-09-01) + +Commit `8378a100`: back to a fixed-coefficient entropy bonus (no α/PID at all), but **CosineAnnealing** init → final over `target_entropy_warmup_steps` (3M). Run 383: continuous 1e-3 → 1e-4, discrete 1e-3 → 1e-4 (discrete lowered 10× by the uncommitted diff of `ppo_hyperparams.h`). + +**The run replays exactly the collapse predicted by the 340/341 calibration** (« below ~5e-4 σ drifts down; 1e-5 indistinguishable from zero; the constant that worked = 2e-3 »): even the 1e-3 init is below the retained 2e-3, and the 1e-4 final is 5× under the drift threshold. Clear chronology in `metrics.csv` (1 row ≈ 900 steps, annealing done at 3M ≈ row 3350): +- 0 → 2000: normal rise, kill peak 8.7 around 1500; Hc follows annealing 0.47 → 0.25. +- **~3500 (= end of annealing): Hc turns negative** (min −0.19 ⇔ σ ≈ 0.2), clip 0.13 → 0.19, kl 0.013 → 0.021. Kills begin to decline (8 → 5). +- 5300 → 6700: starvation loop identical to 375 — kill 4.5 → 0.2, `s` 38 → 30 (timeout 30 s without hit), miss 21 → 29, `v` 0.10 → 0.03, r turns negative. Hc rises slightly at the very end (bonus/surrogate equilibrium exists even at 1e-4) but the reward signal is already dead. +- Discrete side: Hd 0.59 → 0.10 from row 2500 then 0.01-0.03 at end, fire 1.15 → 0.88 — the 10× lower discrete factor made the fire head quasi-deterministic very early. + +Lesson: the « constant » scheme validated 2026-08-17 was not « any fixed coefficient », it was **2e-3 precisely**. Annealing toward 1e-4 recreates the α→0 of dual ascent, open-loop this time. + +## Back to true Lagrangian λ ≥ 0, constant target (2026-09-01, the developer's request) + +After `1651296c` (PID Lagrangian + **ConstantTargetEntropy** — « target entropy annealing is destructive »), the developer switched the PID to **inequality constraint H ≥ target**: canonical projection Stooke et al. 2020, in linear space (no return to log and its floor inertia): `I ← clamp(I + k_i·e, 0, 1)`, `α = clamp(k_p·e + I + k_d·d, 0, 1)`. `MAX_ALPHA_ABS` → `MAX_ALPHA`. The post-375 signed α protected against re-inflation during a **descending target**; with a constant target that rail no longer exists, the surrogate pulls H down and the floor suffices. Tests rewritten: `SustainedOvershootParksAlphaAtZero`, `StaysWithinZeroAndMax`; output/integral saturate at 0 → the P term acts from the first update after the flip. Gains unchanged (k_p 2e-1, k_i 5e-3/1e-2, k_d 1, α₀ 1e-3). + +Reading of hyperparams in floor regime: the target is no longer a setpoint but a **lower bound** — initialise the policy *inside* the feasible region (H_init ≥ target), else α transient at start. `continuous_target_entropy = 0.4` ⇔ σ_floor ≈ 0.4 = low edge of the golden zone; `initial_sigma = 0.5` (H ≈ 0.57, feasible); `initial_fire_proba = 0.4` (H ≈ 0.67, feasible; spraying bounded by the env rate-limit of `9e02790a`). + +**`continuous_target_entropy = 0.4`: well placed, not « optimal » (never swept).** At μ = 0, 0.4 nat ⇔ σ ≈ 0.37 (low edge of golden zone), but the constant target is compared to the real H(μ, σ): with saturated μ (Hc of good runs at peak = −0.1 to +0.3), the effective floor pins σ toward ~0.5 and **α_c will be active at peak** — intended, it reproduces in closed loop the winning « 2e-3 constant » regime (375-379: pushing Hc down kills performance, the historic error has always been targets too low). Run reading grid: α_c ≈ 0 + σ in zone 0.4-0.8 = harmless floor; Hc stuck at 0.4 + α_c at stop + healthy kl/clip + suffering perf = only case where going down to 0.3 is discussable; σ under 0.4 despite active α_c = gains problem, not target. + +## Per-dimension targets on the ppo_liquid side (2026-09-21, validated by the developer after run 407) + +The collapse of 407 (see run 407 note: acceleration unlearned, camping) played out **above the floor**: Beta target −0.88 ⇔ κ ≈ 100, the camping locked at κ 25-80 without ever violating the constraint. And raising the global target is forbidden by the canon: in healthy 405_zoom, canon_x legitimately rose to κ 72-97 (H ≈ −0.85). Hence: `continuous_target_entropy` becomes a **per-dimension vector** (default `{-0.2, -0.2, -0.88, -0.88}` = direction x/y at κ ≲ 25, canon x/y unchanged) and `discrete_target_entropy_factors` a per-action vector (default `{0.2, 0.2}`, behaviour unchanged — no discrete collapse observed on 407: fire H 0.68, zoom H 0.40 at save_30). α were already per dimension; only the floor height becomes differentiated. Size TORCH_CHECK in the LiquidPpoTrainer ctor; `std::vector` added to the variant of `cli_fields.h` (JSON on CLI). The **ppo** module (feed-forward) keeps its scalars — deliberately not migrated. Beta scale (mode 0.5): H(κ=10) = +0.21, H(κ=25) = −0.21, H(κ=100) = −0.89. + +**The discrete floor must stay low: `discrete_target_entropy_factor = 0.2`** (0.139 nat ⇔ p ≈ 0.026), not 0.5. The developer's argument, validated: at 30 fps, even p = 0.01 fires within 10 s with ~95 % probability — the floor does not serve to guarantee fire events (they abound), only to prevent 383-type locking (Hd 0.01-0.03, dead gradient), and 0.139 suffices. Above all: the PID error is on the **mean** of Hd over the minibatch, and a correctly differentiated policy (p ≈ 0.9 target in front 30 % of the time, p ≈ 0.02 otherwise) has a mean Hd ≈ 0.17 nat — a floor at 0.347 would harass it permanently and only allow uniformly hesitant heads. 0.2 is also coherent with the historical scale `target_fire_proba = 0.02` (0.098 nat) on which `DISCRETE_ALPHA_K_I = 1e-2` was calibrated post-368. diff --git a/.claude/knowledge/comparisons/2026-09-09_event-only-reward-refactor.md b/.claude/knowledge/comparisons/2026-09-09_event-only-reward-refactor.md new file mode 100644 index 000000000..b2f8c583b --- /dev/null +++ b/.claude/knowledge/comparisons/2026-09-09_event-only-reward-refactor.md @@ -0,0 +1,21 @@ +# Event-only reward refactor (aim shaping removed = camping cause), timeout ratio removed, run 398_silu + +Runs: 353 (cited), 386, 388-397, 398_beta, 398_silu, 399, 400 + +2026-09 — aim shaping removed from the reward (cause of camping), 100 % event-based reward; 2026-09-13: timeout ratio removed from the proprio; 2026-09-16: run 398_silu — silu > tanh, but ev≈0 since the removal (critic blind to starvation). + +2026-09-09: the ppo_liquid run had converged to camping (aims/hits from spawn, no longer moves). Cause: the `aim` term (0.1 × aim_quality) was computed against the enemy's true position without line of sight — paid without perceiving. Refactor validated: `aim` removed from the reward (get_reward = hit + received + death, + win), TrackedShell machinery kept for `miss`/`r_aim` metrics (inert). Starvation as the only urgency. New run **from scratch** (no weight reuse — the developer does not care about the trained model). + +**Why:** movement must be instrumental (search in order to hit), not rewarded; event terms physically require line of sight, zero camping loophole. + +2026-09-13: the timeout ratio (remaining_frames/30 s, added 2026-09-04 with starving in JoltEnemyTank) is **removed from the proprioception** (134 features). Never ablated, no proof of gain (386, last run without, remained the best of the period); in game `apply_timeout=false` but the counter still decremented → obs pinned to 0 in long games = rare-terminal state never inhabited in training → spraying (permanent despair). The starvation mechanism stays (training only). Networks saved with the ratio (388-397, incl. liquid) are incompatible — from scratch anyway. + +2026-09-16 — analysis train_398_ppo_liquid_beta_silu (vs 398_beta tanh and 397, at equal duration ~6900 rows): **silu > tanh** everywhere (hitR 0.066 vs 0.058, kills 6.4 vs 4.7, curriculum D 1000 vs 850 reached). The « stagnation » of hitR/kill is mostly an artefact: 94 % of the run under growing curriculum (D 250→1000, real mean distance 250→640 m); at fixed D=1000 it still progresses (hitR 0.058→0.066). **Real problem: ev≈0 all run** (397 with timeout ratio in proprio: ev 0.42-0.49; both 398 without: ev≈0). The starvation timer decides deaths (terminal done in GAE) but is no longer observable → unpredictable returns → noisy advantages. kl≈0.0025 (target 0.05), clip ~3 %, Hc held by PID: no sign of saturation of the 128 neurons — the bottleneck is the critic, not capacity. + +**Implemented 2026-09-16 (validated by the developer)**: starvation = truncation + penalty −2 kept. Core tuple widened to `(State, Reward, IsDone, IsTruncated)`; death cause latched in `JoltEnemyTank` (`starved`, since the timer continued after a combat death); GAE of both PPO: `deltas = r + γ·(next_values·(1−dones) + values·truncateds) − values` (bootstrap on **V(s_t)**, the last living obs — the post-mortem wreck is not a state of the counterfactual MDP and V is never trained there); GAE recurrence always cut by `dones`; SAC: target with soft_value(state) for truncated steps. Winner/suicide stay terminal; the global episode timeout was already a correct truncation via bootstrap_state. + +Run 399 (truncation + penalty −2): ev does NOT rise (397 was already at 0.5-0.6 at the same age, ~150 rows). Diagnosis: the invisible −2 starvation remains an unpredictable shock of the same order as the cut (γ=0.997 → contribution −0.8 to −1.2 at 5-10 s from starvation, vs V≈0.2); early in the run most deaths are starvations. **2026-09-16: starvation penalty removed** (pure truncation, `detail.death = is_dead() && !is_timeout() ? -1 : 0`) — combat/suicide deaths keep −1. In reserve if ev still does not rise: starvation timer visible to the critic only. + +Run 400 (pure trunc), first ~200 rows: **best of the 4 runs at same age** — stable positive ev 0.2-0.3 without dip (first time since the timer removal), hitR 0.062, kills 4.9, aim 0.38, no camping (fire ~1/s stable). Mean r −0.0002 vs −0.0017 before: the −2 starvation was ~85 % of the reward mass, so ev of 397 (0.5) is not comparable (it mostly predicted starvations via the timer). Watch: slight ev settling (0.32→0.19, critic chasing a fast-progressing policy?) and ev holding at curriculum opening (D>250). + +**Test plan:** watch the run: `r_aim`/`miss` = ballistics must emerge from fortuitous hits (spawn 250 m, 32 tanks) — known risk run 353 (inert trigger without shaping); if `fire` active but `hit` flat after ~1-2k episodes, discuss before any fix. In reserve: `--gamma 0.999` (horizon 11 s → 33 s, aligned with starvation 30 s) if search stagnates. See runs 388-390 (curriculum, aim baseline) and comparisons/2026-08-17_agent-does-not-aim.md (resolved by this refactor). (see docs/decisions.md 2026-07 dense shaping removed; 2026-11-06 starvation removed; 2026-11-22 bootstrap at episode time limit validated) diff --git a/.claude/knowledge/comparisons/2026-09-20_game-does-not-fire-wrong-checkpoint.md b/.claude/knowledge/comparisons/2026-09-20_game-does-not-fire-wrong-checkpoint.md new file mode 100644 index 000000000..aac89715c --- /dev/null +++ b/.claude/knowledge/comparisons/2026-09-20_game-does-not-fire-wrong-checkpoint.md @@ -0,0 +1,23 @@ +# « Agent does not aim/fire in game » = wrong checkpoint loaded via preferences.json, not a Bernoulli bug + +Runs: 402 (save_0 loaded), 405 (save_26), 413 + +2026-09-20 — verified empirically: symptom caused by the wrong checkpoint selected in preferences.json. + +2026-09-20, symptom « checkpoint 26 of train_405 neither aims nor fires in game ». Verified: no bug in the Bernoulli chain (sigmoid → sample/max → threshold 0.5 → fire/zoom → canon). Replayed save_26 in the real TrainTankEnvironment in deterministic mode (exact game path): 86–93 % of frames with fire pressed, turret active, hits even at spawn_side 1000 m. + +Real cause: the desktop game loads the selection stored in `~/.cache/arenai/preferences.json`, which silently overrides defaults; it pointed to `train_402_ppo_liquid_zoom/save_0`, a barely trained checkpoint (p(fire)=0.40 < 0.5 → never fires in deterministic argmax, Beta mode ≈ 0 → still turret). The prefs had not moved since 2026-09-18 15:18 → no game played on this machine since, despite the impression of having tested save_26. + +Reflex for this symptom: check `agent_folder` in preferences.json and the file mtime before looking for a bug in the code. A `save_0` selected by mistake in the menu's file explorer produces exactly this symptom. + +Reusable quick diagnosis: load the actor alone (LiquidActor ctor + load_torch) and print p(fire)/modes on synthetic inputs — a save_0 gives p(fire)≈init and modes≈0. + +**Caution (2026-09-24): « p(fire) ≈ init » no longer proves « bad checkpoint ».** Run 413 gives p(fire) = 0.391 after 3 M steps, with well-learned modes — the discrete head drifts too slowly to cross 0.5 before ~6 M steps. Check both: the checkpoint index *and* the run's step count. See comparisons/2026-09-24_dead-trigger-deterministic-threshold.md and comparisons/2026-08-17_ppo-entropy-regulation-known-gaps.md. + +Additional pitfalls confirmed (2026-09-20, not fixed — design to validate by the developer): +- No checkpoint compatibility guard: a pre-Bernoulli save (≤ run 401, e.g. embedded resources/trained_models/ppo_liquid_400) loads without error in the current build (same Linear(128,2) shapes) but the discrete head is reinterpreted (softmax [fire, no-fire] → sigmoid [fire, zoom]): save_96 gives p(fire)≈0.41 < 0.5 → never fires in deterministic. +- AI menu: "select_folder" does not reset agent_config, and resolve_agent_config prioritises agent_config if non-empty → an old config.json selected once sticks to any future folder selection. +- Typo in arenai_desktop/src/main.cpp: default config = trained_models/ppo_train_400/config.json (the folder is named ppo_liquid_400). +- Untested suspicion: the desktop launched with --cuda would crash at the first act() (states_to_tensor stays CPU, actor on CUDA; only train.cpp does .to(device)). +- In blind vision (black/noise frames), save_26 STILL FIRES (p≈0.6-0.8) but does not aim → « fires without aiming » = broken vision; « neither fire nor aim » = wrong checkpoint. +(pitfall candidate for a skill/doc: check `~/.cache/arenai/preferences.json` agent_folder + mtime when a game checkpoint seems not to aim/fire) diff --git a/.claude/knowledge/comparisons/2026-09-23_absolute-angle-aim-regression.md b/.claude/knowledge/comparisons/2026-09-23_absolute-angle-aim-regression.md new file mode 100644 index 000000000..a1bb2fcbb --- /dev/null +++ b/.claude/knowledge/comparisons/2026-09-23_absolute-angle-aim-regression.md @@ -0,0 +1,23 @@ +# Absolute-angle yaw control ruins aim — reverted twice (runs 411, 413) + +Runs: 409, 411, 412, 413 + +Absolute turret angle control (`target = a·π`, commit 986550f5, run 411) was **reverted 2026-09-23** (commit 0eb125bd): back to delta control + Jolt motor 8 Hz. + +Measurements: at equal curriculum (D=400), run 409 (delta) kill=11.7 / hit=0.095, run 411 (absolute) kill=6.3 / hit=0.071. `fire` identical (~1.0/s) in both ⟹ the pointing is at fault, not the trigger (see comparisons/2026-08-17_agent-does-not-aim.md). + +**Why:** unimodal Beta law gives, for a centred mode, `σ_action = 1/√(κ+1)` with `κ ≤ CONCENTRATION_MAX = 2000` (`arenai_agent/src/networks/constants.h`). +- delta: 1 action unit = 0.105 rad ⟹ jitter `6°/√(κ+1)` per frame, harmless random walk (≈1.9°/frame at the observed κ≈10). +- absolute: 1 action unit = π rad ⟹ **absolute pointing error** `180°/√(κ+1)` every frame: ≈33° 1σ at κ≈28, and **4.0° irreducible even at the κ=2000 ceiling**. + +Lowering entropy targets fixes nothing: in `networks/entropy.cpp`, `error = target − H` and α is clamped ≥ 0, so **α is a floor, never a ceiling** — nothing forces the policy to tighten. The −3.0 nats target was below the law's floor (−2.38 at κ=2000), hence infeasible (same trap as in comparisons/2026-08-17_ppo-entropy-regulation-known-gaps.md). + +**Recurrence — run 413 (2026-09-24).** Commit `1cd80e0d` reintroduced absolute *and* replaced Beta by a truncated normal, betting the `CONCENTRATION_MAX` ceiling was the problem. It was not: `SIGMA_MIN = 1e-4` makes the −3.0 nats target reachable, yet σ did **not move from its init** in 3 M steps — `initial_sigma = 0.5`, final σ `[0.51, 0.50, 0.39, 0.51]` (dims dir.x, dir.y, turret, canon). σ = 0.39 in absolute = **±70° pointing 1σ**. Because α is clamped ≥ 0, a lower target only disables the bonus: it never pulls σ down. Only the `max_rad_per_frame` clamp (6°/frame) masks the disaster as a low-pass — the turret dithers and never settles. A/B at equal curriculum (D = 500): 412 (delta) hit 0.083 / kill 9.56 vs 413 (absolute) hit 0.072 / kill 6.35, degrading continuously (end of run 0.059 / 3.44). Same gap as 409 vs 411. + +Reverted 2026-09-24, this time **semantics only**: `TurretItem` / `CanonItem` keep `max_rad_per_frame` but read it as a rate (`angle -= x * max_rad_per_frame`), `EnemyControllerHandler` stays deleted, the player goes from `UNLIMITED_RADIAL_VELOCITY` to `PLAYER_TURRET_RADIAL_VELOCITY = 12π` rad/s (= former mouse gain 0.4π/frame at 30 Hz). Agent gain identical to run 412: 0.1047 rad/unit turret, 0.0419 canon. Entropy targets back to `{-0.2, -0.2, -0.88, -0.88}` (`-3.0/-1.4` only make sense in absolute). + +**Rule:** before changing the scale of a continuous action, check `σ_action × (action→physical gain)` against the required precision. To retry absolute: either raise `CONCENTRATION_MAX` by ~3 orders of magnitude *and* add a mechanism that really pushes tightening, or output yaw as (cos θ, sin θ) — which also removes the ±π discontinuity (a=+1 and a=−1 = same physical direction, not representable as a unimodal mode). + +Side pitfall of the same commit: `MotorSettings(8 Hz, 1)` removed from `turret.cpp` and `canon.cpp`, restoring the Jolt default 2 Hz (≈29° slew lag at π rad/s vs ~7° at 8 Hz) — although 44ed1f79 « fix: turret oscillating » had added it 4 h earlier. The added `tests_aim.cpp` saw nothing: they only assert the *commanded* angle (`get_angle()`) and never step the physics. + +Later: absolute angle retried as cos/sin in run 505 and in run 421 (2026-11-11); see docs/decisions.md 2026-09-24 (refused, aim is a delta command). diff --git a/.claude/knowledge/comparisons/2026-09-24_dead-trigger-deterministic-threshold.md b/.claude/knowledge/comparisons/2026-09-24_dead-trigger-deterministic-threshold.md new file mode 100644 index 000000000..718717a0e --- /dev/null +++ b/.claude/knowledge/comparisons/2026-09-24_dead-trigger-deterministic-threshold.md @@ -0,0 +1,59 @@ +# Dead trigger + deterministic threshold (run 413): game never fires + +Runs: 409, 412, 413, 414, 415 + +2026-09-24: run 413 — p(fire) stays at initial_fire_proba after 3 M steps; in deterministic mode the 0.5 threshold is never crossed, so the game never fires. + +The developer's symptom in game on `train_413_ppo_liquid_normal`: « il se déplace bien mais ne tire presque jamais ». Neither a bad checkpoint (see comparisons/2026-09-20_game-does-not-fire-wrong-checkpoint.md) nor a bug: **the discrete head never learned**. + +**Measured** (head `discrete.0` extracted from checkpoints, recipe below): + +| checkpoint | p(fire) | logit std | +|---|---|---| +| 413 save_0 (init) | 0.400 | 0.01 | +| 413 save_28 (3.07 M steps) | **0.391** | 0.14 | +| 412 save_20 (2.23 M steps) | 0.372 | 0.18 | +| 409 save_57 (6.22 M steps) | **0.506** | 0.35 | + +`initial_fire_proba = 0.40`. In game, `TorchLiquidPpoAgent::act(states, …)` calls `act(tensor, false)` ⇒ `bernoulli_max_action` = `(p > 0.5)`. At logit −0.44 ± 0.14, crossing 0.5 needs +3σ, ~0.1 % of states: **never**. Same for `p(zoom) ≈ 0.23`. + +**Why the gradient is null.** Reload = 1 shell / 1.5 s, cooldown = 1/6 s (`jolt_enemy_tank.cpp`). At p = 0.39 and 30 Hz, the wait before the trigger fires is **2.6 frames (0.085 s)**, negligible against 1.5 s: the tank fires at the ammo ceiling whatever p over [~0.05, 1]. `fire` metric = 0.70/s ≈ 0.667 (regen) + 5 × hit rate. Behaviour insensitive to p ⇒ the head stays at its init. Same finding as run 353 (run 353 damage fix note), but here with the in-game consequence, which was missing. + +So not a pathology but a **slow drift**: ~6 M steps (run 409) for the head to develop enough state dependence to cross 0.5. A run stopped at 3 M does not fire in deterministic, whatever else it is worth. + +**Why (mechanism):** the deterministic 0.5 threshold turns an unlearned head into « never fires », while in training (sampled) the same network fires at the max allowed — the gap between training metrics and in-game feeling comes entirely from there. + +**Rule:** before concluding anything about a checkpoint, print p(fire) and compare it to `initial_fire_proba` **and** to 0.5. Recipe without C++ build — `actor.pt` is an archive readable by `torch.jit.load`: + +```python +import torch +sd = dict(torch.jit.load("outputs//save_N/actor.pt", map_location="cpu").state_dict()) +w, b = sd['discrete.0.weight'], sd['discrete.0.bias'] +logit = w.sum(1) * 0.205 + b # 0.205 = E[SiLU(N(0,1))], output of LayerNorm+SiLU +print(torch.sigmoid(logit), w.norm(dim=1) * 0.558) # 0.558 = std[SiLU(N(0,1))] +``` +Same recipe on `sigma.0` / `mu.0` gives typical σ and μ — it is what exposed comparisons/2026-09-23_absolute-angle-aim-regression.md. + +Leads discussed, **not validated**: solicit the fire action only on frames where `can_fire` is true (today sampled 30 times/s for ~0.7 useful shots/s), or raise stock/reload so cadence becomes a choice. + +**Confirmed and refined at run 414 (2026-09-27).** The slow drift exists and the 0.5 threshold is crossed **earlier than estimated: ~3.8-4.8 M steps**, not ~6 M. p(fire) measured on 414 (recipe above, but **corrected for the LayerNorm affine** — see below): save_0 0.400 → save_35 0.499 → save_44 0.521 → save_106 0.536 → save_155 **0.583** (73 % of states above 0.5). So 414 fires in deterministic. `p(zoom)` stays 0.22 at all checkpoints ⟹ **zoom never triggers in game**, no run excepted. + +Practical pitfall: `~/.cache/arenai/preferences.json` pointed to `save_44` (p = 0.52, 61 % of states), just above the threshold — testing there measures the threshold margin rather than the policy. Take the last checkpoint. + +**Recipe correction.** `w.sum(1) * 0.205` assumes LayerNorm outputs raw N(0,1), but `liquid.to_output.1` has `elementwise_affine=true`: go through γ and β, else σ is wrong (on 414 the naive recipe gave σ_canon = 0.27 instead of 0.39 — enough to wrongly conclude σ had tightened). + +```python +import torch +sd = dict(torch.jit.load("outputs//save_N/actor.pt", map_location="cpu").state_dict()) +g, b_ln = sd['liquid.to_output.1.weight'], sd['liquid.to_output.1.bias'] +h = torch.nn.functional.silu(torch.randn(200000, 1) * g + b_ln) # realistic features +E, V = h.mean(0), h.var(0) +for head in ('mu', 'sigma', 'discrete'): + w, b = sd[f'{head}.0.weight'], sd[f'{head}.0.bias'] + print(head, (w * E).sum(1) + b, ((w**2) * V).sum(1).sqrt()) # mean, std over states +# σ = exp(log(1e-4) * (1 - sigmoid(pre_act))) ; p = sigmoid(pre_act) +``` +The mean gives typical behaviour, the std the truly state-dependent part (on 414 save_155: μ_turret = +0.160 ± 0.229 ⟹ positive command in ~76 % of states, i.e. ~29°/s permanent sweep — the drift of comparisons/2026-08-17_agent-does-not-aim.md is still there). + +**⚠ Recipe NOT reliable (found 2026-09-27, run 415).** Even LayerNorm-corrected, it assumes each `to_output` feature is N(0,1) *across states*; LayerNorm only normalises *across the features of one state*, so per-feature means and correlations are unknown without real states. Proof: on 415 save_7 it gives σ ≈ 0.10 on the 4 dims while the trainer measures `Hc` ≈ 0 (⟺ σ ≈ 0.25). All p(fire)/σ values drawn from weights alone (413 and 414) are indicative at best. For 413, « never fires » stays valid because the developer **observed it in game**; for 414, « it will fire » is not established. Reliable sources: `Hc`/`Hd` of metrics.csv, and the in-game test. +(pitfall candidate for a skill/doc: weight-only probing recipe unreliable; deterministic threshold 0.5) diff --git a/.claude/knowledge/comparisons/2026-09-27_candidate-architecture-locks.md b/.claude/knowledge/comparisons/2026-09-27_candidate-architecture-locks.md new file mode 100644 index 000000000..fe512c9ef --- /dev/null +++ b/.claude/knowledge/comparisons/2026-09-27_candidate-architecture-locks.md @@ -0,0 +1,15 @@ +# Candidate architecture locks (liquid cell low-pass, CNN squashed to 1×2) — none demonstrated + +Runs: 391, 392, 405_zoom, 407, 409, 414 + +2026-09-27 — liquid cell = low-pass τ≈0.6 s, CNN squashed to 1×2; but common hit ceiling ~8-9 % for vanilla/liquid and CNN 1×2/2×4 ⟹ none demonstrated. + +The developer's question: « il n'y a pas des verrous dans l'architecture ? ». Reliable measurements (parameters and geometry, no assumed state distribution — cf. the error of comparisons/2026-09-24_dead-trigger-deterministic-threshold.md). + +**Liquid cell = low-pass filter.** `liquid_cell.cpp`: semi-implicit Euler LTC, 6 sub-steps of 1/180 s, `x ← (x + h·f·a)/(1 + h(1/τ + f))`, and the heads see **only** x (no direct input → output path). Effective constant `τ_eff = 1/(1/τ + f)`, fraction updated per frame `1 − exp(−(1/τ+f)/30)`: 5 % at f=0, 8 % at f=1, 29 % at f=10. τ measured 414 save_155: **0.45-0.77 s (median 0.60)**, barely moved from init `softplus(0)` = 0.69. Input weights ×8 (row norm 0.196 → 1.62). Real f unknown without real observations. + +**Vision.** 128×256, vertical FOV π/4 ⟹ horizontal ≈ 79°, ≈ 3.2 px/°. 7 convs stride 2 ⟹ final map **1×2** (128 px cells ≈ 40°), the aim point falls on the boundary of the two. Required precision: tank ~5 m at 60-90 m (nearest-neighbour distance, 32 tanks) ⟹ ±1.6-2.4° ≈ ±5-8 px. + +**What prevents concluding** — hit at equal curriculum: 405_zoom (CNN 6 convs, map 2×4) 0.071-0.088; 407/409/414 (1×2) 0.073-0.096; **vanilla PPO 391 (no recurrence, hence no delay)** 0.08-0.095 at D=525-800. Common ceiling ~8-9 %; 392 (vanilla, 0.114-0.125 at D=250-300) is confounded by the old reward with aim shaping (before 2026-09-13, comparisons/2026-09-09_event-only-reward-refactor.md). + +**Rule:** do not blame the liquid delay nor the CNN squashing without measurement. Proposed test (not validated): C++ harness rendering real frames with the bearing of the nearest enemy ⟹ (a) linear probe bearing ← frozen CNN features (error > ~1.5° ⟹ vision is the lock), (b) real step response of the actor (delay in frames). See run 414 (plateau, σ init). (later: 2026-11-16 CNN bench comparisons/2026-11-16_cnn-bench-spatial-softmax.md; docs/decisions.md 2026-11-10 perception ruled out) diff --git a/.claude/knowledge/comparisons/2026-10-26_continuous-entropy-bonus-zero-sigma-collapse.md b/.claude/knowledge/comparisons/2026-10-26_continuous-entropy-bonus-zero-sigma-collapse.md new file mode 100644 index 000000000..c9e04feea --- /dev/null +++ b/.claude/knowledge/comparisons/2026-10-26_continuous-entropy-bonus-zero-sigma-collapse.md @@ -0,0 +1,25 @@ +# Continuous entropy bonus at 0 ⟹ σ collapses, D stuck at 250 + +Runs: 430, 433, 435, 439, 440 (also 429, 437) + +Since 9fe8ddf9 (2026-10-24) the continuous entropy bonus is 0 ⟹ σ collapses within the first 100 k, hit plateaus at 4-5 % < curriculum threshold 6 %, D never leaves 250 (433-439); 430 with 0.001 held σ 0.45 and passed D (clean pair 430/433). + +Pair 430 / 433 (only differences: cont_entropy 0.001 → 0, epochs 2 → 6, p_fire 0.4 → 0.25): + +| | 430 (bonus 0.001) | 433 / 435 / 439 (bonus 0) | +|---|---|---| +| Hc 0 → 500 k | 0.54 → 0.48 (σ ≈ 0.45) | 0.53 → 0.25 / −0.14 (σ ≈ 0.3 / 0.2) | +| kl / clip | 0.004 / 0.04 | 0.02-0.07 / 0.2-0.5, skip up to 50-70 % | +| hit | 2.5 → 5.6 % at 700 k, monotone | 4-4.5 % from 200 k then plateau, then ≤ 3 % | +| D | 300 at 800 k, 450 at 5 M | 250 whole life | + +Mechanism: the PPO surrogate pulls σ down (cf. run 343); without bonus σ sharpens early (fast gain 0-300 k), then falls below ~0.3 (Hc < 0.2): aim no longer explored, hit plateaus under the 6 % threshold, then drifts (μ random walk, kl at the stop). More epochs = faster collapse (433 epochs 6: Hc → 0 in 400 k; 435/439 epochs 4: in 1 M). + +The developer had already found this on 2026-10-21 (commit 10392476: « 0.0 converges to broken policy »), then the bonus was removed again 2026-10-24 (9fe8ddf9) and the factor code removed in d01d5432 (2026-10-26). The 7 following runs all have the same profile. + +**Why:** the variable separating runs that leave D = 250 from those that do not, at same env (reserve 20, no regen). Ammo economy (430 vs 429) slows but does not block. + +**Rule:** restore `continuous_entropy_factor` 0.001/dim (value measured on 430; 2e-3 was the vanilla calibration of 340/341 if σ still drifts under 0.3). Target operating zone: Hc ≥ 0.2 ⟺ σ ≥ 0.3, cf. comparisons/2026-08-17_ppo-entropy-regulation-known-gaps.md (golden zone σ 0.4-0.8). See runs 439, 433, 430. + +**Run 440 (launched 2026-10-26 ~12 h, commit 5a2f8164)**: config = 439 + continuous **0.001** (not 0.01) + discrete 0, epochs 4, γ 0.994, p_init 0.01/0.05 unchanged. At 80 k: identical to 439 on everything, including instant σ drift (Hc 0.564 → 0.515 on both). Pitfall: `metric_window_size = 4096` updates ≈ 110 rollouts ≈ 100 k steps ⟹ the CSV trainer columns are cumulative means up to ~100 k then lagged ~50 k; de-cumulate to read the instant. Expected verdict at 200-300 k: Hc ≥ 0.5 = bonus holds (430); ≤ 0.45 = 0.001 too weak with epochs 4 (calibration 340/341: 1e-3 marginal, 2e-3 holds). Relaunched 2026-10-26 ~13 h with `metric_window_size` 256 (≈ 7 rollouts ≈ 6 k steps: trainer columns near-instantaneous, like 437) — the 80 k above is the old 440. +(see docs/decisions.md 2026-11-08: entropy coefficient replaced by automatic α per action) diff --git a/.claude/knowledge/comparisons/2026-10-27_ammo-economy-break-even-threshold.md b/.claude/knowledge/comparisons/2026-10-27_ammo-economy-break-even-threshold.md new file mode 100644 index 000000000..20f8c7124 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-10-27_ammo-economy-break-even-threshold.md @@ -0,0 +1,12 @@ +# Ammo economy break-even threshold (env since 2026-10-25) + +Runs: 430, 437, 441 + +Env since 2026-10-25 (20 shells, +5 per hit, max 30, death −1 at empty reserve): break-even hit ≥ 20 % vs observed ceiling 5-6 %; ammo horizon (20 shells at 0.7/s ≈ 28 s) ≡ starvation timer 30 s ⟹ emptying the reserve is rational, the rule carries no gradient. + +Env state (jolt_enemy_tank.cpp, commits 548b4117 of 2026-10-23 and ca4583a5 of 2026-10-25): 20 initial shells, +5 per hit, cap 30, empty reserve (no shell in flight) = suicide ⟹ death −1; starvation 30 s without hit (+3 s per hit, +15 s per kill) = truncation without penalty. Shell ratio/max is in the proprio. + +**Arithmetic (2026-10-27, run 441):** for the reserve to be maintained hit ≥ 1/5 = 20 % is needed. Observed ceiling across all runs: 5-6 %. At 0.7 shot/s the 20 shells leave in ~28 s, i.e. the starvation timer: keeping shells does not save (truncation at 30 s), emptying them maximises the chance of a hit in the window. Fire 0.5-0.9/s constant from 430 to 441: neither the regen removal nor death at empty moved the cadence. The CSV does not distinguish the end cause (empty / starvation / killed) — fire×s ≈ 20-22 shells fired for 24-27 available, so unknown whether the agent keeps shells. + +**Why:** the developer expects regen-on-hit to teach ammo management; it cannot while the break-even threshold is 3-4× above the precision ceiling. +**Rule:** before touching the reward, bring the threshold close to the ceiling (e.g. +15-20 shells per hit ⟹ threshold 5-7 %) or conclude it is useless; do not propose a long cooldown (refused, see docs/decisions.md 2026-10-25). See runs 441, 430, 437. (starvation removed 2026-11-06 per docs/decisions.md) diff --git a/.claude/knowledge/comparisons/2026-10-29_event-density-collapsed-since-10-21.md b/.claude/knowledge/comparisons/2026-10-29_event-density-collapsed-since-10-21.md new file mode 100644 index 000000000..2cf0926e4 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-10-29_event-density-collapsed-since-10-21.md @@ -0,0 +1,16 @@ +# Event density collapsed since 2026-10-21 — why convergence is slower than in September + +Runs: 417, 419, 428, 429, 430, 437, 441, 450 + +kills/episode 11 (417-419) → 1.4 (428) → 0.3-0.9 (430) → 0.1-0.3 (437+); random hit 6 % → 2.6 % → 1.8 %; the event reward no longer has events. + +Figures (metrics.csv, blocks 0-100 k / 100-300 k): +- 417/419 (2026-09-28, 10-04): 32 tanks, network 512, shell regen, 30 Hz — hit 6 % → 10 % in 100 k, kill 5 → 11 per episode, D leaves 250 at 300 k, D 418 at 1.2 M. +- 428/429 (2026-10-21): 16 tanks, network 128, spatial softmax, can_fire mask, 10 Hz, new aim reward — hit 2.6 % → 5 %, kill 0.3 → 1.4, D leaves 250 at 300 k-1.2 M. +- 430 (2026-10-23, regen removed): kill 0.1 → 0.9, fire 1.1 → 0.55/s. +- 437/441 (2026-10-25, death at empty reserve −1): r = −0.003/step (92 % of lives end with the −1 at ~24 s), kill 0.1 → 0.5, hit 2.8 % → 5.8 % at 1.2 M only, D 250 until 800 k. +- 450 (2026-10-29, IMPALA + bonus 0.01): random hit 1.8 %, kill 0.04. + +**Why:** the reward is purely event-based; the aim gradient is carried by hits (0.4 per life today, ~4 in 419). Death at empty reserve is a −1 identical for all, without gradient (cf. comparisons/2026-10-27_ammo-economy-break-even-threshold.md, run 437). Halving the tanks halved the random hit. + +**Rule:** before touching the optimiser, compare event density (hit at 0 k, kill/episode) with 419's; levers = tank density / arena size, empty-reserve rule, hit vs death scale. Decisions for the developer. diff --git a/.claude/knowledge/comparisons/2026-10-29_per-episode-efficiency-levers.md b/.claude/knowledge/comparisons/2026-10-29_per-episode-efficiency-levers.md new file mode 100644 index 000000000..694a4bea8 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-10-29_per-episode-efficiency-levers.md @@ -0,0 +1,14 @@ +# Per-episode efficiency levers: target density and aim tolerance + +Runs: 419, 447, 452, 453 (applied) + +2026-10-29 — to converge faster at equal number of episodes: target density (419 = 32 tanks in the same 250 zone ⟹ hit ×2.5 at 0 k) and aim tolerance (2° ⟹ tol 4-8 m for miss 27 m: aim reward in the exponential tail, gradient ~2e-4/m); λ 0.99, epochs, critic are not levers. + +Signal per episode = ~22 shells (reserve 20, +15/hit at 2 % hit) × informativeness of each shell. +- Density: 419 = 32 tanks in the initial zone 250×250 (same zone as 16 tanks today). Hit at 0 k 6 % vs 2-2.5 %; kill/episode ×8 (with regen). GPU-cost-free equivalent: `--initial_spawn_width/height 175` (area ÷2). CLI flags, zero code. +- Aim tolerance (jolt_enemy_tank.cpp:62-63, aim_tolerance_min 3.25 m, angle 2°): tol = 3.25 + 0.035·d ⟹ 4-8 m for shots of 30-130 m, mean miss 27 m ⟹ exp(−27/6) ≈ 0.01, gradient 0.1·q/tol ≈ 2e-4 per metre: the typical shell learns almost nothing. Angle 6° + min 10 m ⟹ tol ≈ 18 m, q ≈ 0.22, gradient ≈ 1.2e-3/m (×6), max 0.1 unchanged < hit 0.2. +- Non-levers: gae_lambda already 0.99 (~1 s flight intact), epochs > 4 ⟹ KL regime (run 449), critic at ev ≈ 0 legitimate (quasi-constant value). + +**Why:** 452 showed the optimiser healthy (skip 0, Hc 0.62) and the game unchanged at 64 k; what is missing is the per-episode signal, not the number of steps (see comparisons/2026-10-29_event-density-collapsed-since-10-21.md). + +**Decision 2026-10-29 (the developer):** all three applied for run 453 — default nb_tanks 32 (main.cpp), tolerance 10 m + 6°, reserve 40 / max 50 (jolt_enemy_tank.cpp), model tests adapted. Comparison reference: 452 (config 447 + empty-reserve truncation, 16 tanks, 2°, reserve 20). Proposal to the developer at first; they decided. diff --git a/.claude/knowledge/comparisons/2026-11-02_ammo-dump-is-the-reward-optimum.md b/.claude/knowledge/comparisons/2026-11-02_ammo-dump-is-the-reward-optimum.md new file mode 100644 index 000000000..4c89b3d9e --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-02_ammo-dump-is-the-reward-optimum.md @@ -0,0 +1,17 @@ +# Ammo dump is the reward optimum (run 467) + +Runs: 465, 467 (also 437, 474 cited) + +2026-11-02, run 467 (10 shells, +10/hit, cost 0.01, empty −0.5, γ 0.99 at 10 Hz) — emptying the reserve in ~10 s is the computed optimum of the reward: shot = +0.06 expectation (aim 0.068 for a 26 m miss = shot bonus), −0.5 at empty cheaper than living disarmed (−0.3/hit, −1 killed), γ removes 40 % from a shell kept 5 s; no penalty on the trigger can ration while miss does not move. + +Run 467 (`outputs/train_467_ppo_liquid`, launched 2026-11-02 10:26, 340 k decisions, D 250 → 550): fire 1.1-1.5/s, hit 7-11 %, miss 21 → 26.5 m (never falls), s 12-15 s, r_aim 0.0047 > r_hit 0.0033 per step, r_rcv ≈ −(r_aim + r_hit) (symmetric melee, zero sum). + +**Shot arithmetic (jolt_enemy_tank.cpp, tol = 10 m + 6°·D).** At D=550 tol = 68 m: a 26 m miss pays 0.1·exp(−26/68) = 0.068, a perfect hit 0.1, a 50 m miss still 0.048. The aim reward is a shot bonus, not a precision bonus, and the first source of income. Expectation per shot (aim + hit)/fire ≈ 0.06 vs cost 0.01 ⟹ every shot is net positive. + +**Why −0.5 at empty weighs nothing.** Last shell, γ 0.99 at 10 Hz: firing ≈ +0.06 − 0.91·0.5·γ^15 + 0.09·(refill 10 shells ≈ +0.5) ≈ −0.28; keeping = living disarmed ≈ hits received (−0.004/step) + killed (−1) before 30 s ≈ −0.5. Dying empty is the cheapest exit. Same logic as run 437 (−1: « flat penalty »). And γ: a shell kept 5 s loses 40 % of its value. + +**Why a fire cost cannot do the job.** Cost is constant, gain depends on state (density, distance). 0.01 changes nothing (467); 0.03 cuts shots as soon as density drops and extinguishes the trigger (465). No intermediate value: structural. + +**Conclusion.** Rationing = waiting for a better shot than the current one; only valuable if the policy recognises a good shot, i.e. if it aims. Constant miss ⟹ all shots equal ⟹ sooner is better. The dump is a symptom of comparisons/2026-08-17_agent-does-not-aim.md. + +**Rule:** never propose a penalty/cost on the trigger nor a reserve overhaul to treat the dump. Decide first with an offline probe on a checkpoint (p_fire and turret action as a function of canon ↔ nearest enemy angle): flat ⟹ perception lock (comparisons/2026-09-27_candidate-architecture-locks.md); dependent ⟹ reward shape (shot bonus). See comparisons/2026-10-27_ammo-economy-break-even-threshold.md, run 465, long cooldown refused. (see docs/decisions.md 2026-10-25 long cooldown refused; 2026-11-07 fire cost removed; 2026-11-09 fire-rate constraint refused) diff --git a/.claude/knowledge/comparisons/2026-11-03_aim-potential-shaping.md b/.claude/knowledge/comparisons/2026-11-03_aim-potential-shaping.md new file mode 100644 index 000000000..a649857e7 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-03_aim-potential-shaping.md @@ -0,0 +1,16 @@ +# Aim potential shaping γΦ(s′)−Φ(s) — implemented 2026-11-03 (removed same evening) + +Runs: 470, 471, 472, 473 (gates) + +2026-11-03: implemented — the developer proposes a potential shaping γΦ(s')−Φ(s) with Φ = aim quality of a theoretical shell (ballistic trajectory, most promising tank); judged a good idea (invariance, no camping, aim signal decoupled from firing); proposed design: ShellBallistics + AimScorer + AimPotential on the model side, PotentialShaping (γ) on the agent side, per-shell aim removed from the reward. **Code removed the same evening** (see comparisons/2026-11-03_potential-removed-shell-economy-to-design.md); Φ later re-implemented in other forms (see 2026-11-12 factored aim credit, Φ₂ in 2026-11-20 note) and finally removed (docs/decisions.md 2026-11-22). + +Context: bearing-not-decodable measurement (comparisons/2026-11-03_perception-lock-bearing-not-decodable.md: the CNN does not localise the enemy after 700 k steps); Claude had proposed a privileged auxiliary head, the developer preferred exploring a potential shaping (Ng 1999): F = γΦ(s') − Φ(s), Φ = max over enemies of the aim Cauchy of a **theoretical** shell fired now (same formula as the real reward). + +Physical facts (canon.cpp): shell speed = forward × 1.5e5 × f/20 = 250 m/s, tank speed not added, start at (0,0,10) in canon frame, gravity −9.8, life 20 s. Terrain = height map (relief, hence real line of sight) + 30 shapes; `JoltPhysicEngine::ray_test(from, to, excluded)` exists (private, used for contacts). + +Why good: invariance of optimal policy, constant Φ = −(1−γ)Φ per step so no camping (the September dense term was not a potential, see comparisons/2026-09-09_event-only-reward-refactor.md); Φ paid whether or not firing ⟹ breaks the « no fire → no aim signal → drifting turret » loop of runs 465 / 471 (fire cost, trigger extinguished); one-step credit for the turret; moving to obtain a firing line is rewarded. Not guaranteed: perception is still learned by policy gradient; **gate** = yaw decodable (`--features` + analyze_features.py) at save_1, else auxiliary head. +Proposed consequences: remove per-shell aim reward (shot bonus), keep hit/kill and shot_cost 0.03; Φ(terminal) = 0; Φ evaluated per decision (not per frame) at the observed instant. Design: model = ShellBallistics (trajectory, constant SHELL_SPEED shared with canon.cpp), AimScorer (tolerance + Cauchy extracted from JoltEnemyTank), AimPotential (trajectory truncated by ray_test, max of score) + `EnemyTank::get_aim_potential(tanks)`; agent = PotentialShaping (γ, Φ_prev per tank, reset) called in TrainTankEnvironment::step, logged in r_aim. +**The developer's decision (2026-11-03, 15:00): « okay on retire avec le reward de visée par obus » ⟹ implemented 2026-11-03.** Files: constants.h (SHELL_SPEED 250, GRAVITY 9.8; canon.cpp used 1.5e5·f/20, identical at 1/30), canon.h/.cpp `get_fire_pose()`, src/geometry.h (distance_to_segment), tank/ballistics.*, tank/aim_scorer.*, tank/aim_potential.* (polyline at 0.1 s truncated by `ray_test` excluding own bodies, max of score over living enemies), tank.h `get_aim_potential(tanks)` + `RewardDetail::shot` (sum_aim_quality removed), jolt_tank `get_body_ids()`, jolt_enemy_tank (reward = hit + received + death + shot, no more compute_aim_reward), agent core/potential_shaping.* (γ, scale 0.1, Φ_prev, terminal ⟹ 0), train_environment (ctor + gamma read from factory config, Φ per decision after read_states, logged in r_aim, Φ_0 taken in on_reset_physics **before** the 4 s settle), probe/e2e adapted. Tests: 86/86 model (ballistics, aim_potential, reward adapted), agent 2278 ok. Measured cost: +0.2 s per episode of 300 steps × 32 tanks (negligible). +Gates for the next run (472): yaw decodable from features at save_1, then p_fire vs best_angle at step ≥ 10, then hit/kill/D. Uncommitted: The developer runs pre-commit themself. +**Review 473 save_1 (2026-11-03, 19:00)**: tolerance 20° + shot_cost 0, gate still missed, see run 473 (tol 20°, shot_cost 0, gate missed). +**Review 472 save_1 (2026-11-03, 17:00)**: gate not reached, see run 472 (potential too narrow) — the 3° tolerance reused from the hit makes Φ null beyond ~10°, the potential must have its own wide tolerance (invariance ⟹ no bias). diff --git a/.claude/knowledge/comparisons/2026-11-03_perception-lock-bearing-not-decodable.md b/.claude/knowledge/comparisons/2026-11-03_perception-lock-bearing-not-decodable.md new file mode 100644 index 000000000..f16b0df17 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-03_perception-lock-bearing-not-decodable.md @@ -0,0 +1,19 @@ +# Perception « lock »: enemy bearing not decodable from actor features (470 save_6) — later corrected as a consequence + +Runs: 470 (save_0, save_6), 471 (save_1) + +Measurement 2026-11-03 (probe `--features`, bearing regression ← actor features): after 700 k steps (470 save_6) the yaw of the visible enemy is NOT decodable from features (RMSE 20° = std, AUC aligned<3° = 0.5, left/right AUC 0.68), identical to the untrained CNN. **Correction by the developer the same day: this is a consequence, not a lock** (see below). + +Tool: `arenai_agent_probe --features ` writes per decision (episode, step, tank) + the liquid output read by the heads (128) + the CNN output (384, spatial softmax x/y/presence per channel). `LiquidActorOutput` gained `features` and `vision_features` (internal struct src/networks/recurrent). Script analyze_features.py (session scratchpad): ridge, MLP 64 and logistic, split by episode, targets = yaw/pitch of the nearest enemy when in field (|yaw| < 39.5°, |pitch| < 22.5°, < 200 m), best_angle < 3°/6°. + +| network | yaw RMSE (std) | pitch RMSE (std) | aligned < 6° AUC | left/right AUC | +|---|---|---|---|---| +| 470 save_0 (init) | 24-29° (23°) | 10-12° (13°) | 0.49-0.61 | — | +| 470 save_6 (700 k) | 20-23° (20°) | 7.5-8.4° (8.7°) | 0.55-0.63 | 0.68 | +| 471 save_1 (108 k) | 29-47° (25°) | 7-9° (10°) | 0.63-0.86 (n=8 positives, noise) | — | + +By distance (470 s6): 0-40 m RMSE 18-26° for std 20° ⟹ even a 25-px-wide tank is not localised. Positive controls: μ_canon_x decoded R² 0.98 (the method works); shell ratio (in the proprio!) R² 0.03: the liquid does not even keep this input. + +**Initial reading:** result explaining the previous weeks (comparisons/2026-08-17_agent-does-not-aim.md, run 467 probe flat trigger / weak turret, run 470 15-s episode, run 471 shot_cost 0.03): the policy has only a vague left/right (corr yaw/μ_cx −0.28) and no notion « target on axis », so no selectivity is expressible whatever the reward; hit 6-9 % is spraying at 32 tanks. The only gradient reaching the CNN is the policy gradient (rare, noisy, delayed advantages): in 700 k steps it learned nothing beyond random init. +**Correction 2026-11-03 (the developer):** this is NOT a CNN lock: the same network converged (aimed, fired) with shell regen (405-429). The measured undecodability is the consequence of the absence of events since 2026-10-23 (comparisons/2026-10-29_event-density-collapsed-since-10-21.md). Auxiliary head refused (the CNN had already converged). (see docs/decisions.md 2026-11-03: auxiliary head refused, lifted 2026-11-23; 2026-11-10 perception ruled out) +**Rule:** keep probe `--features` + analyze_features.py as a measurement (it says whether aim is learned), but do not deduce an architecture change from it. diff --git a/.claude/knowledge/comparisons/2026-11-03_potential-removed-shell-economy-to-design.md b/.claude/knowledge/comparisons/2026-11-03_potential-removed-shell-economy-to-design.md new file mode 100644 index 000000000..97f8bcb2a --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-03_potential-removed-shell-economy-to-design.md @@ -0,0 +1,11 @@ +# Potential shaping removed; shell economy to design (2026-11-03) + +Runs: 465, 471, 473, 474 (next), 405-429 (regen era reference) + +2026-11-03 evening: The developer rules « le problème vient du reward et de l'économie des obus »; all potential-shaping code removed (AimPotential/AimScorer/Ballistics, PotentialShaping, phi, env gamma, progress-bar flag); remaining reward = hit 0.3 / kill 2 / received −0.2 / death −1 / empty −0.5, shot_cost 0 (mechanism kept), reserve 10 +10/hit max 30; economy to design keeping a limited reserve (no regen). + +Removal done 2026-11-03, committed by the developer (088ff389 « remove potential reward »; the developer does the final verification): deleted aim_potential.*, aim_scorer.*, ballistics.*, tests_aim_potential.*, tests_ballistics.cpp, potential_shaping.*, tests_potential_shaping.cpp; `EnemyTank::get_aim_potential` and `JoltTank::get_body_ids` removed; TrainTankEnvironment without gamma nor `phi` metric; flag `print_in_progress_bar` removed (as the developer did 2026-10-26: no new metrics in the progress bar). Kept: probe `--features`/AimGeometry, geometry.h (distance_to_segment serves miss), SHELL_SPEED/GRAVITY/get_fire_pose (canon uses them), `RewardDetail::shot` + shot_cost 0, column r_aim (0 now). Build ok, model 78/78, agent 2275 ok. + +Framework set by the developer: no auxiliary head (the CNN had already converged), no long cooldown (refused), limited reserve kept (no passive regen), the lever is the reward and the shell economy. What regen gave (405-429): 10 + 0.67/s × 30 s ≈ 30 shells per life, 2-3 hits per life at 7-9 %, 11 kills/episode; today 10 shells, 0.5 hit per life (comparisons/2026-10-29_event-density-collapsed-since-10-21.md). + +**Constraints on any economy proposal:** (1) do not extinguish the trigger (immediate cost vs rare gain = 465/471), (2) restore the hit density of the regen era, (3) make a shell valuable only when aim exists (break-even refund/cost ≈ blind hit, comparisons/2026-10-27_ammo-economy-break-even-threshold.md). Validated by the developer 2026-11-03 (« Réserve 30, +20, sans mort à vide ») and applied, uncommitted: jolt_enemy_tank.cpp initial_nb_shells 30, shells_recharged_per_hit 20, max_shells 60, flag out_of_shells and death at empty reserve removed (is_suicide = returned only, death −1 without the −0.5 case), test EmptyReserveDoesNotKillInTraining; model 78/78, agent 2275 ok. Break-even 1/20 = 5 % = blind shot; proprio stays nb/max (max 60). Next run = 474, to compare with 417-419 (hits/life, kills/episode) and probe `--features` at save_1/save_2. Follow-up: comparisons/2026-11-03_scarcity-economy-tied-to-competence.md. (see docs/decisions.md 2026-11-22 potential Φ removed) diff --git a/.claude/knowledge/comparisons/2026-11-03_scarcity-economy-tied-to-competence.md b/.claude/knowledge/comparisons/2026-11-03_scarcity-economy-tied-to-competence.md new file mode 100644 index 000000000..d3faeada5 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-03_scarcity-economy-tied-to-competence.md @@ -0,0 +1,17 @@ +# Shell economy « scarcity tied to competence » — validated and implemented 2026-11-03 (run 475) + +Runs: 474 (premise), 475 + +2026-11-03 evening, validated and implemented (uncommitted): reward unchanged, zero fire cost, reserve/refund/max driven by the ADR curriculum (30/20/60 → 8/5/16), γ 0.995, no death at empty; 3 computed facts: scarcity teaches nothing to a blind agent, refund 20 = free spam (p·k ≥ 1 from 5 %), γ 0.99 makes restraint irrational even for an agent that aims. + +Context: The developer (2026-11-03) « soit il spam pour apprendre à tirer, soit il apprend rien », asks for a new economy; criteria: limited reserve, learn that shooting blindly is useless, no spam, a way to regain shells. See comparisons/2026-11-03_potential-removed-shell-economy-to-design.md, run 474. + +**Three facts from the analysis (back-of-envelope model, to verify on a run):** +1. A shortage cannot teach anything to an agent whose p(hit) does not depend on state: keeping a shell = waiting for a better shot, which does not exist for it; and any fire cost that would bite extinguishes the trigger (345/465/471). So scarcity must **follow** competence, not precede it. +2. Refund k per hit: spam is self-financed as soon as p·k ≥ 1. At blind p 5-7 % and k = 20 (474), the reserve is infinite while density holds ⟹ permanent dump of 474. Need k < 1/p_blind ≈ 14 **eventually**, but k ≈ 20 at start = regen equivalent. +3. γ 0.99 at 10 Hz: keeping a shell for an aligned+close shot (50 %, visited ~1 time/8 s) is worth 0.15·Σγ^{80i}. N = 30: dump 0.5 vs keep 0.27 (0.99) / 0.45 (0.995) / 0.70 (0.997). N = 8: dump 0.15 vs 0.27 / 0.44 / 0.6. ⟹ small reserve **and** γ ≥ 0.995. +Corollaries: the 8-9 % hit ceiling of the regen era is the signature of « always fires » (1.2 % aligned+close shots at 50 %), not an aim ceiling; the spawn-curriculum threshold 0.06 is the chance level at 32 tanks, D advances on luck. + +**Proposal:** event reward unchanged (hit 0.3 / kill 2 / received −0.2 / death −1 / win 2), `shot_cost` removed; (N0, k, M) = f(progress) of the existing ADR controller (SpawnCurriculum), linear 30/20/60 → 8/5/16, thresholds ratio_high 0.10 / ratio_low 0.07; first run D frozen 250 (one variable); γ 0.995; no death or truncation at empty, starvation 30 s kept; proprio nb_shells / 60 (constant, not / current max). Code: ammo parameters via JoltEnemyTank constructor and the factory (public interface ⟹ the developer validation), progress → ammo mapping in main/train_environment, model tests. Success: progress rising with hit/fire > 0.10 at D 250, fire/s falling while kill/episode holds, probe p_fire vs best_angle not flat at step ≥ 10. + +**Validated and implemented 2026-11-03 evening** (the developer: « fais le et fais le curriculum sur D en même temps »). A single ADR progress (`SpawnCurriculum`, unchanged) mapped in train.cpp onto spawn AND `model::ShellEconomy` (struct in constants.h, rounded lerp); `GAME_SHELL_ECONOMY` 8/5/16 = default of flags `--final_shells/--final_shells_per_hit/--final_max_shells` and desktop game economy; `--initial_*` 30/20/60; `make_enemy_tank` and `BaseTanksEnvironment::reset` take the economy; proprio = nb_shells / `PROPRIOCEPTION_SHELL_SCALE` (60); `RewardDetail::shot` and `shot_cost` removed; γ 0.995 in the 3 hyperparams (ppo, ppg, liquid); curriculum thresholds 0.07/0.10; probe flags `--shells/--shells_per_hit/--max_shells`. Pitfall: `curriculum_delta` stays in metres on the spawn side, so final_spawn = initial_spawn also freezes ammo. Tests: model 79/79 (incl. ShellEconomyParametersAreApplied), core 27 + golden skip, agent/desktop ok. (see docs/decisions.md 2026-11-06 slow regeneration refused; 2026-11-09) diff --git a/.claude/knowledge/comparisons/2026-11-04_centred-shot-reward-baseline.md b/.claude/knowledge/comparisons/2026-11-04_centred-shot-reward-baseline.md new file mode 100644 index 000000000..333ceac14 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-04_centred-shot-reward-baseline.md @@ -0,0 +1,15 @@ +# Per-shell reward centred on its running mean (ShotBaseline), run 477 + +Runs: 465, 467, 471, 473, 476, 477 + +2026-11-04 — per-shell reward centred on its sliding mean (ShotBaseline, window 4096 shells) + Cauchy 2.5 m + 3° × 0.1 restored, kill left raw (hit 0.3 per hit, kill +1.7); ammo curriculum removed, fixed economy 10 / +10 / max 30; run 477 to compare to 476. + +2026-11-04, after the failure of all « fixed cost / economy / ADR » variants (465-476), the developer first rejected the p_fire clamp, the asymmetric critic and the teacher-student (« béquilles », « je veux de vrais leviers sur le reward »), then validated the reward lever alone: + +- **Diagnosis**: expected value of a shot negative (465, 471) ⟹ trigger absorbed to 0; positive (467, 473, 476) ⟹ dump. Only stable value: zero, which no fixed cost holds since the mean gain moves with the policy (8 % spam → 50 % aligned). Credit delay not at fault (flight ~0.15 s at 250 m/s, 1-2 steps). +- **Coded**: `ShotBaseline` (arenai_agent/src/core) = exact mean up to `window` shells then EMA; in `TrainTankEnvironment::step`, `rewards[i] -= b × nb_landed_shells`, centred channel g = aim + hit (kill raw). `RewardDetail` now has `aim`, `hit` (0.3 per hit, kills included), `kill` (1.7 more ⟹ 2.0 total unchanged). Constants `HIT_REWARD`/`KILL_REWARD` in constants.h. Cauchy taken from 3c2d540c: tol 2.5 m + 3°, scale 0.1 (turret gradient on every shell, not only the 8 % of hits). +- **CSV only** (no progress bar): `r_aim`, `b` via `get_csv_only_metrics()`, without flag `print_in_progress_bar` (removed). +- **Economy**: ammo curriculum (interpolate, initial_/final_) removed; a single `ShellEconomy` 10 initial / +10 per hit / max 30 for game, train (`--shells`, `--shells_per_hit`, `--max_shells`) and probe; proprio = nb_shells / max_shells (no more `PROPRIOCEPTION_SHELL_SCALE`). γ 0.995 and spawn ADR thresholds 0.05/0.08 kept. +- `--shot_baseline_window` 4096 shells (~3-4 rollouts at 32 tanks). + +**Announced success criterion**: probe p_fire depending on angle at step ≥ 10; time before empty reserve lengthening without fire falling to 0.02/s. Listed risks: EMA too short, dump by inertia (neutral shot), noisy kill (hence raw kill). See runs 476 (trigger saturated, ADR plateau), comparisons/2026-11-02_ammo-dump-is-the-reward-optimum.md, run 471 (shot_cost, trigger extinguished). (see docs/decisions.md 2026-11-06 hit reward from closest miss distance removed; 2026-11-22 Φ removed) diff --git a/.claude/knowledge/comparisons/2026-11-11_peak-does-not-hold-critic-leads-actor-follows.md b/.claude/knowledge/comparisons/2026-11-11_peak-does-not-hold-critic-leads-actor-follows.md new file mode 100644 index 000000000..b1dc37e0d --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-11_peak-does-not-hold-critic-leads-actor-follows.md @@ -0,0 +1,21 @@ +# Hit/shell peak does not hold: the critic leads, the actor follows (analysis of 500/501/502) + +Runs: 500, 501, 502 (context: run 502 at 688 k, canon_x brought back, competence not returned) + +Analysis requested by the developer 2026-11-11 (hyperparameters + reward). Finding: the hit/shell peak (22 % at D=1000) is undone because the critic's `ev` drops (0.5 → 0.2-0.3) on reaching D=1000 in all 3 runs and Δev precedes Δhit by 10-20 k (corr +0.4 at lag 1-2, ~0 at lag 0); the actor advances at constant speed (76 Adam steps/rollout, kl 0.02, clip 0.25, normalised advantages) on critic noise; σ frozen at the ceiling by a hard clamp (zero gradient) ⟹ drift goes into saturated μ (tanh attractor); the turret (credit via critic) lets go before the trigger (direct credit < λ horizon 1.8 s). + +**Effective reward (code read):** hit +3 × damage fraction (0.2/hit ⟹ +0.6), kill +1, received −0.2/hit, death −1, aim shaping 0.3·(γΦ(s′)−Φ(s)) with Φ = Cauchy(2.5 m + 3°·d) of the minimal approach of a predicted shell (gravity + ray_test, 20 s flight); no fire cost; reserve 10, +2/hit, max 20, empty reserve ⟹ respawn full life (truncated, no penalty). Symmetric self-play: r_rcv = −r_hit/3 exactly. Φ̄ ≈ 0.1 (deduced from r_aim = −0.15e-3 = 0.3·(γ−1)·Φ̄); variance of ΔΦ not measured (CSV = mean only). Density at D=1000: one hit / 300 decisions / tank, 3-8 kills per 32-tank episode. + +**Hyperparameters (computed effects):** rollout 300 × 32 = 9600 correlated rows, chunk 30, batch 512 ⟹ 19 minibatches × 4 epochs = 76 Adam steps actor and critic per 30 s rollout; lr 1e-4 / 3e-4 constant; kl 0.015-0.025 per rollout (target 0.05 never bites, skip = isolated minibatches > 0.075); clip fraction 0.2-0.29; advantages normalised per rollout (noise rescaled to 1 when the signal vanishes); GAE λ 0.95 at 10 Hz ⟹ direct credit horizon 1.8 s (shot → impact 0.5-1 s inside, aim seconds earlier = via the critic); γ 0.995 ⟹ 20 s; σ: Linear → torch::clamp(ln σ) → exp, **hard clamp = zero gradient at the ceiling**, 80-98 % of states at σ = 0.700 exactly ⟹ σ frozen, α (floor 0.001, negligible against advantages of scale 1) only regulates μ; CSV Hc = mean over dims (masks saturation of one dim). + +**Measurements:** +- ev oscillates 0.3-0.55 all run; on reaching D=1000 it drops in the 3 runs (500: 0.45 → 0.32; 501: 0.54 → 0.29; 502: 0.52 → 0.18, deepest trough of the run); v (loss) also falls (0.07 → 0.013) since return variance drops (r_hit ÷2). +- corr(Δev_t, Δhit_t+k) (k = 0, 1, 2 windows of 10 k): 502 +0.03 / +0.39 / +0.38; 501 −0.07 / +0.38 / +0.45; 500 +0.23 / +0.08 / +0.31 ⟹ **critic drop precedes hit drop by 10-20 k**. corr(ev, hit) level +0.4-0.5; corr(ev, r_hit) inconsistent (−0.09 / −0.33 / +0.39) ⟹ ev is not only event density. +- Intermediate D jumps do not systematically break ev (only 500 D→700 and D→1000) ⟹ not the curriculum itself: the critic oscillates and the actor follows. +- Probes 502: at each drift, |μ| of one dim heads to saturation (canon_x 0.40 → 0.77 → 1.17), the turret lets go (aligned shots 5.8 → 1.3 %) while the trigger ratio holds (16.9 → 10.2 → 6.4); armed 83 → 58 → 43 % of decisions (dump returns when aim leaves). + +**Mechanism retained:** when ev drops, normalised advantages are critic noise at scale 1; the actor still advances at constant speed (76 steps, kl 0.02/rollout, no decay) ⟹ random walk (already seen in 418/419). It goes toward saturated μ because σ is frozen and nothing brings μ back (target 0 acts only after crossing, 50-75 k later). Aim, credited via the critic, leaves first; the trigger, credited directly, keeps its selectivity. The peak is reached when the critic is at its best (ev 0.5), just before D=1000 changes the distribution and digs ev. + +**Ruled out:** KL regime (kl ≪ target), σ (frozen, invariant), event rarity alone, seed noise for the peak/ev-trough coincidence (present in the 3 runs at the same place). + +**Candidate levers (to discuss, nothing applied):** (1) actor speed tied to signal (decaying lr/epochs, or no per-rollout advantage normalisation but a sliding scale); (2) soft σ ceiling (sigmoid/tanh parametrisation of log σ) so σ carries entropy again (⟹ SoftClamp, see comparisons/2026-11-11_softclamp-sigma-soft-bound.md); (3) critic: stability before the actor (lr, epochs, capacity, or actor freeze if ev < threshold); (4) measure sd(ΔΦ) in CSV-only to quantify shaping noise; (5) free respawn at empty reserve = incentive to dump under fire. diff --git a/.claude/knowledge/comparisons/2026-11-11_probe-step-is-0-1-s-not-0-3.md b/.claude/knowledge/comparisons/2026-11-11_probe-step-is-0-1-s-not-0-3.md new file mode 100644 index 000000000..5c399b4bd --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-11_probe-step-is-0-1-s-not-0-3.md @@ -0,0 +1,12 @@ +# Probe step = one decision = 3 frames at 30 Hz = 0.1 s (old script converted ×0.3) + +Runs: 502 and earlier probe-based notes + +2026-11-11 — one probe step = one decision = 3 frames at 30 Hz = 0.1 s; the script probe_an.py converted ×0.3 ⟹ every « empty reserve » in seconds written in memory before 2026-11-11 is ×3 too large (65 s = 22 s). + +arenai_agent_probe: `step++` once per `env->step`, which plays action_repeat = 3 frames of wanted_frequency = 1/30 s ⟹ 0.1 s per step (1801 steps = max_episode_steps 5400 frames). The probe script reused from session to session multiplied by 0.3. + +**Why it matters:** the figures « reserve 65 s / 89 s / 37.6 s » (cruise metrics at D1000 hit/shell dump note; run 502 600k verdict) remain comparable to each other but are worth ÷3. + +**Rule:** convert step × 0.1 s; to compare with an old value, divide it by 3 or compare in steps. +(pitfall candidate for a skill/doc: probe step unit = 0.1 s; belongs in `probe-checkpoint` skill) diff --git a/.claude/knowledge/comparisons/2026-11-11_softclamp-sigma-soft-bound.md b/.claude/knowledge/comparisons/2026-11-11_softclamp-sigma-soft-bound.md new file mode 100644 index 000000000..b8d1968d0 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-11_softclamp-sigma-soft-bound.md @@ -0,0 +1,13 @@ +# SoftClamp — soft σ bound replaces the hard clamp (run 503 first user) + +Runs: 500, 501, 502, 503 (first with SoftClamp), 504 + +2026-11-11 — hard σ ceiling (torch::clamp, zero gradient, 80-98 % of states at σ = 0.700) replaced by SoftClamp = lower + (upper − lower)·sigmoid(z) in misc.h/.cpp, wired on the σ head of both actors (actor.cpp, liquid_actor.cpp) with inverse init (SoftClamp::inverse) to start from initial_sigma; same bounds LOG_SIGMA_MIN/MAX; action noise σ 0.7 ≈ ±11°/decision vs tolerance 3°; **503 already runs with SoftClamp** (binary linked 02:40:58 after sources 02:36, actor_repr.txt confirms); saves ≤ 502 probed with the new binary give a wrong σ. + +Option 1 of the 2026-11-11 discussion (peak-does-not-hold note, comparisons/2026-11-11_peak-does-not-hold-critic-leads-actor-follows.md), requested by the developer: « fais le un dans une nouvelle classe SoftClamp ». Uncommitted. + +**Code:** `SoftClamp(lower, upper)` in networks/misc.h/.cpp (same scheme as ConcentrationOutput), forward = lower + (upper − lower)·sigmoid(x), `SoftClamp::inverse(value, lower, upper)` = logit bounded at 1e-4; `init_log_sigma_output_weights` sets the bias to inverse(ln σ0, LOG_SIGMA_MIN, LOG_SIGMA_MAX); σ head = Linear → SoftClamp → Exp in Actor and LiquidActor. Tests: SoftClampModuleParamTest (strict bounds, 0 → middle, gradient > 0 everywhere, round-trip inverse). Class Clamp stays (tests). + +**Why:** `torch::clamp` has zero gradient outside bounds ⟹ σ at the ceiling is an absorbing state, α regulates only μ. Moreover σ_max 0.7 before tanh ≈ action std 0.6 ≈ ±11° per decision (turret π rad/s = 18°/decision at 10 Hz) for a tolerance of 3° + 2.5 m: saturating μ was the only remaining route to precision (at μ = 1.5 action std falls to 0.13). SoftClamp makes descent possible, does not change the incentive to rise nor the ceiling value (option 2 = lower σ_max, option 4 = Beta law, not done). + +**Pitfall:** Clamp and SoftClamp have no parameters ⟹ old checkpoints load, but the pre-activation is interpreted differently: **do not probe saves ≤ 502 with a SoftClamp binary** (503 has it ⟹ probe build/ valid; check `actor_repr.txt` of a save: Clamp vs SoftClamp) (σ wrong), like convert_mu_linear (run 501 second verdict, μ at bounds). To read on 503 (first run with SoftClamp, confounded with batch 9600 + lr ×5): fraction of states at σ ≈ 0.7 at probe (former 80-98 %), median canon σ, and whether |μ| still drifts to the bounds. See σ ceiling 0.7 (run 501), run 503 (full-rollout batch, lr 5e-4). (see docs/decisions.md 2026-11-08: state-dependent σ soft-clamped since 11-11) diff --git a/.claude/knowledge/comparisons/2026-11-12_aim-diagnosis-mu-white-noise.md b/.claude/knowledge/comparisons/2026-11-12_aim-diagnosis-mu-white-noise.md new file mode 100644 index 000000000..abd683ee2 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-12_aim-diagnosis-mu-white-noise.md @@ -0,0 +1,20 @@ +# Aim diagnosis: turret jitters through μ itself (state white noise), not σ + +Runs: 507 (save_5/9/12), 508 (save_5/9) + +2026-11-12: the turret agitates through μ itself (state white noise, std 0.44 ≈ 8°/decision) and not through σ (5°); 4-14 % of var(μx) explained by yaw, growing over saves; single scalar advantage for 6 dims (ppo/ppo_liquid/ppg identical). + +Measured on probes side 550 (507 save_5/9/12, 508 save_5/9): +- clean plant under stabiliser: action t → +9.3° at t and +9.0° at t+1 (18°/unit); 507 (2 Hz) spread 0.8/5.2/6.0° over 3 decisions ⟹ the Φ shaping of 507 paid action t for gestures of t−1/t−2. +- std tanh(μ_canon_x) 0.21 → 0.46 (507), 0.30 → 0.44 (508); autocorr μx(t,t+1) 0.09 at 508 save_9; share explained by yaw 0.04-0.14; μ_y same (R² 0.01-0.14). +- wanted correction k = 0.044 of the gap/decision; off-command perturbation 5.9-7.4°/decision. + +Code: single normalised GAE advantage, joint ratio of the 6 dims, common clip, in the 3 trainers; Φ shaping (0.3) in r_t. + +**Why:** the aim lock after run 508 (stabiliser); same mechanism as comparisons/2026-11-11_peak-does-not-hold-critic-leads-actor-follows.md (random walk of the actor). + +Levers proposed 2026-11-12 (nothing decided): temporal smoothing of μ (CAPS), separate advantage for aim dims (critic with heads per reward component), re-test stronger Φ now that credit falls on the right step, absolute command to reopen cautiously. + +**Measurement 2026-11-12 evening (outputs/train_508_ppo_liquid/gradients/save_9.md, sigma_gradients tool enriched with u, reward decomposition, geometry):** ρ = corr(A, ε·d) of the trainer's advantage = 0.003-0.02 (t/minibatch < 0.5); Φ at the same step responds at 0.10-0.13; ρ decreases monotonically with λ (Φ alone turret 0.116 → 0.005 from λ 0 to 0.95); separate aim advantage at λ 0.95 = also null ⟹ lever B as is refuted, the source is the credit horizon, not the reward mix. Pitfall: elevation sensitivity ∝ cos(yaw), filter |yaw| < 10°; probe columns already in degrees; yaw to fold ±180°. + +**Causal test 2026-11-12 19:20-20:05 (outputs/train_508_ppo_liquid/finetune/verdict.md, tool arenai_agent_aim_finetune + LiquidPpoTrainer::train_actor, uncommitted):** 40 updates from save_9, critic frozen, 2 trials/arm: GAE λ 0.95 advantage ⟹ tour<5° 8.3/13.6 % (start 13.1); immediate Φ ⟹ 18.8/18.1 %, best_angle 22 → 12-14°, μx bias removed. Horizon = causal lock demonstrated. But nearest < 5° unchanged (Φ rewards any enemy) and hit/shell not better (confounded: Φ also applied to fire/driving, p_fire 0.27 → 0.16). diff --git a/.claude/knowledge/comparisons/2026-11-12_aim-diagnosis-range-and-out-of-field.md b/.claude/knowledge/comparisons/2026-11-12_aim-diagnosis-range-and-out-of-field.md new file mode 100644 index 000000000..b2b4a14ca --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-12_aim-diagnosis-range-and-out-of-field.md @@ -0,0 +1,16 @@ +# Aim diagnosis: hit/shell ceiling = information + geometry (range, out-of-field) + +Runs: 504, 507 + +2026-11-12: lineage hit/shell ceiling = information + geometry: hits < 50 m at 40-60 %/shell, > 100 m at 7-10 %; close enemy out of field 65-70 % of the time; proposals P0 oracle, P1 radar/360 camera, P2 D 500 / area damage, P3 elevation aid. + +Established on probes 504/507 (save_2 to 16, + deterministic): +- hit/shell by target distance: < 50 m 39-53 % (60-77 % aligned < 5°), 50-100 m 11-16 %, > 100 m 4-10 % (aligned 12-22 %); 60 % of shots aim > 100 m. +- nearest enemy < 100 m in 52-91 % of decisions, in field ±40° 31-35 % (chance 22 %), median bearing 65-87° ⟹ the turret does not turn toward it; the proprio contains no enemy, camera = canon (looking = aiming). +- deterministic ≈ stochastic (tour<5° 17.7 vs 14.5 %): not a noise problem. +- elevation: yaw-aligned on the nearest, |pitch| < 2° only 18-25 % (terrain 200 m relief). +- Φ (max over all enemies) pays the far lottery. + +**Why:** ~100 runs of tuning (entropy, σ, critic, economy, shaping) touched neither information, geometry nor elevation. + +Proposed to the developer 2026-11-12 (nothing decided): P0 oracle in the probe (game ceiling by distance, with/without elevation aid); P1 radar K enemies in the state (distinct from the refusal of duplicating vision observation: info absent from vision) or 360° hull camera; P2a bounded curriculum D 500, P2b area damage; P3 assisted elevation if P0 designates it; remove/restrict Φ. Report: outputs/comparisons/2026-11-12_diagnostic_visee_refonte.md. (see docs/decisions.md 2026-11-03: alignment/target info in proprioception refused; 2026-11-23/25 panorama/presence head validated later) diff --git a/.claude/knowledge/comparisons/2026-11-12_aim-oracle-p0.md b/.claude/knowledge/comparisons/2026-11-12_aim-oracle-p0.md new file mode 100644 index 000000000..f60cdcc3e --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-12_aim-oracle-p0.md @@ -0,0 +1,46 @@ +# Aim oracle (P0) — game ceiling and value of perception + +Runs: 507 (save_12 policy used for movement and zoom). +Date: 2026-11-12. `arenai_agent_probe --oracle` (build/ binary of 2026-11-12 ~13:40). All tanks use the oracle, which slaves turret and cannon to the nearest living enemy within a cone of `--oracle_fov` around the cannon axis: gain 0.3 per decision (the hinge position motor lags by about 2 decisions), ballistic drop compensation, no movement anticipation. It fires when the error is < 1° in yaw and elevation. With no target in the cone, the policy turns the turret and does not fire. Movement and zoom: policy of 507 save_12. 4 episodes × 32 tanks per configuration, economy 10 / +2 / 20. Raw data: `outputs/oracle/` (`oracle__side<550|1000>.{csv,log}`, `*_shots.csv`, `attitude_side*.{csv,log}`, `attitude_side550_det.*`). + +## Results + +hits/tank/min (throughput) and hits per shell: + +| configuration | side 550 | side 1000 | +|---|---|---| +| policy 507 save_12 | 5.4 (19 %) | 1.9 (12 %) | +| oracle 45° (zoomed field) | 10.7 (45 %) | 7.5 (26 %) | +| **oracle 80° (current camera)** | **11.0 (50 %)** | **8.5 (29 %)** | +| oracle 120° | 12.3 (47 %) | 10.3 (34 %) | +| oracle 180° | 14.2 (51 %) | 10.6 (36 %) | +| oracle 360° | 14.7 (53 %) | 11.5 (41 %) | +| oracle 360°, policy elevation | 8.3 (25 %) | 5.0 (16 %) | +| oracle 360°, target at image centre | 13.8 (48 %) | 11.4 (36 %) | +| oracle 80°, target at image centre | 11.6 (40 %) | 8.4 (29 %) | + +hit/shell of a perfectly aimed shot by target distance (360°, sides 550 / 1000): < 50 m 97 / 94 %, 50-100 m 71 / 72 %, 100-200 m 36 / 42 %, > 200 m 15 / 9 %. + +## What it settles + +1. **Perception explains only a small part of the gap.** With the current camera (80°), a perfect shooter does 2× (side 550) to 4.4× (side 1000) better than the policy. Going to 360° then adds only +34-36 %. Most of the gap is aiming precision, not what is out of field. +2. **Elevation is the main cause.** Perfect yaw + policy elevation brings throughput back to 8.3 / 5.0 and hit/shell to 25 / 16 %, close to the policy (19 / 12 %). The policy loses mainly its shots in elevation. Consistent with the probe: yaw aligned on the near enemy, |elevation error| < 2° only 18-25 % of the time. +3. **Camera parallax costs a lot at short range.** The camera is at (0, 4, −20) in the cannon frame and aims at the point 100 m along the axis; `CollisionCamera` moves it closer further when terrain obstructs. A shooter that centres the target in the image (instead of the firing axis) drops from 93-99 % to 61-70 % under 50 m and from 71-77 % to 53-66 % between 50 and 100 m. That is exactly the zone where hits are made. Total throughput moves little here because the oracle is perfect beyond, but for an agent learning "target at centre", the visual landmark is wrong at every distance except 100 m. +4. **Beyond 200 m the game caps at 9-15 % even with a perfect shot**: moving target, flight time, no anticipation. More resolution would only pay on these targets. +5. Side finding: the hinge position motor lags by about 2 decisions. A single-decision command turns the turret only 19-37 % of its nominal travel during that decision, the rest arrives afterwards (steady state: 18°/decision, nominal). + +## Origin of the agent's elevation error (probe 507 save_12, attitude columns added) + +Decisions where yaw is aligned (< 3°) on the nearest enemy, between 10 and 130 m. Error e = T − C − R, with T the world elevation of the target, C the elevation the chassis attitude gives the cannon, and R the elevation commanded by the agent (chassis-relative). + +| side 550 (1000) | std | \|e\| < 2° | +|---|---|---| +| stochastic agent | 10.9° (11.9°) | 19 % (17 %) | +| deterministic agent | 9.7° | 24 % | +| cannon frozen relative to chassis, no command at all | 8.0° (7.6°) | 21 % (20-23 %) | +| cannon stabilised to the horizon, no command at all | 5.5° (4.8°) | 28 % (36 %) | + +- The elevation need (T − C, std 8°) comes mostly from chassis attitude (C: std 8°, median pitch 6°, roll 4.6°), more than from target position (T: std 5°). +- The agent follows this need slowly (corr 0.5, slope 0.8) but adds its own agitation of about 10° std unrelated to it. Decision by decision, it does not compensate chassis movements (corr(ΔR, −ΔC) = 0.04-0.07). +- Result: its elevation command is worth no more than a frozen cannon (21 %), stochastic as deterministic. So it is not exploration noise. +- A cannon stabilised in the world, with no elevation command at all, would already do 1.5 to 2× better than the agent (28-36 % versus 17-19 %) and reduce the target to follow to std 5°. diff --git a/.claude/knowledge/comparisons/2026-11-12_aim-overhaul-diagnosis-potential-507.md b/.claude/knowledge/comparisons/2026-11-12_aim-overhaul-diagnosis-potential-507.md new file mode 100644 index 000000000..4cb5118ea --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-12_aim-overhaul-diagnosis-potential-507.md @@ -0,0 +1,85 @@ +# Aim — conclusion of the 10° potential lever (507) and diagnosis for an overhaul + +Runs: 504, 507. +Date: 2026-11-12. Sources: probes 504 save_2/5/9/12/16 (+ deterministic save_16/18) and 507 save_2/5/9/12, sides 550 and 1000, 4 episodes × 32 tanks. Code re-read: `train_environment.cpp`, `jolt_enemy_tank.cpp`, `environment.cpp` (arena), `liquid_ppo_trainer.cpp` (GAE). + +## 1. The 10° potential lever (507): inconclusive for its objective + +Announced objective: a better-aligned turret (threshold fixed before the run: turret<5° > 18 %). + +| save (index) | turret<5° 507 / 504, side 550 | side 1000 | slope μ_cx/10° 507 / 504 (550) | +|---|---|---|---| +| 2 (54 k) | 9.0 / 10.0 % | 6.0 / 9.9 % | 0.036 / 0.030 | +| 5 (135 k) | 13.2 / 13.8 % | 9.6 / 12.7 % | 0.051 / 0.057 | +| 9 (243 k) | 14.9 / 12.5 % | 13.4 / 10.1 % | 0.076 / 0.062 | +| 12 (324 k) | 13.9 / 14.5 % | 11.6 / 13.1 % | 0.116 / 0.085 | + +- Alignment is the same over 4 saves. The corrector is stronger at save_12 (+35 %) with no effect on turret<5°. +- 507 leads at save_12 on the trigger (ratio 8.7 / 13.6, reserve 21-28 s, hit/shell 18.7 / 11.8 %), but 504 made the same transition at save_9 before falling back. The economy oscillates in both runs: seed noise, not an attributable effect. +- Verdict: the potential does not improve aim. The mechanism is partly explained in §2: Φ pays alignment on the best-aligned enemy wherever it is, hence mostly targets at 200-400 m that are almost never hit. + +## 2. What the probes establish (504/507 lineage, identical in both runs) + +**F1 — Hitting is a short-range matter.** Hits per shell by distance of the aimed target (side 550, 504 save_12 / 507 save_12): + +| target | share of shots | hit/shell | hit/shell if aligned < 5° | +|---|---|---|---| +| < 50 m | 21 / 29 % | 39 / 41 % | 60 / 61 % | +| 50-100 m | 16 / 14 % | 11 / 11 % | 25 / 23 % | +| 100-200 m | 24 / 21 % | 7 / 10 % | 13 / 22 % | +| > 200 m | 39 / 35 % | 7 / 10 % | 12 / 16 % | + +Beyond 100 m, even a shot aligned to 5° misses 8 times out of 10: a tank spans ~1° at 200 m, and the 256 px camera for 90° gives 0.35°/px. + +**F2 — The near enemy is almost always out of view.** The nearest enemy is within 100 m in 52-91 % of decisions. It is in the camera field (±40°) in only 31-35 % of cases, barely above chance (22 %), and within 10° in 13-15 %. Its median bearing is 65-87°: the turret does not turn toward it. 88-91 % of shots are fired while an enemy is within 100 m, but 60 % aim at a target beyond 100 m. + +**F3 — The agent cannot know where the near enemies are.** The only perception is the cannon-mounted camera (90° × 45°). Proprioception contains no enemy, and the liquid memory has a time constant of about 0.6 s. Finding the near enemy requires sweeping with the cannon, i.e. misaligning the weapon. Looking and aiming are the same action. + +**F4 — Not exploration noise.** 504 save_16 deterministic: turret<5° 17.7 % versus 14.5 % stochastic. The policy mean itself does not centre. + +**F5 — Elevation (hausse) is a second lock.** When yaw is aligned (< 5°) on the near enemy (~40 m), the elevation error is −10 to +16° (p10-p90) and is under 2° in only 18-25 % of cases. The terrain has 200 m of relief over 2 km (`heightmap6`, scale 10 × 200 × 10). + +**F6 — The reward rewards the far lottery.** hit and kill are worth as much at 300 m as at 30 m. Φ takes the max over all enemies, so it pays pointing at the far pack that fills the field. The curriculum pushes D toward 1000, hence toward this regime. + +**Overall reading.** The bulk of possible hits (< 50 m, 40-60 % per shell) is out of view 2 times out of 3. What is visible is mostly far and hit at 7-10 %. The ~100 tuning runs (entropy, σ, critic, economy, shaping) acted on none of these three factors: information, geometry, elevation. The common ceiling of 10-20 % hit/shell follows. + +## 3. Proposals (proposed 2026-11-12, for the developer to decide) + +### P0 — Measure the game's ceiling before any overhaul (probe, no training change) + +Add an oracle mode to `arenai_agent_probe`: turret and cannon slaved to the nearest enemy (exact yaw and ballistic elevation), fire when error < 1°. Measure hit/shell and kills by distance, plus two variants: yaw-only oracle (elevation left at 0) and oracle limited to the camera field. + +What it settles: +- If the oracle hits at 60 % or more up to 100 m and little beyond, the game is learnable at short range and the lock is information (P1) and geometry (P2). +- If the yaw-only oracle collapses, elevation (P3) is the priority. +- If the oracle hits badly even at short range, the problem is in the game (dispersion, hitbox, shell physics). + +Cost: ~½ day, code in `probe/` only. (Done the same day: see `2026-11-12_aim-oracle-p0.md`.) + +### P1 — Make off-field enemies visible (game / observation) + +Today the agent has no way to know that an enemy is 40 m behind it. Two forms: + +- **P1a, radar in the state vector**: for the K = 3-4 nearest living enemies, bearing relative to the turret (cos, sin), normalised distance and height difference. Changes `ENEMY_STATE_VECTOR_SIZE` (`include/`). + - Warning: this is not the 2026-11-03 refusal (« duplication vision → proprio »), which concerned the alignment of an already visible target. Here the information is absent from vision in 65-70 % of decisions. But it must be validated explicitly. +- **P1b, second camera** fixed to the chassis, low-resolution 360° panorama (e.g. 256 × 16). The agent stays "vision only", looking and aiming are decoupled, but rendering and CNN cost more. + +Expected effect: turning toward the near enemy becomes an immediate-credit action (target in field, then firing at 40-60 %), where today it is a blind search. + +### P2 — Bring combat back to useful range (geometry / curriculum) + +- **P2a (config only)**: bound the curriculum at D 500 instead of 1000. Density ×4 and typical distances ÷2. +- **P2b (game)**: area damage of the shell, over a radius of a few metres, decreasing. A shot at 300 m missing by 3 m yields something: the physical gradient the Cauchy tried to imitate, but paid by the game itself and identical for the player. To check: effect on the desktop game. + +### P3 — Elevation (conditional on P0's result) + +If the yaw-only oracle loses most hits: game-side assisted elevation (the cannon takes the ballistic elevation toward the point under the reticle, the agent commands only yaw), or less rugged terrain during the curriculum. + +### Reward + +- Remove Φ, or restrict it to enemies within ~100 m (or weight it by a P(hit | distance) measured by P0). In its current form it pays the far lottery (F6). +- hit and kill stay event-based; no other crutch. + +### Proposed order + +P0 first (½ day, no hypothesis committed). Then P1 + P2a together if the oracle confirms the game is learnable at short range, with Φ removed. P2a is a simple config change, P1 changes the observation contract. diff --git a/.claude/knowledge/comparisons/2026-11-12_canon-stabiliser-gun-laying.md b/.claude/knowledge/comparisons/2026-11-12_canon-stabiliser-gun-laying.md new file mode 100644 index 000000000..7dde48ac4 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-12_canon-stabiliser-gun-laying.md @@ -0,0 +1,13 @@ +# Canon stabiliser — GunLaying, world aim setpoint (yaw + elevation), hinges at 20 Hz + +Runs: 507 (reference), 508 (first run) + +2026-11-12 — validated and coded (uncommitted): GunLaying, aim setpoint in the world (yaw + elevation), always active for player + agent; `aim_target` removed; turret/canon hinges at 20 Hz (AIM_HINGE_FREQUENCY). + +The developer's choice (2026-11-12, « choix recommandés »): 2-axis stabilisation, always active without option, `aim_target` removed from `inputs.h` (separate change, to commit apart), then hinge stiffness 2 → 20 Hz validated (« Oui, 20 Hz »). + +Code: `arenai_model/src/tank/parts/gun_laying.{h,cpp}` (world yaw/elevation; `turret_angle`/`canon_angle` from the parent rotation; `anchor_*` when the hinge does not reach its target: speed or stop ⟹ no runaway; `reset` from the real canon direction), shared by TurretItem/CanonItem, created by JoltTank, re-anchored at construction and after `teleport` (respawn). `right_joystick` keeps its velocity meaning. + +**Why:** the agent does no better than a frozen canon in elevation; relief dominates the need (comparisons/2026-11-12_oracle-aim-ceiling-elevation-parallax.md). + +**Test plan:** run 508 from scratch vs 507 at equal D: |elevation gap| < 2° (17-24 % before), hit/shell < 50 m (41 %), hits/tank/min (5.4 / 1.9). Measured delay (critical spring): 2 Hz = 30° at full-speed rotation, 1-4° in chassis turn; 20 Hz = 6-9° and < 1°; delay ≈ speed / (π·f), inherent; test TurretFollowsItsSetPointWhileTheChassisTurns (< 1.5°). Do not probe saves ≤ 507 with this binary to compare with their old figures. (see docs/decisions.md 2026-11-12: gun laying validated) diff --git a/.claude/knowledge/comparisons/2026-11-12_factored-aim-credit-phi-aimed.md b/.claude/knowledge/comparisons/2026-11-12_factored-aim-credit-phi-aimed.md new file mode 100644 index 000000000..2f52bac62 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-12_factored-aim-credit-phi-aimed.md @@ -0,0 +1,22 @@ +# Factored aim credit + aimed Φ (A_vis) — validated and coded 2026-11-12 + +Runs: 508, 509 (first run with it) + +2026-11-12 evening — validated and coded (uncommitted): factored advantage (canon on A_vis = λ-return of Φ without critic, `aim_gae_lambda` 0; rest on GAE 0.95) in ppo/ppg/ppo_liquid via `agents/ppo_objective`; Φ = Cauchy(miss/3 m) on visible enemies (frustum + line of sight). + +The developer's choices (2026-11-12): factored design OK, Φ on the aimed enemy (« j'adore »), no hits/kills in A_vis, the three trainers at once, measure before code. + +Code: `arenai_agent/src/agents/ppo_objective.{h,cpp}` (generalized_advantages, normalized, aim_advantages, PolicyLogProbs::split with FIRST_AIM_ACTION = 2, clipped_surrogate per group, joint ratio for KL/clip); continuous log-probs stored per action; `aim_reward` in the 3 rollout buffers, `on_transition(rewards, aim_rewards, done, truncated)` (SAC ignores it); `TrainTankEnvironment::last_step_aim_rewards()`; hyperparameter `--aim_gae_lambda` (0). Φ: `get_aim_potential(tanks, aspect_ratio)` (public contract), `visible_enemies` (camera frustum with `CanonItem::get_fov()` + muzzle→centre ray_test excluding the target), predicted trajectory crossing targets, `AIM_TARGET_RADIUS = 3 m` (chassis 6.4 × 9.4 × 3.2 m). Tool aim_finetune and `train_actor` removed after the causal test. + +Measurements: new Φ ρ(λ 0) 0.096/0.089 turret, 0.103/0.114 canon (pre-registered criterion 0.08); end to end the trainer's A_vis gives ρ 0.089/0.106 vs 0 for the usual advantage. Φ facing at 30 m = 0.58 (muzzle 2 m above centre). Tests: 94 model, 2440 agent, ctest 5/5. + +**Why:** comparisons/2026-11-12_aim-diagnosis-mu-white-noise.md — the λ 0.95 horizon destroys aim credit, causally demonstrated (finetune 13 → 18-19 %). + +**Test plan:** first run = 508 + this change; compare at equal D: turret correction gain (−0.05/10° before), nearest < 5° (9 %), tour<5°, elevation < 2°, hit/shell. Rebuild cmake-build-release before launching. + +**Hull correction (2026-11-12, validated and kept by the developer despite turret 1000 under the threshold):** miss counted from the hull, max(0, miss − 3 m)/3 m ⟹ straight ahead at 30 m Φ = 1 (before 0.58). ρ re-measured (trainer's aim A): turret 0.085/0.067, canon 0.121/0.095 (550/1000); turret side 1000 falls below the 0.08 threshold (−0.02 to −0.03, ~3 standard errors): lost signal = push toward the exact centre when the shot already hits. + +**Φ plateau removed (2026-11-14, validated by the developer):** Φ was 1 for any pass < AIM_TARGET_RADIUS (3 m) ⟹ no aim gradient under ~1.7° at 100 m, exactly the measured dispersion (1.3-1.9° in yaw and elevation, in μ). Now ratio = miss / 3 m (Φ = 0.5 at 3 m). Tests PeaksOnTheEnemy/DecaysWithTheMiss adapted; uncommitted. Judge on median aim error at 50-200 m (< 1°?) and h<5°. + +**a·|a| curve turret/canon (2026-11-14, validated by the developer):** `aim_action_to_rate` in torch_types.cpp (agent only, all algos, player intact); the probe oracle goes through the inverse `aim_rate_to_action`. Confounded with the Φ plateau removal in the same run. Old checkpoints play differently (turret response changed). +(see docs/decisions.md 2026-11-22: Φ removed, tried ≥ 8 times; 2026-11-24 refused) diff --git a/.claude/knowledge/comparisons/2026-11-12_oracle-aim-ceiling-elevation-parallax.md b/.claude/knowledge/comparisons/2026-11-12_oracle-aim-ceiling-elevation-parallax.md new file mode 100644 index 000000000..48800dd5a --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-12_oracle-aim-ceiling-elevation-parallax.md @@ -0,0 +1,13 @@ +# Probe oracle: aim ceiling, elevation, parallax (507 save_12) + +Runs: 507 (save_12) + +2026-11-12 — probe oracle (`--oracle`, `--oracle_fov`, `--oracle_policy_pitch`, `--oracle_camera_center`): current camera ×2-4.4 the policy, 360° only +35 %, elevation = main lock, 3rd-person camera parallax costs 30 % under 50 m. + +On 507 save_12, hits/tank/min side 550 / 1000: policy 5.4 / 1.9; oracle 80° (current camera) 11.0 / 8.5; 120° 12.3 / 10.3; 360° 14.7 / 11.5; 360° + policy elevation 8.3 / 5.0 (hit/shell 25 / 16 %); centring the target in the image instead of the axis: < 50 m 61-70 % instead of 93-99 %. Perfect shot > 200 m: 9-15 %. + +**Why:** the developer dislikes the radar (« ça substitue la vision ») and P2; they seek a vision lever. The oracle shows out-of-field is not the bulk of the gap: it is precision, especially in elevation, and the visual reference distorted by the camera (0, 4, −20) aiming at the point at 100 m (+ CollisionCamera bringing it closer). + +**Lever proposed:** aiming camera on the canon axis (image centre = firing line), possibly wider default FOV + zoom to aim. Resolution would only pay > 200 m. Report: outputs/oracle/oracle.md. The hinge position motor has ~2 decisions of delay (servo gain 0.3 in the oracle). Linked to comparisons/2026-11-12_aim-diagnosis-range-and-out-of-field.md. + +**Elevation decomposition (2026-11-12, columns canon_elevation/canon_relative_elevation/chassis_pitch/chassis_roll in the probe):** parallax is not the cause (median gap ≈ 0, it is a ±5° IQR dispersion). Elevation need std 8° dominated by chassis attitude (relief); the agent follows it slowly (slope 0.8) but adds ~10° of own agitation and does not compensate step by step ⟹ |e| < 2°: agent 17-24 % ≈ frozen canon 21 % < stabilised canon without command 28-36 %. Lever proposed: canon stabiliser (game), then on-axis camera. (outcome: gun laying validated 2026-11-12, see comparisons/2026-11-12_canon-stabiliser-gun-laying.md; later revised by comparisons/2026-11-15_local-optimum-aim-trigger-coordination.md) diff --git a/.claude/knowledge/comparisons/2026-11-13_delayed-respawn-cut-at-respawn.md b/.claude/knowledge/comparisons/2026-11-13_delayed-respawn-cut-at-respawn.md new file mode 100644 index 000000000..0c681b878 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-13_delayed-respawn-cut-at-respawn.md @@ -0,0 +1,11 @@ +# Delayed respawn, trajectory cut at respawn (validated, pending run 511 save_9 verdict) + +Runs: 510, 511 (save_5/9), 491, 481 + +2026-11-13 — scheme validated by the developer, awaiting the verdict of 511 save_9: at empty reserve, 10 s disarmed and vulnerable without cut, then respawn with 10 shells as truncated + V cut; D (episode end at 0 armed) judged insufficient. + +Validated scheme (not coded): empty reserve and no shell in flight ⟹ the tank stays in place 10 s (fixed duration), disarmed and vulnerable, trajectory not cut (`r_rcv`/death in the return); then respawn with 10 shells, `truncated` + V cut at respawn; death before ⟹ normal `done`. Open point: respawn in place or at a new spawn. + +**Why:** 511 save_5: dump faster than 510, flat trigger (see run 511 save_1 note). Retained hypothesis: everyone dry in ~3 s ⟹ disarmed without danger. Cutting at respawn (not at empty as in 491-510) puts the danger of waiting into the return without ever paying the reload, coherent with the refusal of regen (run 481 slow regen). Variant D discarded: neutral on returns, throughput only; at threshold « ≤ 1 armed » it would punish the thrifty. + +**Test plan:** code only after 511 save_9, if its trigger stays flat. Replaces the « delayed respawn » fallback of comparisons/2026-11-13_game-rule-empty-reserve-no-respawn.md. Risk: trigger extinction of the 437/479 type, to watch at probe (armed p_fire ≪ 0.1) in addition to the dump. (see docs/decisions.md 2026-11-22: empty reserve rule = refill + constant penalty) diff --git a/.claude/knowledge/comparisons/2026-11-13_game-rule-empty-reserve-no-respawn.md b/.claude/knowledge/comparisons/2026-11-13_game-rule-empty-reserve-no-respawn.md new file mode 100644 index 000000000..a5af8551e --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-13_game-rule-empty-reserve-no-respawn.md @@ -0,0 +1,11 @@ +# Game rule at empty reserve: no respawn / no truncation in training (run 511) + +Runs: 510 (base), 511 (first run), 491, 437, 479 (earlier rules) + +2026-11-13 — the developer's decision: at empty reserve, no more respawn nor truncated in training; the tank stays alive disarmed until death or end of episode, as in game (uncommitted, run 511 from scratch planned). + +Respawn/truncated block removed from `TrainTankEnvironment::step` (train_environment.cpp). Model/core API (`respawn`, `respawn_tank`, `is_out_of_shells`, `has_shells_in_flight`) left in place, unused outside tests. Trainers unchanged: truncated is never true any more. No empty penalty (difference with 437/479). + +**Why:** in game tanks end dry: at 21 % hits, a shot costs 0.58 shell net, and training offered a free exit (full respawn, V cut to 0) never seen in game. The developer: « je veux que la politique apprenne à économiser ses obus ». Follows run 510 (per-group KL stop save3), cancels the run 491 empty-reserve truncation/respawn (option A). + +**Test plan:** run 511 = 510 + this single change, from scratch after reboot (NVIDIA driver). Read at probe: % disarmed, armed decisions (floor 490: 2-3 %), 1st empty reserve, ratio, hit/shell vs 510 at equal D. Fallback validated by the developer if the trigger starves: delayed respawn of N s (see comparisons/2026-11-13_delayed-respawn-cut-at-respawn.md). Probe follows the new rule: % disarmed not comparable to 510 probes. Open point: episodes where all the living are dry run to max_episode_steps without events (throughput). (see docs/decisions.md 2026-11-22: no respawn (11-13, reverted); current rule refill + constant penalty) diff --git a/.claude/knowledge/comparisons/2026-11-13_per-group-kl-stop-skip-canon.md b/.claude/knowledge/comparisons/2026-11-13_per-group-kl-stop-skip-canon.md new file mode 100644 index 000000000..2eb6fd54e --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-13_per-group-kl-stop-skip-canon.md @@ -0,0 +1,13 @@ +# Per-group `target_kl` stop (canon vs rest) — GroupKlStop + +Runs: 509 (cause), 510 (first run with it) + +2026-11-13 — `target_kl` stop per group (canon vs rest) in ppo/ppg/ppo_liquid via `GroupKlStop` (ppo_objective); skip = rest; `skip_canon` CSV-only; same threshold 1.5 × target_kl; uncommitted at the start. + +The developer's choice: option 1 (stop per group), the three trainers, same threshold per group, `skip_canon` CSV-only. A stopped group loses its surrogate and its entropy bonus for the rest of the update; the step where it stops is recomputed without it; `kl` stays the joint KL. Companion tool: `arenai_agent_sigma_gradients --kl_by_group`. + +**Why:** run 509 (comparisons/2026-11-12_factored-aim-credit-phi-aimed.md) — the canon made 77 % of the joint KL at the stop step and cut the trigger's update. + +**Test plan:** first run = 509 + this single change (p_init fire left at 0.5); read skip vs skip_canon, dump exit (reserve, probe ratio) against 508/509 at equal D. Rebuild cmake-build-release before launching. + +(see docs/decisions.md 2026-11-22: separate aim credit incl. per-group KL stop removed, single optimisation group) diff --git a/.claude/knowledge/comparisons/2026-11-14_ev-per-optimiser-batch.md b/.claude/knowledge/comparisons/2026-11-14_ev-per-optimiser-batch.md new file mode 100644 index 000000000..2d2c2c34c --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-14_ev-per-optimiser-batch.md @@ -0,0 +1,11 @@ +# CSV `ev` computed per GPU micro-batch was an artefact — fixed to optimiser batch + +Runs: 515, 516, 517, 518 + +2026-11-14: CSV `ev` was computed per GPU micro-batch (negative artefact at gpu_batch 256/128 in 516-518); fixed to cover the whole optimisation batch in ppo/ppo_liquid/ppg (uncommitted). + +`backward_critic` now returns (returns, values) detached, and `explained_variance()` (update_utils) computes `ev` over the concatenation of the blocks of one optimisation batch. Identical to the old computation when gpu_batch_size = batch_size (≤ 515: 512/512). Test: tests_update_utils.cpp. + +**Why:** 516-518 (critic_gpu_batch_size 256 ⟹ 8 sequences of 30 steps per computation) displayed ev −1 to −14 while critic loss was lower than in 515. + +**Rule:** `ev` of 516, 517 and 518 (launched before the fix) is not interpretable; compare the `v` loss instead. Runs launched after the release rebuild: ev comparable to ≤ 515. diff --git a/.claude/knowledge/comparisons/2026-11-14_forced-zoom-resolution-not-the-lock.md b/.claude/knowledge/comparisons/2026-11-14_forced-zoom-resolution-not-the-lock.md new file mode 100644 index 000000000..d3d5ff64f --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-14_forced-zoom-resolution-not-the-lock.md @@ -0,0 +1,15 @@ +# Forced zoom: resolution is not the lock for aligned-shot precision + +Runs: 510, 514 (save_23), 515 (save_9) + +2026-11-14 — probe `--zoom on/off` (514 s23, 515 s9): resolution ×2 does not make aligned shots more precise < 100 m, helps only at 100-200 m; zoom transition 0.75 s in training, FOV absent from the observation. + +Option `--zoom policy|on|off` added to arenai_agent_probe and probe_checkpoint.py (suffix `_zoomon`/`_zoomoff`), uncommitted. + +Result: forced zoom on ⟹ hit of aligned shots by distance equal or lower than the policy (0-50 m 78-82 %, 50-100 m 46-55 %), median miss 6 m unchanged. Forced zoom off ⟹ losses only at 100-200 m (22-29 → 16-17 % for 514; 515 s9 no longer fires far, hit/shell 17 → 12 %). The earlier p_zoom ↔ hit correlation was confounded by state (the agent zooms when it is easy). + +Code facts: `CanonItem::fov()` advances 2.9° per renderer call ⟹ transition 0.75 s in training/probe (1 render per decision) vs 0.25 s in game; the current FOV is not in the observation. 514 abandons zoom between 720 k and 1 M (p_zoom 0.33 → 0.09), 510 does not. + +**Why:** the developer proposed 512×256 + one CNN block as a fine-precision lever; comparisons/2026-11-12_oracle-aim-ceiling-elevation-parallax.md already said « useful resolution > 200 m only ». + +**Rule:** do not present resolution as a lever of aligned-shot precision < 100 m; the lock is in the command (μ, delay, elevation), cf. comparisons/2026-11-12_aim-diagnosis-mu-white-noise.md. Analysis: outputs/comparisons/2026-11-14_zoom.md. (see docs/decisions.md 2026-11-14: 512×256 vision removed) diff --git a/.claude/knowledge/comparisons/2026-11-14_trigger-entropy-regulator-caps-selectivity.md b/.claude/knowledge/comparisons/2026-11-14_trigger-entropy-regulator-caps-selectivity.md new file mode 100644 index 000000000..16d198f62 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-14_trigger-entropy-regulator-caps-selectivity.md @@ -0,0 +1,18 @@ +# Trigger entropy regulator caps selectivity (510 probes replay, save_9 → 32) + +Runs: 510, 514, 515, 520 + +2026-11-14: replay of the 510 probes save_9→32 (binary 7422d098) — aim held, trigger loosened at 540 k when α_fire ×20; target H(0.05) > entropy of a selective trigger. + +Probes 510 save_9/16/20/24/28/32 at the run's binary (worktree `/home/samuel/CLionProjects/arenai_wt_510`, build/), outputs/train_510_ppo_liquid/probes/rejeu_7422d098/timeline.md. + +- Aim held at fixed distance (h<5° 32-34 %, tour<5° 28-30 %) from save_16 to save_32 ⟹ no precision regression. +- Trigger loosened at save_20 (540 k): p_off ×4-6, then 2.5× save_16 until the end; cadence 1.5-2×, empty reserve earlier. +- Mean trigger entropy (armed): 0.09-0.18 at save_16 < target H(0.05) = 0.199 ⟹ α_fire 0.0005 → 0.011 (380 → 530 k), then H 0.16-0.31. 514: same α_fire rise at 500-600 k and plateau. +- ~40 % of armed decisions are off-axis ⟹ a selective trigger is necessarily below the target: the regulator forbids selectivity. + +**Why:** explains « 510's peak does not hold »; follows run 510 (per-group KL stop) and the Stooke PID (run 497). + +**Test plan:** temporal causality only; test = 515 with lower `discrete_target_proba` (common fire + zoom target) or per-head target (code). The developer's decision. + +**The developer's choice (2026-11-14):** lower common target, `discrete_target_proba` 0.05 → 0.01 (H 0.056) as default in ppo/ppo_liquid/ppg, config 515 otherwise ⟹ run 520 (uncommitted). Read α_fire and p_off at 400-600 k vs 510/514. diff --git a/.claude/knowledge/comparisons/2026-11-14_zoom-usage-and-fine-precision.md b/.claude/knowledge/comparisons/2026-11-14_zoom-usage-and-fine-precision.md new file mode 100644 index 000000000..d74b1e5cb --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-14_zoom-usage-and-fine-precision.md @@ -0,0 +1,81 @@ +# Zoom: usage, abandonment, and what it says about fine precision + +Runs: 510, 514, 515. +Date: 2026-11-14. Side-550 probes of 510, 514 and 515 (armed decisions, step ≥ 10). The real FOV is not logged by the probe: it is simulated from p_zoom, drawing the zoom according to p_zoom and applying the game's transition step. + +## Mechanics (code) + +- `CanonItem::fov()` advances the FOV by a step `(45° − 23.3°) · (1/30) / 0.25 s` = 2.9° **at each call**. The call comes from the renderer. +- In training and in the probe, vision is rendered only **once per decision** (`render_frame` after the `action_repeat` frames). The transition thus takes 7.5 decisions = **0.75 s**, versus 0.25 s in the game, which renders every frame. +- The zoom is drawn at each decision (Bernoulli p_zoom). At p ≈ 0.5, the FOV wanders between 23 and 45° (simulated median FOV 26-42° depending on the save). +- **The current FOV is not in the observation**: neither in proprioception nor as network input. The agent does not know the pixel → degree ratio of the image it sees, which varies by a factor 2. + +## Zoom usage across saves + +| run | save | p_zoom | aligned < 5° | off-axis ≥ 20° | corr(p_fire, p_zoom) | zoomed share (FOV < 30°) | +|---|---|---|---|---|---|---| +| 510 | 5 | 0.68 | 0.72 | 0.62 | 0.62 | 88 % | +| 510 | 9 | 0.30 | 0.36 | 0.28 | 0.68 | 16 % | +| 510 | 16 | 0.47 | 0.63 | 0.39 | 0.55 | 43 % | +| 510 | 28 | 0.40 | 0.55 | 0.34 | 0.53 | 35 % | +| 514 | 9 | 0.43 | 0.54 | 0.39 | 0.86 | 25 % | +| 514 | 20 | 0.32 | 0.52 | 0.23 | 0.87 | 32 % | +| 514 | 23 | 0.33 | 0.59 | 0.20 | 0.86 | 34 % | +| 514 | 34 | **0.09** | 0.12 | 0.07 | 0.33 | **2 %** | +| 515 | 9 | 0.49 | 0.62 | 0.44 | 0.90 | 44 % | + +- **The zoom is selective.** The agent zooms more when aligned (0.52-0.67) than off-axis (0.20-0.44), and more when the enemy is near. Not noise. +- **The zoom follows the trigger.** In 514/515, corr(p_fire, p_zoom) is 0.86-0.93: the two discrete heads move together. In 510 the correlation is weaker (0.53-0.68). +- **Abandonment is late and specific to 514.** In 514's CSV, Hd drops from 0.33 to 0.15 between 720 k and 1 M steps. alpha_zoom reacts only from 960 k, because the discrete target (0.05) acts only once the probability is very low. 510 keeps p_zoom ≈ 0.40 until save_28. 514's CSV hit does not drop during the abandonment (18-21 %). + +## Zoom and precision of aligned shots (< 5°, 50-200 m, target = nearest) + +| probe | p_zoom < 0.3 | 0.3-0.7 | > 0.7 | +|---|---|---|---| +| 514 s9 (550 / 1000) | — | 44 / 47 % | 55 / 61 % | +| 515 s9 | — | 28 / 27 % | 49 / 60 % | +| 514 s20 | 22 / 23 % (n 18-30) | 44 / 34 % | 49 / 52 % | +| 514 s34 | 39 / 39 % (n ≈ 1200) | 46 / 48 % | 57 / 40 % (n < 60) | + +These figures are correlations. p_zoom follows the states where the target is easier (near, aligned), and the real FOV is unknown. + +## Reading + +1. **The zoom seems to help fine precision** (+10 to +30 points on aligned shots). The clue pointing toward 512×256. +2. **Shots at intermediate p_zoom are often the worst** (515 s9: 27-28 % versus 49-60 %). At p ≈ 0.5 the FOV wanders and the image scale changes from one decision to the next without the agent knowing it. Hypothesis: the **unknown scale**, more than resolution, costs precision. An error of x pixels at the centre is worth 1× or 2× in angle depending on the FOV. +3. **The 0.75 s transition in training** (versus 0.25 s in game) lengthens the period of uncertain scale. It also makes the effect of a zoom action small (2.9° of FOV) and diluted over 7-8 decisions, hence hard to credit. + +## What would settle it + +- **Forced-zoom probe** (`--zoom on|off`, to add) on one checkpoint (514 save_23, 515 save_9): aligned hit/shell at fixed FOV 45° versus fixed 23°. That is the causal effect of ×2 resolution at equal policy, hence what to expect from 512×256. +- Design decisions for the developer, nothing coded: + - zoom transition per frame rather than per render (training/game alignment); + - current FOV in the observation; + - or zoom removed in favour of a higher fixed resolution. + +## Result of the forced-zoom probe (2026-11-14, `--zoom on|off`) + +Same checkpoint, zoom left to the policy / forced on (FOV 23°) / forced off (FOV 45°). Hit is measured on aligned shots (< 5°) at the nearest target, by distance. + +| probe | zoom | hit/shell | 0-50 m | 50-100 m | 100-200 m | median miss | +|---|---|---|---|---|---|---| +| 514 s23, 550 | policy | 22.0 % | 82 % | 55 % | 22 % (n 351) | 6.0 m | +| | on | 20.4 % | 82 % | 50 % | 22 % (n 259) | 6.0 m | +| | off | 20.3 % | 78 % | 48 % | 16 % (n 112) | 6.0 m | +| 514 s23, 1000 | policy | 18.4 % | 82 % | 55 % | 29 % (n 419) | 6.0 m | +| | on | 16.5 % | 78 % | 46 % | 26 % (n 810) | 7.0 m | +| | off | 18.2 % | 85 % | 45 % | 17 % (n 265) | 6.3 m | +| 515 s9, 550 | policy | 17.3 % | 82 % | 51 % | 20 % (n 89) | 5.6 m | +| | on | 16.4 % | 81 % | 51 % | 18 % (n 147) | 5.6 m | +| | off | 12.2 % | 86 % | 41 % | 0 % (n 23) | 5.9 m | +| 515 s9, 1000 | policy | 12.5 % | 79 % | 62 % | 27 % (n 117) | 5.9 m | +| | on | 12.2 % | 78 % | 51 % | 26 % (n 230) | 6.5 m | +| | off | 6.7 % | 84 % | 48 % | 0 % (n 20) | 5.6 m | + +### Reading + +- **Forced zoom on does not make aligned shots more precise.** Hit by distance is equal or lower than with the policy, and the median miss does not move (6 m). Doubling px/° does not reduce the error of aligned shots at < 100 m, where most hits happen. +- **Forced zoom off costs only beyond 100 m**: 16-17 % instead of 22-29 % for 514. 515 save_9 no longer even fires far (n 20-23, 0 %), and its hit/shell falls 17 → 12 % and 12.5 → 6.7 %. +- **The p_zoom ↔ hit correlation of the first part was confounded by state.** The agent zooms in easy situations (near target, already aligned). +- Conclusion: angular resolution does not limit fine precision below 100 m. It matters only at 100-200 m, which the 2026-11-12 oracle already said (> 200 m). 512×256 would not target the main lock. The error of aligned shots (miss ~6 m, ~50 % at 50-100 m) lies elsewhere: dispersion of μ, command delay, elevation (hausse). +- Limits: a single 4-episode probe per arm. Both forced zooms leave the policy's distribution (514 save_23 zoomed only 34 % of the time), which slightly penalises the "on" arm. diff --git a/.claude/knowledge/comparisons/2026-11-15_agent-economy-2-shells-per-hit.md b/.claude/knowledge/comparisons/2026-11-15_agent-economy-2-shells-per-hit.md new file mode 100644 index 000000000..60d04bed9 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-15_agent-economy-2-shells-per-hit.md @@ -0,0 +1,13 @@ +# Agent economy: 2 shells per hit (`GAME_SHELL_ECONOMY` 10/2/30) + +Runs: 520 (config base), 521 (first run with N=2) + +2026-11-15 — the developer's choice: lever « constraining reserve », `GAME_SHELL_ECONOMY` 10/2/30 (2 shells returned per hit instead of 3) for the agent in game and in training; the player has no shell economy; uncommitted. + +Reason: reward = ⅔ r_hit ∝ hits per tank-step, and at 3 shells per hit a reserve of 25-30 % hit/shell suffices for 10-30 hits, death comes before the empty reserve ⟹ volume wins (520's drift after save_32). At 2 per hit the budget falls to 5-7.5 hits at 25-30 %, and shot sorting (< 5°: 35 %, < 1°/1°: 55-63 %) becomes the optimum (hits-per-life model, validated on 520's drift). + +A single constant `GAME_SHELL_ECONOMY` (shell_economy.h): agent tanks in game (game_session.cpp), CLI defaults of training and probe. The player (`make_player_tank`) has no economy. Empty-reserve rule always different: truncated respawn in training, disarmed until death in game. + +**Why:** the developer prefers lever 1 (same rule game/training) over precision in the reward; choice N = 2, player untouched. + +**Test plan:** next run = config 520 + N = 2 only. Markers: hit/shell > 30 % held at D 1000, stable cadence from save_24 to save_37, late 1st empty reserve; failures = extinguished trigger or dump; watch very early empties (respawn as leak). Related: run 520 (discrete target 0.01), comparisons/2026-10-27_ammo-economy-break-even-threshold.md. (not in docs/decisions.md as an entry; see 2026-08-06 shell reserve validated) diff --git a/.claude/knowledge/comparisons/2026-11-15_local-optimum-aim-trigger-coordination.md b/.claude/knowledge/comparisons/2026-11-15_local-optimum-aim-trigger-coordination.md new file mode 100644 index 000000000..c4eac4885 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-15_local-optimum-aim-trigger-coordination.md @@ -0,0 +1,17 @@ +# Local optimum of aim/trigger coordination (oracle 2×2×2 plan on 520 save_37, confirmed 522 save_68) + +Runs: 520 (save_37), 522 (save_68), 510-520 (common ceiling) + +2026-11-15: 2×2×2 oracle plan (yaw/elevation/trigger) on 520 save_37: no single link pays, perfect aim + agent trigger = policy level, only the oracle trio ×1.8/×2.6 ⟹ local coordination optimum; the trigger ignores the alignment produced by the oracle. + +Hits/tank-s (550/1000): AAA 0.320/0.140; one oracle link: yaw 0.295/0.106, elevation 0.348/0.158, trigger 0.124/0.099; OOA (oracle aim, agent trigger, turret aligned 84-92 %) 0.320/0.150; OAO 0.200/0.181; AOO 0.169/0.126; OOO 0.586/0.361. In OOA, p_fire at < 1° = 0.13/0.07 vs 0.43-0.50 aligned in normal play. + +Probe: `--oracle_policy_yaw`, `--oracle_policy_fire` added (validated by the developer), oracle trigger = yaw AND elevation < 1° (uncommitted at 2026-11-15). Report: outputs/train_520_ppo_liquid/probes/oracle/save_37.md. + +Parallax + dynamics test (2026-11-15): OOA centred camera p_fire aligned 0.12 → 0.16 (agent alone 0.58) ⟹ parallax minor. The trigger fires in self-sustained bursts: p_fire 0.63 in the second after a shot then 0.1-0.2; under OOO (oracle fires) 0.45 constant, under OOA (burst never primed) 0.18 → 0.06. Fire decision = internal engagement state (recent shot, proprio cooldown/reserve or liquid memory) > visible alignment. Proposed next tests: neutralise cooldown/reserve in the proprio (probe option), trigger fine-tune under oracle aim. + +**Why:** explains the common ceiling of 510-520: links are co-adapted (loose trigger ~5° + volume ↔ aim rarely < 1°), marginal gradient of each link ≈ 0. Revises comparisons/2026-11-12_oracle-aim-ceiling-elevation-parallax.md (« elevation is the main lock »): elevation alone pays nothing. + +**Rule:** no longer propose tuning a single link as a lever of the ceiling. Proposed next tests: OOA + `--oracle_camera_center` (H1 parallax), then alignment decoding from features (H2). Levers to discuss with the developer: on-axis camera, weaned assisted aim, trigger fine-tune under oracle aim. Related run 520 (discrete target 0.01). + +**Confirmed on 522 save_68 (2026-11-16, outputs/train_522_ppo_liquid/probes/oracle/save_68.md):** hits/tank-s agent 0.152/0.111; oracle trigger + agent aim 0.128/0.087; oracle aim + agent trigger 0.147/0.059 (turret aligned 93-97 %, aligned p_fire < 2° 0.115 → 0.019/0.008); all oracle 0.533/0.448 (×3.5/×4). At equal angle and distance (< 2°, 50-100 m, 80 % hits) p_fire 0.20 with its own aim vs 0.06 under oracle. Aligned < 100 m: 0.23 after a hit impact, 0.16 after a miss, 0.08 without recent shot (0.016 under oracle) ⟹ the first shot of an engagement is the bottleneck, shot outcome matters little (not a mere refund sensor), |μ canon| does not explain the gap. Run 522's empty penalty moved the optimum toward precision without breaking it. Acquisition unchanged since 2026-11-12: nearest < 100 m in field 38 % of time, median bearing 76-82°. Levers proposed to the developer 2026-11-16 (nothing decided): training under weaned assisted aim (breaks co-adaptation), preceded by a short trigger fine-tune under oracle aim as causal test; no resume-training option in main.cpp. (see docs/decisions.md 2026-11-16: training under assisted/oracle aim refused) diff --git a/.claude/knowledge/comparisons/2026-11-16_cnn-bench-spatial-softmax.md b/.claude/knowledge/comparisons/2026-11-16_cnn-bench-spatial-softmax.md new file mode 100644 index 000000000..596d6e89c --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-16_cnn-bench-spatial-softmax.md @@ -0,0 +1,18 @@ +# CNN test bench: spatial softmax does not generalise lateral localisation + +Runs: 522 (save 68 images), 470 (cited) + +2026-11-16: supervised bench on images of 522 s68 — spatial softmax generalises nothing (left/right 0.51) even with the exact label; flattened outputs learn and rise with data (7 convs flattened 1×2: 0.68, 0.73 < 100 m). Follow-up of the alignment-decoding note of 522 save_68 (2026-11-16); the developer's hypothesis « le spatial softmax n'est pas adapté », ready to revisit the CNN entirely. Report: outputs/train_522_ppo_liquid/frames/bench.md (scripts bench_cnn.py, bench_curve.py; images save_68_side550_40ep.bin, 3.6 GB). + +- 40 episodes, 13.6 k images with an enemy in the field; target = yaw/elevation of the most on-axis enemy; test on 8 never-seen episodes. +- A (current, 4 convs + spatial softmax): left/right 0.51-0.52 at 8/16/32 episodes, corr 0; 16×32 map and coordinates-as-input variants same. +- B (4 convs flattened 8×16) 0.62; C (6 convs flattened 2×4) 0.66; D (7 convs flattened 1×2, form before 2026-10-20) 0.57 → 0.61 → 0.68, target < 100 m 0.73, median error 2.4° (3.7° without image). Curves still rising. +- Single-enemy images no easier ⟹ not ambiguity. Hard task: random colours per episode, small tanks, agent tank at bottom-centre (3rd-person camera) masking close aligned targets. +- All memorise training; generalisation = the criterion. + +**Why:** first direct (non-RL) proof that the spatial softmax introduced 2026-10-20 (dbd11417) prevents lateral localisation; consistent with the undecodable yaw of 470 and 522. + +**Use:** run candidate = back to a flattened output with 6-7 stride-2 convs (the developer's decision, architecture change). Limits: 10.8 k images, one seed, supervised ≠ RL. Tool: `arenai_agent_probe --frames --frames_every N --zoom off` (header 10 floats: episode, step, tank, view_distance/yaw/pitch, best_distance/yaw/pitch, view_count; then 3×128×256 uint8); `AimGeometry` gained best_yaw, best_pitch, view_count (uncommitted at 2026-11-16). + +**Architecture choice (2026-11-16 evening, bench_seeds.txt, 4 seeds, 32 episodes)**, left/right / target < 100 m / median yaw error < 100 m: 5 convs 8-16-32-48-64 flattened 4×8 (default of 10-20) 0.599 / 0.630 / 3.45°; 5 convs 16…128-128 flattened 4×8 0.630 / 0.693 / 3.21°; 6 convs flattened 2×4×128 0.653 / 0.713 / 2.84°; 6 convs 64 channels 0.637 / 0.710 / 2.71°; 7 convs flattened 1×2×128 0.654 / 0.714 / 2.45° (std 0.01-0.03). GPU cost identical (inference 32: 0.35-0.41 ms; training 512: 27-30 ms): cost is in the first layers. Proposed to the developer: 7 convs 16-32-64-128-128-128-128, GroupNorm 2-4-8-16-16-16-16, Flatten → 256 (liquid input 320 instead of 448). Open point: spatial-softmax checkpoints (incl. the committed game model) no longer load if the layer is replaced without an option. +(see docs/decisions.md 2026-11-25: spatial softmax removed) diff --git a/.claude/knowledge/comparisons/2026-11-17_hypothesis-sigma-canon-target-holding.md b/.claude/knowledge/comparisons/2026-11-17_hypothesis-sigma-canon-target-holding.md new file mode 100644 index 000000000..743d3fbc1 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-17_hypothesis-sigma-canon-target-holding.md @@ -0,0 +1,23 @@ +# Hypothesis: canon σ / target holding — holding pays but σ 0.5 + sweep make it unreachable (refuted by run 529) + +Runs: 520, 522, 524, 525, 528, 529 + +2026-11-17: target holding pays (1 s = 3 hits) but canon σ 0.5 + sweep make it unreachable; 520/522 hold because the turret is still at σ 0.2; untested hypothesis, options posed. **Refuted 2026-11-18 by run 529** (see end). + +Search for the lever requested by the developer 2026-11-17 after run 528 (« les 5 obus n'ont pas résolu, cherche le vrai levier avec ce CNN et le reward événementiel »). Report: `outputs/train_528_ppo_liquid/levier_visee.md`. No code modified at first. + +Measured facts (probes side 550): +- hits per pass < 5° & < 100 m by duration (528 s9): 0.07 (0.1 s), 0.34 (0.3-0.4 s), 1.04 (0.5-0.9 s), 3.05 (1-1.9 s), 7.5 (≥ 2 s); outside a pass 0.076 hit/s. Cadence in pass ~5 shots/s. The event reward thus pays holding; 0.6-3 % of passes last ≥ 1 s. +- plant: 9.2° + 9.0° per unit of a·|a| over two decisions. Exploration noise: 3.0°/decision at canon σ 0.5 (524/525/528), 1.6-1.7° at σ 0.2 (520/522). Mean command: sweep 3-4°/decision (528, 525) vs 1.0-1.1 (520/522). +- dwell < 5°: 0.37 s untrained network (525 s1) → 0.20 s (528 s14); 520/522: 1.0-1.1 s ≈ simulation of a still turret at σ 0.2 (1.43 s); at σ 0.5 still = 0.38 s, ideal controller 0.96 s. +- canon_x entropy at probe ≈ 0 = target `continuous_target_entropy` for σ 0.53-0.60; alpha_canon_x leaves the floor around 200-300 k (1.3-3e-3 in 524/525/528): the regulator holds σ. Initial rise 0.30 → 0.58 before 135 k = policy gradient (α at floor). 520/522: α_canon_x 0.010-0.017 from 81 k with σ 0.2. + +Hypothesis (Claude's, correlational, untested): at σ 0.5 stopping the sweep gains only +0.15 s on target vs +1.2 s at σ 0.2 ⟹ holding gradient ÷10; separate credit perhaps acted mostly by tightening σ. Counter-indications: ideal controller holds 0.96 s at σ 0.5; 498/433/439 at low σ did not aim (but spatial softmax). + +Options posed to the developer, nothing decided: (1) σ ceiling ≈ 0.25 for both canon actions + lowered canon entropy target; (2) canon target −1 only; (3) temporally correlated exploration noise. Refutation criterion of (1) at save_5: dwell > 0.6 s and tour<5° > 20 %, otherwise the lock is the sweep. + +**Rule:** in every probe, read dwell < 5°, canon σ and mean command in °/decision (scripts to rewrite: passes by duration, regression Δyaw on a·|a|); do not present the hypothesis as established. + +**Coded 2026-11-17 (option 1 validated by the developer, uncommitted, build `build/` + 2 442 agent tests ok):** σ ceiling 0.25 for canon_x/canon_y (`CANON_LOG_SIGMA_MAX`, `FIRST_CANON_ACTION`, `NB_CANON_ACTIONS` in networks/constants.h; `SoftClamp` with one ceiling per action; `log_sigma_upper_bounds` in networks_utils/init) in Actor, SacActor and LiquidActor (the developer's choice: all actors); initial canon σ = min(initial_sigma, 0.20) (the developer's choice: 0.20); default `continuous_target_entropy` = [0, 0, −1, −1] in ppo, ppg, ppo_liquid. Old checkpoints load but their canon σ is reinterpreted by the new binaries: stochastic probe wrong on ≤ 528. Previous probe binaries saved in `outputs/train_528_ppo_liquid/probe_bin/` (launch with `LD_LIBRARY_PATH` on this folder). `cmake-build-release` not rebuilt (528 running there). + +**Refuted 2026-11-18 by run 529 (σ cap):** canon σ held at 0.24 over 729 k, the sweep disappears at the start (s5: 0.9°/decision, dwell 0.47 s) then returns through the command (s27: 3.3°/decision, dwell 0.17 s, below 528) and the trigger closes the same. The lock is the sweep itself, not exploration noise. (see docs/decisions.md 2026-11-21: canon σ cap 0.25 removed) diff --git a/.claude/knowledge/comparisons/2026-11-17_run-524-vs-430-other-pc.md b/.claude/knowledge/comparisons/2026-11-17_run-524-vs-430-other-pc.md new file mode 100644 index 000000000..5fe65ebe3 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-17_run-524-vs-430-other-pc.md @@ -0,0 +1,60 @@ +# 524 (single advantage) vs 430 of the other PC (separate aim credit) + +Runs: 524, 430 (other PC), 522 (reference). +2026-11-17. Both runs have the flattened CNN (cfb76a2e), the same reward, the same economy and the same config, apart from three differences: + +| | 430 other PC | 524 | +|---|---|---| +| code | cfb76a2e | 5c338159 + target_kl 0.10 (= f4702f90) | +| credit of cannon actions | λ-return of Φ (`aim_gae_lambda` 0), no critic | single GAE advantage | +| KL stop | per group (cannon / rest), target_kl 0.05 | single, target_kl 0.10 | +| launched | 16/11 21:36, 446 k at 07:21 (46 k steps/h) | 16/11 22:54, 608 k at 07:00 (75 k steps/h) | + +D milestones: 430 = those of 520/522 (1000 @ 429 k); 524 is one notch late (1000 @ 461 k). Probes come from the same binary (f4702f90); the inference diff with cfb76a2e reduces to one training-side accessor. 430's archive was extracted outside the repo (session temp folder). + +## CSV at equal index + +| index | run | D | hit | kill | fire | r_hit | empty/tank-s | ev | skip | α_fire | +|---|---|---|---|---|---|---|---|---|---|---| +| 100-140 k | 430 | 400-450 | 0.17 | 23.6 | 1.06 | 9.6e-3 | 0.091 | 0.68 | 0.01 | 1e-4 | +| | 524 | 350-400 | 0.15 | 19.9 | 1.04 | 7.6e-3 | 0.078 | 0.60 | 0.25 | 1e-4 | +| 180-220 k | 430 | 550-600 | 0.27 | 22.7 | 0.52 | 7.5e-3 | 0.029 | 0.71 | 0.17 | 1e-4 | +| | 524 | 500-550 | 0.20 | 19.2 | 0.62 | 5.6e-3 | 0.037 | 0.65 | 0.27 | 1e-4 | +| 300-340 k | 430 | 800-850 | 0.36 | 19.4 | 0.30 | 4.5e-3 | 0.009 | 0.76 | 0.24 | 1e-4 | +| | 524 | 750-800 | 0.26 | 12.3 | 0.21 | 2.9e-3 | 0.012 | 0.73 | 0.20 | 2e-4 | +| 420-446 k | 430 | 1000 | 0.38 | 17.8 | 0.23 | 3.6e-3 | 0.006 | 0.80 | 0.21 | 1e-4 | +| | 524 | 950 | 0.26 | 9.0 | 0.20 | 1.8e-3 | 0.006 | 0.74 | 0.24 | 1.9e-2 | + +430 at D 1000 is at the level of 522 (kill 15-17, hit 0.35-0.40); 524 at D 1000: kill 6-10, hit 0.17-0.20. + +## Probes at the same saves (side 550 / side 1000) + +| save | run | turret<5° | aligned shots | hit/shell | hits/tank-s | ratio | p_al | σ cannon | \|μ\| cx | disarmed | +|---|---|---|---|---|---|---|---|---|---|---| +| s5 (135 k) | 430 | 29.3 / 23.5 % | 45 / 35 % | 20.0 / 11.4 % | 0.171 / 0.073 | 3.2 / 3.9 | 0.27 / 0.29 | 0.34-0.42 | 0.18 | 16 / 20 % | +| | 524 | 15.7 / 13.5 % | 24 / 20 % | 11.4 / 7.4 % | 0.125 / 0.058 | 4.2 / 6.0 | 0.74 / 0.77 | 0.44-0.53 | 0.47-0.54 | 36 / 39 % | +| s9 (243 k) | 430 | 33.7 / 22.2 % | 61 / 50 % | 34.9 / 27.8 % | 0.101 / 0.046 | 10 / 14 | 0.14 / 0.15 | 0.36-0.50 | 0.20-0.22 | 1 / 1 % | +| | 524 | 12.4 / 14.8 % | 28 / 22 % | 32.4 / 22.3 % | 0.068 / 0.016 | 25 / 54 | 0.31 / 0.24 | 0.59-0.61 | 0.53 | 2 / 1 % | +| s16 (432 k) | 430 | 40.3 / 31.0 % | 67 / 66 % | 47.3 / 44.1 % | 0.093 / 0.060 | 5.7 / 18 | 0.06 / 0.09 | 0.30-0.42 | 0.20 | 0.1 % | +| | 524 | 10.1 / 9.1 % | 30 / 23 % | 28.0 / 22.7 % | 0.072 / 0.020 | 31 / 67 | 0.37 / 0.41 | 0.51-0.56 | 0.43 | 4 / 3 % | +| *522 s16* | | 45.1 / 36.9 % | 71 / 74 % | 46.2 / 44.1 % | 0.075 / 0.035 | 7.2 / 14 | 0.04 / 0.03 | 0.25-0.35 | 0.17-0.18 | 0.1 % | + +## Reading + +Established: +- **Aim depends on the separate credit.** turret<5° rises in 430 (29 → 34 → 40 % side 550) and falls in 524 (16 → 12 → 10 %); ×4 gap at s16, monotone over 3 saves and 2 sides. The share of aligned shots follows (67 % versus 30 %). +- **The flattened CNN is not the cause of 524's failure**, and it helps at the start: at s5, 430 already has turret<5° 29 % (522 at same index: 13 %) and hit/shell 20 % (13.5 %). At s16, 430 ≡ 522 in precision (47/44 % versus 46/44 %) with a higher hit throughput (0.093/0.060 versus 0.075/0.035). +- **Skip does not separate the runs**: 430 cuts 17-24 % of the non-cannon minibatches from 180 k (7-10 % cannon side) and 524 20-33 %. New versus 522 (skip 0), common to both flattened-CNN runs. +- **524's trigger is sharper**: ratio 25-67 and p_al 0.3-0.4 versus 6-18 and 0.06-0.15 in 430. The on-axis dip of 520/522 is present in 430 (p_al 0.27 → 0.14 → 0.06), absent from 524. +- **α_fire** stays at the floor in 430; it lifts only in 524, where the gain per shot is low. + +Not settled: +- 524's sharp trigger: effect of the single advantage on the trigger, or mere consequence of rare opportunities (few aligned and near states, hence all fired); +- single advantage and single KL stop remain confounded in 524; the joint threshold does not explain aim (skip comparable), but it is not isolated; +- 430 has only 17 k steps at D 1000: its cruise holding (axis recovery like 520/522) remains to be seen. + +## Options (no decision) + +- Let 430 run and probe it at s20-s24 (522 s24 references: hits/tank-s 0.154/0.069, hit/shell 36 %, disarmed 1 %). +- Stop 524: aim has regressed since 135 k and the relaxation is installed at s22. +- If 524's sharp trigger is of interest: measure p_fire aligned & near at equal sample size in 430 before seeing an effect of the single advantage. diff --git a/.claude/knowledge/comparisons/2026-11-17_trigger-closed-at-range-lock.md b/.claude/knowledge/comparisons/2026-11-17_trigger-closed-at-range-lock.md new file mode 100644 index 000000000..9094dba64 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-17_trigger-closed-at-range-lock.md @@ -0,0 +1,16 @@ +# Lock: trigger closed at range (single advantage = hits at < 50 m only) + +Runs: 522 (reference), 524, 525, 526 + +2026-11-17: single advantage (524-526) = hits at < 50 m only (60-75 %), trigger closed beyond 50 m before long-range aim is learned, hit/shot curriculum satisfied by this closure ⟹ kills ÷2 when D rises. + +Measurement 2026-11-17 on existing probes, by target distance at the shot (`outputs/train_526_ppo_liquid/diagnostic_portee.md`), 524/525/526 vs 522 (separate aim credit): + +- hits/tank-s side 550: single advantage 0.05-0.06 at < 50 m and 0.002-0.007 at 50-100 m (falling from save to save); 522: the 50-100 m band rises from 0.023 (s5) to 0.055 (s24) and equals the close one; +- hit of an aligned shot < 5°: > 70 % at < 50 m everywhere (41 % even without aiming); at 50-100 m 25-35 % without progress (single advantage) vs 38 → 62 % (522); +- p_fire on aligned target: 525 s9 0.38 at < 50 m, 0.14 at 50-100 m, 0.04-0.07 beyond; 522 s9 0.11 / 0.14 / 0.06-0.09 with 6-10× more aligned states at 50-100 m; +- enemy at < 50 m: 40 % of the time side 550, 9-18 % side 1000. + +Reading (Claude's, by run comparison, not intervention): the trigger, the clearest signal, closes beyond 50 m between 135 k and 243 k; fewer shells at range ⟹ fewer events to learn long-range aim; the curriculum criterion (hits/shots > 0.08, `curriculum_ratio_high`) is satisfied by this closure, D rises, close encounters become rare, kill 18 → 8. The batch 2400 of run 526 changes nothing in this mechanism; the « per-step noise » hypothesis of the run 525 audit (event-only, Φ removed) is thus insufficient. + +**Rule:** read any probe by distance band (hits/tank-s and aligned hit at 50-100 m), not only tour<5° nor the ratio aligned & < 40 m, which rewards exactly the « point blank » policy. Options posed to the developer 2026-11-17, not decided: curriculum criterion on hit throughput or kills; keep the trigger open at range while aim is learned; separate aim credit. diff --git a/.claude/knowledge/comparisons/2026-11-18_coloured-ar1-exploration-noise.md b/.claude/knowledge/comparisons/2026-11-18_coloured-ar1-exploration-noise.md new file mode 100644 index 000000000..989534b96 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-18_coloured-ar1-exploration-noise.md @@ -0,0 +1,12 @@ +# Coloured AR(1) exploration noise — coded 2026-11-18, removed 2026-11-19 + +Runs: 529, 530, 531, 532, 533, 534, 536, 537, 538 + +2026-11-18: hypothesis retained after the failure of the critic-side pilots (530-532): per-decision white Gaussian noise (1.2°/0.1 s) produces no different events, so the event reward does not reach the turret (dwell 0.17 s, tour<5° 8.5 % vs 21-27 % for 520/522 — probes 529 s27, the gap is not a curriculum artefact). The developer chose coloured AR(1) noise over strict gSDE, ρ 0.9 default (`--noise_correlation`), on wheels + turret. Actor batch 2400 refused (« ça tacle pas le pb »). + +Code (uncommitted): `distributions/colored_noise.{h,cpp}`, shared agent + collector; marginal law, log-prob, entropy and α unchanged; reset at each trajectory start (episode end, done or truncated per tank — requested by the developer: independent trajectories); game (factory.cpp) passes 0 since deterministic; probe.cpp reads `noise_correlation` from config (0 if absent, SAC). + +**Why:** the developer refuses Φ because it imposes a target, not on principle against a dense signal; they want an irrefutable event reward. +Run 532 killed at 249 k (D 450, never measured at D 550). The developer launched the next run themself in CLion. Judge on probes: dwell < 5°, tour<5°, at equal D. See comparisons/2026-11-18_critic-blind-to-aiming-gesture.md. + +**Removed 2026-11-19 (the developer's request after control 538):** class `ColoredNoise`, option `--noise_correlation`, overload `gaussian_tanh_sample(mu, sigma, noise)` and tests deleted from the 3 PPO agents, the probe and `sigma_gradients` (uncommitted, agent tests green in `build/`). Reason: white noise ≥ coloured at equal config, the policy cancels coloured noise, KL regime (runs 537, comparisons/2026-11-19_aim-gesture-state-vs-events-signal.md). Never propose again. Checkpoints 533-537 are now probed in white noise. (see docs/decisions.md 2026-11-21: removed in `0137ae77`) diff --git a/.claude/knowledge/comparisons/2026-11-18_critic-blind-to-aiming-gesture.md b/.claude/knowledge/comparisons/2026-11-18_critic-blind-to-aiming-gesture.md new file mode 100644 index 000000000..108d9d055 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-18_critic-blind-to-aiming-gesture.md @@ -0,0 +1,36 @@ +# Critic blind to the aiming gesture (528/529) and pilots 530-532 + +Runs: 528, 529, 530, 531, 532 + +2026-11-18, 528/529: run V does not move when the turret aligns (slope ÷10 to ÷50 vs geometric value), response spread over 4 s; critic CNN not at fault as measured first (AUC ≡ actor — later corrected, see below); event signal present (ρ 0.08-0.12 at λ ≤ 0.3 on 528 s9). Report: `outputs/comparisons/2026-11-18_leviers_avantage_unique/rapport.md` (scripts `credit.py`, `total_signal.py`, `vsens.py`, `vkernel.py`, `decode.py`, `gamma_share.py`). + +Measured facts (528 s1-s14, 529 s9/s27, frozen policies): +- Run V per 10° of yaw approach (armed, no shot): 0.000-0.04; value fitted on geometry: 0.09-0.30. ρ(run advantage, gesture) ≈ 0 at λ 0, 0.005-0.02 at λ 0.95; exploitable share of advantage per continuous head ≤ 0.013. +- With the geometric value as critic: ρ yaw 0.076, elevation 0.116 at λ 0.3 on 528 s9 (Φ level), 0.02-0.03 at λ 0.95; 0.02-0.04 when the trigger is closed (529 s9/s27). +- Critic CNN: AUC aligned < 5° vs 10-39° 0.75-0.79, ≡ actor (untrained 0.58-0.67). +- V responds to present alignment with weight 0.12 (reference 0.9-1.1), the rest spread uniformly over 4 s. +- Critic target: angles = 6-12 % of return variance at γ 0.998, 25 % at γ 0.95. Critic liquid-cell input weights ×5 those of the actor, critic τ slowing (p90 1.9 → 2.7 s), actor at init. +- CSV `ev` (0.75-0.84) is a fit on training rows against a target containing V; out-of-sample corr(V, MC return) = 0.26. +- Measurement trick: config copied with gamma 0 and gae_lambda 0 ⟹ `advantage` column of sigma_gradients = −V up to a per-rollout affine. + +Not settled: cause of the slow response (liquid cell, γ horizon, critic optimisation regime 8 epochs × lr 3e-4). Critic of 520/522 not measured. + +**Rule:** (see docs/decisions.md 2026-11-18: asymmetric critic refused) look for levers on the critic learning side from the image. In a script, never `pgrep -f`/`pkill -f` the name of a script present in the current shell's command line (an hour lost 2026-11-18). + +**Pilot 530 (2026-11-18, 529 + critic_epochs 2 + critic_learning_rate 1e-4, only difference verified by config diff):** at save_3 and save_5 V slope stays zero (s5: −0.001 to +0.007 per 10°; reference 0.11-0.13), share at delays 0-0.1 s 16 % then 12 % (529: 31 / 25 %), while critic input weights stay small (0.19 vs 1.12) and τ at init. ⟹ critic over-training is not the cause; remaining: target horizon (γ) and liquid cell. CSV ≡ 529 at 143 k. + +**Pilot 531 (2026-11-18, 529 + gamma 0.99, only difference):** V slope zero at s3 and s5 (−0.005 to +0.004 per 10°; reference 0.07-0.14), weight on present alignment 0.01 then 0.07 (529: 0.18 / 0.12); degraded actor (kill 1.8 at 100 k vs 18, D stayed 250 at 140 k). ⟹ γ horizon is not the cause either; do not re-propose γ 0.99. Remaining: image → V path (critic liquid cell), untested, architecture choice for the developer to validate. + +**Offline measurement (2026-11-18, `vhead.py` / `vdistill.py`, 24 episodes of 529 s9, sigma_gradients `--critic_inputs` export uncommitted):** a memoryless value head retrained on the frozen output of the critic CNN + proprio is as blind as the run's critic (slope −0.008 to +0.006 per 10°, reference 0.15) ⟹ the liquid cell is NOT the lock. The critic CNN output barely contains alignment: AUC aligned < 5° vs 5-40° 0.66 (proprio alone 0.57), reference distillation R² 0.12. The « critic CNN not at fault » above is false: it only showed critic ≡ actor. Lock = what the CNN encodes; untested: CNN trained end to end on an alignment-dependent target. + +**End-to-end CNN offline (2026-11-18, `vcnn.py`, 272 k images of 529 s9, sigma_gradients `--frames` export uncommitted):** same 7-block CNN + memoryless head. Target = geometric reference ⟹ slope +0.05 to +0.07 per 10° from the 1st pass (reference 0.11-0.13), AUC alignment 0.75, limited by overfitting. Target = Monte-Carlo return ⟹ slope ≈ 0, the network memorises noise (loss 0.13 fit / 0.95 test). ⟹ neither CNN architecture nor cell: it is the signal-to-noise ratio of alignment in the critic target (6-12 % of return variance). Look for levers there, without auxiliary head, asymmetric critic or Φ (refused). + +**Short-horizon value head offline (2026-11-18, validated by the developer as a lead: « j'aime bien »):** same protocol, one head per γ on the same CNN. Alignment AUC read in the CNN: γ 0.998 0.67; 0.99 0.72; 0.95 0.77; 0.9 0.78 (geometric target 0.75). Short-head slope +0.05 per 10° (a quarter of its reference). Double head 0.998 + 0.9/0.95: the long head goes from ~0 to +0.02-0.03 (reference 0.09-0.11). Positive but partial; one seed; partly contradicted by 531 (γ 0.99 online no effect). Not yet coded in training. + +**Pilot 532 (2026-11-18, launched ~16:50):** 529 + `--short_gamma 0.9` (only difference). Uncommitted code: second output `to_short_value` of LiquidCritic (same cell), TD(λ) target at short γ with its own ReturnScaler (`short_return_scaler.pt`), summed losses, advantage unchanged (γ 0.998 head); option disabled by default (0), test `ShortValueHeadTrainsAndReloads`. Binary `build/arenai_agent/arenai_agent_train`. Criterion: V slope (long head) at saves 3 and 5 vs 529 (`data/pilote_532_s*.txt`), then CSV at equal D. + +**2026-11-18 evening, the developer's request:** short head enabled by default (`short_gamma` 0.9) for ppo, ppo_liquid and ppg, before the 532 verdict. PPO/PPG: `ValueFunction::value` returns [B, 2] (column 0 = long γ), one loss per column summed, advantage and `ev`/`v` on column 0, PPG distillation on column 0. `sigma_gradients` sets short_gamma 0 for runs whose config lacks the field (≤ 531). Uncommitted, 2443 tests OK. + +**2026-11-18 ~17:50, the developer's decision:** permanent short head (no disable option), no compatibility with old checkpoints (« pas besoin d'être compatible »), SOLID / single responsibility, anticipate without waiting for 532's proof. Refactor: class `ValueTargets` (`agents/value_targets.{h,cpp}`, module saved as `return_scaler.pt`) = λ targets per head with own γ and normaliser; critics with `nb_values` outputs (single `to_value`); the 3 trainers delegate; `--short_gamma` 0.9 default. `build/` probes no longer load runs ≤ 532: 532 probe binaries kept in `outputs/train_532_ppo_liquid/probe_bin` (collect.sh picks them if the folder exists). Pre-existing unstable test: `TruncatedNormalEdgeTest.LogPdfAndPdfConsistent` (~10 % failures). + +**Pilot 532 (short head γ 0.9), save_3/5, 2026-11-18 evening:** negative at this stage. Long head +0.013 to +0.015/10° (529: −0.001 to +0.026), short head itself +0.003 to +0.016 (γ 0.9 reference: +0.15), delay 0 = 0.00; critic CNN → aligned AUC 0.55 (529 s5: 0.60-0.63). CSV: trough 40-70 k then ≡ 529 at 138 k but D 250 still at 142 k. Gap with the offline test (+0.05) unexplained: offline = D 550 policy, re-initialised CNN, MC target. Details: rapport.md §10 of folder 2026-11-18_leviers_avantage_unique. `bc` absent on the machine. diff --git a/.claude/knowledge/comparisons/2026-11-18_single-advantage-levers-why-aim-not-learned.md b/.claude/knowledge/comparisons/2026-11-18_single-advantage-levers-why-aim-not-learned.md new file mode 100644 index 000000000..f854038cb --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-18_single-advantage-levers-why-aim-not-learned.md @@ -0,0 +1,194 @@ +# Single advantage + event reward + flattened CNN: why aim is not learned + +Runs: 528 (s1, s3, s5, s9, s14), 529 (s9, s27), pilots 530, 531, 532. +Date: 2026-11-18. Checkpoints probed at side 550 except the first saves (side = the run's D). Collection: `arenai_agent_sigma_gradients` (run's binary, no code modified), 12 episodes per configuration at λ 0.95 and λ 0, 6 episodes at γ 0 / λ 0 (in that case the advantage equals −V up to an affine transformation: the only way to read V without touching the tool). Scripts in `outputs/comparisons/2026-11-18_leviers_avantage_unique/` (`vsens.py`, `total_signal.py`, `credit.py`, `decode.py`, `vkernel.py`, `gamma_share.py`, `measure_pilot.sh`, `vhead.py`, `vdistill.py`, `vcnn.py`, `vshort.py`, `vlag.py`, `vprofile.py`, `early.sh`, `collect.sh`, `cfg/`), outputs in `outputs/comparisons/2026-11-18_leviers_avantage_unique/data/`. + +## 1. The critic does not see the aiming gesture + +Variation of V when the turret approaches the target (armed tank, no shot, no event), in standard deviations of V per rollout, per 10° of approach (`vsens.py`): + +| checkpoint | band | run's V | value fitted on geometry | +|---|---|---|---| +| 529 s9 | < 50 m | 0.000 to +0.007 | +0.09 to +0.12 | +| 529 s9 | 50-100 m | −0.002 to +0.004 | +0.06 to +0.10 | +| 528 s9 | < 50 m | +0.02 to +0.04 | +0.28 to +0.30 | +| 528 s9 | 50-100 m | +0.005 to +0.009 | +0.15 to +0.16 | +| 529 s27 | < 50 m | +0.004 to +0.012 | +0.16 to +0.18 | + +The "geometric value" is an MLP fitted offline on the Monte-Carlo return from the nearest enemy's geometry (out-of-fold per episode). It is a measuring standard, not a proposal. + +Consequence: ρ(run advantage, corrective gesture) = −0.002 to +0.005 at λ 0, 0.005 to 0.010 at λ 0.95. Share of the advantage exploitable by a gradient, per head (`total_signal.py`, standard error 0.002): + +| checkpoint | dir_x | dir_y | canon_x | canon_y | +|---|---|---|---|---| +| 528 s1 | −0.006 | 0.000 | +0.012 | +0.010 | +| 528 s5 | 0.000 | +0.012 | +0.008 | +0.007 | +| 528 s9 | −0.002 | +0.002 | +0.013 | +0.004 | +| 529 s9 | −0.005 | 0.000 | +0.004 | +0.002 | +| 529 s27 | +0.003 | −0.001 | +0.004 | 0.000 | + +## 2. The signal exists in the events + +Same measurement with the geometric standard as critic (`credit.py`), ρ with the corrective gesture: + +| checkpoint | yaw < 100 m, λ 0.3 | elevation, λ 0.3-0.6 | at λ 0.95 | run advantage | +|---|---|---|---|---| +| 528 s1 | 0.030 | 0.067 | 0.027 / 0.044 | 0.021 / 0.024 | +| 528 s5 | 0.055 | 0.054 | 0.019 / 0.030 | 0.010 / 0.033 | +| 528 s9 | 0.076 | 0.116 | 0.020 / 0.032 | 0.008 / 0.011 | +| 529 s9 | 0.025 | 0.037 | 0.017 / 0.007 | 0.010 / 0.007 | +| 529 s27 | 0.020 | 0.021 | 0.005 / 0.009 | 0.005 / 0.012 | + +528 s9 (trigger open at 50-100 m) reaches the level of the former separate credit (one-step Φ: 0.08-0.10). The signal drops when the trigger closes (529 s27). + +## 3. Where information is lost in the critic + +**Not in the CNN.** (Corrected in §7: this showed only that the critic encodes no less than the actor, on an easier contrast.) Linear probe on CNN features (`decode.py`, 32 k images of 529 s9, fitted on one episode, evaluated on the other), AUC "aligned < 5° versus 10-39°", enemy < 100 m: + +| CNN | block 4 | block 5 | block 6 | output 1×2 | +|---|---|---|---|---| +| critic | 0.784 | 0.787 | 0.783 | 0.751 | +| actor | 0.773 | 0.753 | 0.759 | 0.737 | +| untrained | 0.672 | 0.649 | 0.623 | 0.578 | + +The critic encodes alignment as much as the actor, whose trigger is selective. Modest level in both (0.75); linear-probe regression of |yaw| is unstable (negative R²), inconclusive. + +**In the temporal response.** Distributed-lag regression of V on alignment (target < 10° and < 100 m) at lags 0 to 4 s (`vkernel.py`): + +| checkpoint | run's V: weight at lag 0 | share at lags 0-1 | standard: weight at lag 0 | share 0-1 | +|---|---|---|---|---| +| 529 s9 | +0.12 | 18 % | +0.91 | 63 % | +| 528 s9 | +0.13 | 31 % | +1.12 | 59 % | +| 529 s27 | +0.11 | 14 % | +0.38 | 35 % | + +The critic responds to present alignment 3 to 9 times too little and spreads the rest uniformly over 4 s (weight at 3-4 s as large as at 0 s in 529). It knows "an enemy has been in front for a while", not "the turret just aligned". + +**Clues on the cause** (correlational, not settled): + +- Critic target: at γ 0.998 (horizon 50 s) angles explain 6 to 12 % of the return variance; 12-17 % at γ 0.99; 25 % at γ 0.95 (`gamma_share.py`). Most of the target is long-horizon noise. +- Liquid cell weights: critic input norms 5 times the actor's (1.4-2.5 versus 0.3-0.46), rising from s9 to s27; critic τ slowing (p50 0.47 → 0.65 s, p90 1.88 → 2.66 s) while the actor's stays at init (0.42 / 1.4 s). In the actor vision enters mostly through fast neurons (correlation −0.72 with log τ); in the critic this structure has disappeared (−0.1). +- The critic does 8 epochs at lr 3e-4 (actor: 4 epochs at 1e-4) on these targets. CSV `ev` is measured on rows being fitted, against a target that contains V: 0.75-0.84 whereas out-of-sample corr(V, Monte-Carlo return) = 0.26 (R² 0.07; standard: 0.33). + +## 4. Other measurements + +- Actor latency: corr(yaw, setpoint) maximal at lag +1 decision in 528/529, 0 in 520/522; same order of gain. The turret tracks, but the mean setpoint vanishes with the target at +5-8° off axis (529 s14/s27) and commands in the cone are 5-7° per decision (520/522: 0.8-1.8°). +- Return variance: hits 70-80 %, kills 10 %, damage received 6-8 %, death 4-6 %, empty reserve 0.4-6 %. + +## 5. Limits + +- Everything is measured on frozen policies; nothing tested in training. +- The geometric standard knows only the nearest enemy, neither reserve nor life. +- The critic of 520/522 was not measured (old binaries): unknown whether it was as slow. +- Proprioception not being exported, the critic was not replayed offline: the exact cause of the slow response (liquid cell, target horizon, optimisation regime) remained to settle. + +## 6. Training pilots (2026-11-18) + +Two runs starting from the 529 config, one single difference each (verified by diff of `config.json`), critic measured at saves 3 and 5 (`measure_pilot.sh`, outputs `data/pilote_53*.txt`, `data/reference_529_s3_s5.txt`). Slope of V per 10° of approach, enemy < 50 m: + +| run | difference | s3: run's V | s3: standard | s5: run's V | s5: standard | share lags 0-0.1 s (s3 / s5) | +|---|---|---|---|---|---|---| +| 529 | — | +0.008 to +0.024 | 0.15 | −0.001 to +0.026 | 0.13-0.17 | 31 % / 25 % | +| 530 | critic epochs 2, lr 1e-4 | +0.005 to +0.036 | 0.16-0.18 | −0.001 to +0.007 | 0.11-0.13 | 16 % / 12 % | +| 531 | γ 0.99 | −0.005 to +0.004 | 0.11-0.14 | −0.003 to +0.004 | 0.07-0.14 | null response / 27 % | + +Weight of V on present alignment: 529 0.18 / 0.12, 530 0.12 / 0.11, 531 0.01 / 0.07 (standard 0.2-0.7). Neither pilot straightens the slope. + +- 530: critic input weights stayed small (0.19 versus 1.12), τ at init, CSV ≡ 529 up to 190 k ⟹ the critic's optimisation regime is not the cause. +- 531: the short horizon does not help the critic and degrades the actor: kill 9.5 → 1.8 at 100 k (529: 18), D stayed at 250 at 140 k (529: 300, 530: 350), Hc −0.37 from 100 k ⟹ the target horizon is not the cause. + +Remaining, among the three causes of section 5: the image → V path itself: V reads the image only through the liquid cell. Untested at that point. + +## 7. Offline measurement: the liquid cell is not the lock (2026-11-18) + +`arenai_agent_sigma_gradients --critic_inputs ` (option added, uncommitted) exports at each step the proprioception and the critic's CNN output. 24 episodes of 529 s9 at side 550 (821 k living rows), 18 for fitting, 6 never seen for measurement. Value heads retrained on these frozen inputs against the Monte-Carlo return (`vhead.py`, 40 passes, 2 seeds): + +| value head | corr(V, return) | slope of V per 10° (< 50 m) | weight at lag 0 | +|---|---|---|---| +| geometric standard | 0.30 | +0.14 to +0.15 | 0.74 | +| run's critic, replayed in Python | 0.27 | +0.004 to +0.010 | 0.13 | +| memoryless (MLP on the step's input) | 0.27 | −0.008 to +0.006 | 0.16 | +| liquid cell reinitialised | 0.13-0.19 | +0.002 to +0.015 | 0.13-0.15 | +| cell + direct input → V path | 0.15-0.19 | +0.003 to +0.013 | 0.13-0.15 | +| run's critic fine-tuned on the return | 0.17 | 0.000 to +0.004 | 0.13-0.14 | + +A head with no memory at all is as blind as the run's critic: the cell is not at fault. Recurrent heads overfit (576 sequences: fit loss 0.25-0.38, test worse than the run's critic), so their row is little informative. + +What the critic's CNN output contains (`vdistill.py`, MLP 2×512 without memory, test): + +| input | AUC aligned < 5° vs 5-40° (< 100 m) | R² of standard distillation | slope of distilled V | +|---|---|---|---| +| CNN features + proprio | 0.66 | 0.12 | +0.02 | +| CNN features alone | 0.67 | −0.03 | +0.02 to +0.04 | +| proprio alone | 0.57 | −0.02 | +0.01 to +0.03 | + +Even given the standard as target, the critic's CNN 1×2×128 output allows reconstructing only 12 % of it, and the slope stays 4 to 7 times below the standard. The lock is thus upstream of the cell: alignment is almost absent from what the critic's CNN transmits. Section 3 ("not in the CNN") is to be corrected: it showed only that the critic encodes no less than the actor, on an easier contrast (< 5° versus 10-39°, AUC 0.75). + +Limit: frozen CNN. This measurement does not say whether the CNN can learn alignment when trained on a target that depends on it, nor why the run's value loss does not lead it there. + +## 8. CNN trained end to end offline: it is the target, not the architecture (2026-11-18) + +`--frames` added to `arenai_agent_sigma_gradients` (uncommitted). 24 episodes of 529 s9, one image in three: 272 k images (206 k fit, 66 k test on 6 never-seen episodes). The run's CNN (7 blocks, output 1×2×128) + proprio + memoryless head, 8 passes (`vcnn.py`, outputs `data/vcnn_529_s9_*.txt`). Test measurements, slope at 0.3 and 0.6 s: + +| target | starting CNN | slope of V per 10° | weight at lag 0 | AUC aligned < 5° | fit / test loss | +|---|---|---|---|---|---| +| geometric standard (reference) | — | +0.11 to +0.13 | 0.84 | — | — | +| run's critic, replayed | — | +0.01 to +0.03 | 0.10 | 0.66 (section 7) | — | +| standard | reinitialised | +0.05 | 0.38 | 0.74 | 0.21 / 0.85 | +| standard | run's CNN | +0.06 to +0.07 | 0.43 | 0.75 | 0.24 / 0.81 | +| Monte-Carlo return | reinitialised | +0.01 | 0.13 | 0.64 | 0.13 / 0.95 | +| Monte-Carlo return | run's CNN | −0.03 to 0.00 | 0.13 | 0.70 | 0.14 / 0.88 | + +- With a target that depends on alignment, this CNN learns to read it from the first pass (slope +0.05 to +0.06) and reaches half the reference, limited by overfitting (206 k images). The architecture is thus not the lock. +- With the return as target, same images, same network: null slope, the network memorises return noise (fit loss 0.13, test 0.95) and does not extract alignment. That is what the run's critic does. + +Conclusion: the critic does not learn aim because the part of the return explained by alignment (6-12 % of variance at γ 0.998) is too weak against noise to shape the CNN, not because the CNN or the cell are incapable. + +Limits: offline on a fixed set of 206 k images (the run sees millions of fresh samples, but its critic stays at +0.01-0.03 after 7.8 M tank-steps); one checkpoint; one seed per configuration; the standard is a noiseless target, the most favourable case. + +## 9. Short-horizon value head, offline (2026-11-18) + +Same protocol as section 8 on a new collection (24 episodes of 529 s9, 272 k images), CNN reinitialised, 6 passes, one head per γ on the same CNN (`vcnn.py`, config `<γ>+<γ>:scratch:7`, outputs `data/vcnn_529_s9_g*.txt`). On this set: standard fitted on γ 0.998 slope +0.09 to +0.11, run's critic +0.011. Values at the last pass, slope at 0.3 and 0.6 s: + +| heads trained | slope of short head | slope of γ 0.998 head | AUC aligned < 5° read in CNN | fit / test loss | +|---|---|---|---|---| +| γ 0.998 alone | — | +0.01 / −0.00 | 0.67 | 0.19 / 1.07 | +| γ 0.99 alone | +0.05 / +0.04 | — | 0.72 | 0.25 / 1.00 | +| γ 0.95 alone | +0.05 / +0.05 | — | 0.77 | 0.35 / 0.83 | +| γ 0.9 alone | +0.06 / +0.05 | — | 0.78 | 0.38 / 0.82 | +| γ 0.998 + 0.95 | +0.05 / +0.04 | +0.03 / +0.02 | 0.75 | — | +| γ 0.998 + 0.9 | +0.05 / +0.05 | +0.02 / +0.03 | 0.74 | 0.31 / 0.93 | + +- Alignment read in the CNN grows monotonically as the horizon shortens (0.67 → 0.78); at γ 0.9-0.95 the CNN encodes it as much as with the geometric target (0.75), without geometry. +- The short head reaches +0.05 per 10°, a quarter of its own standard (+0.18 to +0.20): the signal is learned but stays attenuated. Weight at lag 0: 0.20-0.24 (standard 1.04). +- With two heads, the γ 0.998 head goes from ~0 to +0.02-0.03 (2 to 3 times the run's critic), far from its standard (+0.09 to +0.11): the CNN is better shaped, the long head benefits only in part. + +Limits: one seed, slope noisy by ±0.02 from one pass to the next, overfitting on 206 k images, memoryless head, Monte-Carlo target (the run uses TD(λ) with the liquid cell). Offline γ 0.99 gives a slope, whereas pilot 531 (γ 0.99 in training) gave none at saves 3 and 5: an offline result does not guarantee the effect in training. + +## 10. Pilot 532: short head γ 0.9 in the run — negative at save_5 (2026-11-18) + +532 = 529 + a second value head at γ 0.9 (own TD(λ) target and normaliser, losses summed, advantage unchanged on the γ 0.998 head). Measured at save_3 and save_5 (D = 250). + +| slope of V per 10° (< 50 m, k = 3 and 5) | save_3 | save_5 | +|---|---|---| +| 529, single head | +0.008 to +0.024 | −0.001 to +0.026 | +| 532, long head | +0.013 to +0.037 | +0.013 to +0.015 | +| geometric standard (532) | +0.14 to +0.24 | +0.20 | + +Weight at lag 0 of the long head: 0.03 then 0.01 (standard 0.55 then 0.92). + +The two heads of 532 s5 replayed on 24 episodes (`vshort.py`, `data/vshort_53{2,9}_s5.txt`): + +| at save_5 | 529 (D 300) | 532 (D 250) | +|---|---|---| +| long head, slope /10° | +0.002 to +0.029 | 0.000 to +0.012 | +| short head, slope /10° | — | +0.003 to +0.016 | +| short head, weight at lag 0 | — | 0.00 | +| standard fitted on the γ 0.9 return, slope | — | +0.14 to +0.16 | +| critic CNN output → aligned < 5° (AUC) | 0.60-0.63 | 0.55 | +| standard distillation from CNN + proprio (R²) | 0.17 | 0.02 | + +The short head itself does not see alignment, and 532's critic CNN encodes it rather less than 529's at the same age. The expected mechanism (section 9: +0.05/10° on the short head offline) did not take in the run. The short head follows its γ 0.9 target less well than the long head (corr 0.45 versus 0.50): it learned nothing of its own. + +CSV: trough from 40 k to 70 k (kill 6 versus 9-13), recovery at 138 k (kill 20.8, hit 12.7 %), but D still at 250 at 142 k (529: 300 at 114 k; 530: 300 at 67 k). + +Reservations: one seed, different D (250 versus 300), only 135 k steps; the offline test was on a D 550 policy (529 s9), reinitialised CNN, Monte-Carlo target rather than normalised TD(λ). The `ValueTargets` rework (permanent head in ppo / ppo_liquid / ppg) is coded, uncommitted; no unit test covers `ValueTargets::compute`. diff --git a/.claude/knowledge/comparisons/2026-11-18_skip-kl-rise-507-535.md b/.claude/knowledge/comparisons/2026-11-18_skip-kl-rise-507-535.md new file mode 100644 index 000000000..a86d4e687 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-18_skip-kl-rise-507-535.md @@ -0,0 +1,72 @@ +# Why skip rises — runs 507 to 535 (ppo_liquid) + +Runs: 507-510, 522, 523-535 (ppo_liquid); checkpoints 529, 534, 535 for the KL breakdown. +Date: 2026-11-18 (file mtime 2026-11-19; direct measurement section dated 2026-11-19). +Question: does the skip rise come from the hyperparameters changed since the removal of the separate aim credit (commit 5c338159, run 523)? + +## kl / clip / skip at equal index (cells: kl / clip / skip) + +| run | change | kl target | 2 k | 20 k | 80 k | 150 k | +|---|---|---|---|---|---|---| +| 507-508 | single advantage, CNN 4 blocks + spatial softmax | 0.05 | 0.005 / 0.07 / 0 | 0.010 / 0.15 / 0 | 0.011 / 0.16 / 0 | 0.013 / 0.18 / 0 | +| 509 | + factorised credit, single KL stop | 0.05 | 0.013 / 0.20 / 0 | 0.028 / 0.32 / 0.08 | 0.032 / 0.32 / 0.36 | 0.027 / 0.28 / 0.41 | +| 510-522 | + per-group KL stop (skip = rest, skip_canon apart) | 0.05 | 0.009-0.015 | skip 0, cannon 0.02-0.09 | skip 0, cannon 0.14-0.22 | skip 0, cannon 0.10-0.18 | +| 523 | removal of separate credit + CNN 7 blocks flattened | 0.05 | 0.008 / 0.13 / 0 | 0.024 / 0.27 / 0.01 | 0.031 / 0.27 / 0.24 | – | +| 524-525, 528-532 | kl target 0.10 | 0.10 | 0.008-0.010 / 0.12-0.16 / 0 | 0.025-0.028 / 0.28-0.31 / 0 | 0.051-0.059 / 0.31-0.40 / 0.03-0.09 | 0.055-0.060 / 0.30-0.37 / 0.27-0.37 | +| 526 | actor batch 2400 | 0.10 | 0.002 / 0.02 / 0 | 0.007 / 0.10 / 0 | 0.011 / 0.14 / 0 | 0.011 / 0.10 / 0 | +| 533-534 | coloured noise ρ 0.9 | 0.10 | 0.026-0.030 / 0.31-0.34 / 0-0.10 | 0.061 / 0.39 / 0.29 | 0.069-0.072 / 0.37-0.39 / 0.54-0.58 | – | +| 535 | + actor lr 5e-5 | 0.10 | 0.011 / 0.16 / 0 | 0.061 / 0.44 / 0.06 | 0.069 / 0.40 / 0.37 | – | + +Mean kl plateaus at ~0.6 × (1.5 × target) as soon as the stop acts: 0.03 at target 0.05, 0.06 at target 0.10. Past that point it measures nothing; only skip is informative. + +## Established + +- The actor-update maths are identical between 508's code (25a75a34) and today's (trainer diff: refactor only). +- 508 → 509, only change = factorised credit: kl ×3 from the first rollout, skip appeared. +- 510-522: the per-group stop masked the regime (skip column = "rest" group = 0, the cannon skipped 10-30 %). +- The removal (523) did not bring back 508's regime: at equal target 0.05, skip 0.24 at 80 k versus 0; starting kl 0.008 versus 0.005; and above all kl grows ×6-7 with training where 508 stayed flat (×2). +- Hyperparameters changed since the removal: kl target 0.05 → 0.10 (delays skip, 0.24 → 0.09 at 80 k); shells_per_hit 5 and kills curriculum (528, no effect); canon entropy target −1 and σ canon cap 0.25 (529, no effect: 528 ≡ 529); critic (530-532, no effect); coloured noise (kl ×3 at start, skip ×6 at 80 k); lr 5e-5 (shifts by ~40 k). + +## Not settled + +What separates 508 from 523 apart from the separate credit: CNN (4 blocks + spatial softmax, 384 features → 7 flattened blocks, 256 features, output 1×2), gamma 0.995 → 0.998, discrete_target_proba 0.05 → 0.01, a·|a| curve, shell economy, empty-reserve penalty. Gamma (514 vs 515) and discrete proba (519 vs 520) did not move kl under factorised credit; removing Φ did not either (524 vs 525). The CNN remains the main suspect, without direct proof: no run isolates this change. + +The share of each action in the KL is measured nowhere. + +## Direct measurement: KL per action across actor steps (2026-11-19) + +Tool: `arenai_agent_sigma_gradients --kl_breakdown ` (uncommitted). On each rollout of a checkpoint (1 episode, side 350, 6 rollouts), replays the actor epochs without KL stop with the save's Adam state, and measures the exact KL old → new policy over all rows, per action; the actor is restored after each rollout. α are not updated. + +Exact KL (sum of actions) after 8 actor steps, lr 1e-4 unless stated: + +| checkpoint | collection noise | KL at 8 steps | dir_x | dir_y | canon_x | canon_y | fire + zoom | +|---|---|---|---|---|---|---|---| +| 534 s0 (0 k) | coloured | 0.003 | 0.0008 | 0.0001 | 0.0011 | 0.0005 | < 1e-4 | +| 534 s0 | white | 0.002 | | | | | | +| 534 s1 (27 k) | coloured | 0.107 | 0.008 | 0.026 | 0.036 | 0.037 | < 1e-4 | +| 534 s3 (81 k) | coloured | 0.145-0.168 | 0.006 | 0.028 | 0.056 | 0.056 | < 1e-4 | +| 534 s3 | white | 0.052-0.067 | 0.002 | 0.024 | 0.020 | 0.021 | < 1e-4 | +| 535 s3 (lr 5e-5) | coloured | 0.076 | 0.003 | 0.034 | 0.022 | 0.017 | < 1e-4 | +| 529 s0 | white | 0.002 | | | | | | +| 529 s3 (81 k) | white | 0.024-0.026 | 0.007 | 0.006 | 0.006 | 0.008 | 1e-4 | +| 529 s3 | coloured | 0.048 | 0.010 | 0.013 | 0.012 | 0.013 | 3e-4 | + +- 94-100 % of the KL comes from the displacement of μ; σ, trigger and zoom play no part. +- At save_0 the displacement is mostly an offset common to all states (60-80 %); at save_3 it is state-specific (common offset 10-30 %). +- KL per step is multiplied by 10 (529, white) to 50 (534, coloured) between save_0 and save_3, mostly by save_1. +- Coloured noise on the same checkpoint: ×2 (529 s3) to ×2.5-3 (534 s3). + +## Weight norm of the μ head (‖mu.weight‖, init 0.02) + +| run | 27 k | 81 k | 135 k | 243 k | CSV kl at 80 k | +|---|---|---|---|---|---| +| 507 / 508 | 0.155 / 0.159 | 0.244 / 0.221 | 0.299 / 0.301 | 0.429 / 0.461 | 0.011 | +| 509 / 510 | 0.170 / 0.186 | 0.203 / 0.259 | 0.244 / 0.312 | – / 0.438 | 0.03 | +| 526 (batch 2400) | 0.130 | 0.195 | 0.246 | – | 0.011 | +| 523 / 524 / 528 | 0.246 / 0.243 / 0.246 | 0.394 / 0.497 / 0.505 | – / 0.532 / 0.560 | – / 0.654 / 0.621 | 0.03-0.06 | +| 529 / 532 | 0.204 / 0.227 | 0.398 / 0.397 | 0.468 / 0.460 | 0.535 / 0.515 | 0.056 | +| 533 / 534 / 535 | 0.290 / 0.258 / 0.258 | 0.405 / 0.408 / 0.378 | – / – / 0.451 | – | 0.07 | + +Reading: μ = W·h. The head starts at ~0 (decoupled from the trunk); as ‖W‖ grows, each Adam step on the trunk moves μ more, and the per-step KL follows (‖W_a‖ / σ_a)². The per-action split of 534 s3 fits: (0.113/0.3)² : (0.278/0.3)² : (0.176/0.19)² : (0.214/0.19)² ≈ 1 : 6 : 6 : 9 for 1 : 5 : 10 : 10 measured (wheel σ assumed ~0.3). Since 523 the head grows twice as fast as in 507/508; 526 (batch 2400) is the only recent run that stayed at 508's level. Nothing bounds this norm. + +Not settled: why the head grows ×2 faster since 523 (flattened CNN, single advantage after the separate credit, a·|a|: never isolated). diff --git a/.claude/knowledge/comparisons/2026-11-19_aim-gesture-state-vs-events-signal.md b/.claude/knowledge/comparisons/2026-11-19_aim-gesture-state-vs-events-signal.md new file mode 100644 index 000000000..73ab3cb2d --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-19_aim-gesture-state-vs-events-signal.md @@ -0,0 +1,18 @@ +# Aim gesture: state signal vs events signal — event credit capped at ρ 0.02; policy cancels coloured noise + +Runs: 528, 529, 533, 534, 537, 538 + +2026-11-19: turret agitates 2.2°/decision for a target drifting 0.18°; learned corrector 0.1-0.8° drowned in |μ| 3.2°; effect of one gesture null at 1 s; ρ(events, gesture) ≤ 0.03 whatever the windowing; the policy cancels its coloured noise (corr −0.25 to −0.43). + +Offline measurement 2026-11-19 (`outputs/comparisons/2026-11-19_bruit_avantage_visee/rapport.md`, script `lagprofile.py`, sigma_gradients exports of 537 s3/s4 + those of 2026-11-18 for 528 s9, 529 s3/s9). Requested by the developer to find the root cause (after the proxy-is-not-a-lever feedback). + +- **Where the yaw motion comes from (537 s3, enriched export positions + headings, `drift.py`, `command.py`, `counterfactual.py`)**: the turret command itself. Plant over two decisions (−8.8 / −8.6°/unit, R² 0.92); command = 51 % of variance of Δyaw at 0.1 s (89 % excluding extremes), parallax 20 %, target 20 %, stabiliser 4 %. Bearing: 0.18°/decision; turret: 2.2°/decision (μ 2.7°, noise 1.5°, anticorrelated −0.48). μ toward target: 0.1-0.8°/decision depending on yaw, null > 40°, equilibrium shifted to +4°; |μ command| 3.2° whatever the yaw; μ explained by yaw 4 %, past noise 18 %, 55 % unrelated to geometry. 1D replay with only the yaw-related part of μ: yaw < 5° 6.8 → 15.2 %, dwell 0.31 → 2.77 s (turret still 1.90 s). Median |yaw| at nearest < 100 m: 81°. **Error corrected the same day**: Claude first wrote « turret = 13-15 % of Δyaw » ignoring the previous decision's action. +- **Gesture → state**: ρ(gesture, drop of |yaw|) 0.04-0.14 at 0.1 s, 0.02-0.05 at 0.5 s, ≈ 0.01 at 1 s (white and coloured); null from 0.5 s in the 1-10° band. +- **Gesture → events**: run advantage 0.002-0.012; short windows, return without critic, optimal linear filter per delay (out of sample): all ≤ 0.017 over 1-40°, max 0.027 over 10-40° (528 s9). Ceiling ρ ≈ 0.01-0.03. The signals that made the turret learn (Φ 0.10-0.13, geometric critic λ 0.3 0.076) are state differences. +- **Return variance**: hits 81-85 %, kills 11-13 %, received + death 5-7 %; 76-80 % comes from rewards at > 2 s. +- **Coloured noise**: no signal gain (≤ 0 in 537), plane effect 6-10; « aligned < 5° at 1 s » negative (−0.015 / −0.022); the policy cancels its noise: corr(μ_t, noise_t−1) 0 at s0 → −0.25 (533/534) → −0.43 (537 s3), −0.4 to −0.6 over 1 s. The 0.62 corrector of 533/534 is not an artefact of this compensation (0.624 → 0.620). +- **538 s3 (white noise, same code)**: turret 2.7°/decision for a drift of 0.16°; smooth μ (autocorr 0.87, 77 % explained by previous μ), constant bias −0.9 to −2.4°/decision at any yaw = sweep in one direction ~13°/s + same 0.3-0.7° corrector; no noise cancellation (corr −0.04); replay of the yaw-related part: 6.2 % / 0.87 s (it contains the bias). ρ events 0.017-0.024 (max 0.040 over 1-10°). Real dwell 0.3 s in both. + +**Rule:** (Claude's reading, untested in training) no longer propose credit tuning on events alone for the turret (λ, γ, window, per-component head, batch): capped at ρ 0.02. Open next question: what sweeping brings (out-of-field acquisition, median target at 81°) vs holding; joins comparisons/2026-11-17_hypothesis-sigma-canon-target-holding.md (« le verrou est le balayage lui-même »). Enriched sigma_gradients export (columns nearest, position_*, nearest_*, canon_heading, chassis_heading, turret_yaw; fields added to AimGeometry) uncommitted, validated by the developer 2026-11-19. See comparisons/2026-11-18_critic-blind-to-aiming-gesture.md, comparisons/2026-11-12_aim-diagnosis-mu-white-noise.md. + +**Inference-time intervention (2026-11-19, 538 s8, report part 6)**: probe `--detrend_canon_x_steps N` (removes the sliding mean of μ canon_x). Dwell 0.31 → 0.49 s but passes ÷2, hits −9 to −20 %, kills 25 → 23-25 (side 250) and 22.5 → 19 (side 550). **The sweep is the acquisition, not a defect**: do not propose a penalty on μ canon nor a slower turret. Camera field ±39.5° = limit of the corrector (null > 40°). Remaining lock: low gain on visible target (0.5-0.8°/decision at 5-40°). The probe also prints kills/hits/shells per episode in its log. diff --git a/.claude/knowledge/comparisons/2026-11-19_aim-synthesis-the-circle.md b/.claude/knowledge/comparisons/2026-11-19_aim-synthesis-the-circle.md new file mode 100644 index 000000000..dd682b055 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-19_aim-synthesis-the-circle.md @@ -0,0 +1,23 @@ +# Aim synthesis 2026-11-19 — « the circle »: 2×2 CNN × aim credit on kills at D 1000 + +Runs: 500, 510, 514, 520, 522, 524, 525, 528, 529, 538, 523-538 + +2026-11-19: 2×2 table CNN × aim credit on kills at D 1000; only separate credit on Φ ever held aim, 523-538 = variations without it; reread before any proposal on aim. + +Synthesis requested by the developer 2026-11-19 (« on tourne trop en rond, je perds le fil »), CSVs reread at equal D: + +| | separate aim credit (Φ, λ 0, no critic) | single advantage | +|---|---|---| +| spatial softmax | 510/514/520/522: kill 19-22 at D 1000, hit 0.18-0.38 | 500: kill 7 | +| flattened CNN 7 convs | control 430 other PC (cfb76a2e): kill 17.8, hit 0.38, tour<5° 40 % | 524/525/528/529: kill 8-13 from D 750-1000 | + +- 538 (white noise, batch 2400, linear command) at D 650 (279 k): kill 20.8, hit 0.17, fire 0.57 falling = trajectory of 528 at the same D (22.4 / 0.19 / 0.45, then 12.7 at D 750). Prediction made to the developer: drop before D 1000; if kill ≥ 17 at D 1000, the synthesis is false. +- The circle: removed and never restored = separate credit (2026-11-16, 5c338159) then Φ (2026-11-17); the 15 runs 523-538 varied target_kl, batch, kills curriculum, economy 5, σ ceiling, short head, γ, critic lr, coloured noise, softmax, linear command. +- Concordant measurements: ρ(events, gesture) ≤ 0.03 under five angles; critic blind to alignment (530/531/532); sweep = acquisition (comparisons/2026-11-19_aim-gesture-state-vs-events-signal.md); no run ever steered the turret toward the target, the best sweep slowly and fire selectively. +- the developer's hypothesis of 2026-11-16 (« avec un CNN qui localise, l'avantage unique suffira », single-advantage run 523) is refuted by 524-538. + +Options presented 2026-11-19 (the developer's decision awaited): A restore separate credit + Φ on the current tree, 538 as control; B same structure with a potential learned from shot outcomes (events only, classed « pas ouf » on 2026-11-16, bound ρ 0.08-0.09, one-step aim critic measurement 522 s68), measurable offline before code; C stay pure-event = no measured lever remaining. + +**Rule:** no longer propose tuning under single advantage as the solution to aim; judge any run on kill and hits/tank-s at D 1000 against this table. (see docs/decisions.md 2026-11-22: separate aim credit removed; 2026-11-24: separate aim credit on Φ refused) + +**Measurement of B (2026-11-19 afternoon, report `outputs/comparisons/2026-11-19_bruit_avantage_visee/rapport.md` §7, script `hhead.py`)**: The developer sets A aside (« Φ biaise la politique de visée ») and asks for the measurement of B. On 538 s12, H = share of the fire's shells that hit: read from geometry ρ 0.147 at one step (> Φ); learned from the image (7-block CNN from scratch, 36 k shots) ρ ≈ 0 at one step, 0.056 at two steps, flat from 9 to 36 episodes while hit AUC rises 0.68 → 0.75 (geometry 0.865). Criterion 0.08 not reached. B's lock is reading the image, not the label. Pitfall: one episode = 1 801 decisions (max_episode_steps + 1), `credit.load` assumes 1 800; image key = (t // 1801, t % 1801, tank). Tool: `sigma_gradients --frames_fired`, columns `fired_shells;landed_shells;nb_hits` (uncommitted). 538 at 379 k: D 700, kill 18.3, fire 0.46. diff --git a/.claude/knowledge/comparisons/2026-11-19_canon-credit-on-shot-value-b.md b/.claude/knowledge/comparisons/2026-11-19_canon-credit-on-shot-value-b.md new file mode 100644 index 000000000..28ad3ff8b --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-19_canon-credit-on-shot-value-b.md @@ -0,0 +1,20 @@ +# Canon credit on the shot value H (option B) — one-step credit, linear head of the critic + +Runs: 539, 540, 541 (credit canon on H head), 542 + +2026-11-20 state: one-step canon credit on H = linear head of the critic (`to_shot_value`, auxiliary BCE ×0.1), 3rd CNN removed, ppo/ppg/ppo_liquid; uncommitted, never launched beyond a 3-min trial (run 540 stopped at 147 k, not analysed). + +Option B validated by the developer 2026-11-19 (« Oui, code B ») after run 539 (up-to-date image) and coded the same evening, uncommitted, compiled in `build/` only. Choices validated: separate network on the image alone with no gradient to the policy, label = hit alone, canon_x/canon_y credited only on the one-step variation of this value. + +- **Code (first version):** `networks/shot_value.{h,cpp}` (agent CNN + head 128), `agents/shot_value_learner.{h,cpp}` (FIFO of in-flight shells per tank, ring of 32 768 labelled shots, AdamW 3e-4, 16 steps of 256 per rollout, horizontal mirror), `ppo_objective` (PolicyLogProbs, GroupKlStop next to KlStop), `LiquidPpoTrainer` (aim_advantages = normalised (γ·H(s′) − H(s))·(1 − cut), H evaluated before learning the rollout's shots). `on_transition` receives `shot_outcomes` [nb_tanks, 3] (fired, landed, hits) from `TrainTankEnvironment::last_step_shot_outcomes()`; ppo, ppg, sac ignore it. +- **CSV:** `skip_canon` and `shot_value` (cross-entropy on each rollout's new shots, before learning), CSV only. Options `--shot_value_*`. +- **9-min trial** (next to 539): runs, kl 0.005-0.009, skip 0; `shot_value` 0.26 → 0.13-0.17 for ~4.5 % hits (base rate ≈ 0.18). Throughput overhead not measured. +- **Consequence:** `LiquidPpoTrainer::load` requires `shot_value.pt` ⟹ `arenai_agent_sigma_gradients` no longer loads earlier checkpoints (no backward-compat for old checkpoints). Probe `arenai_agent_probe` untouched. + +**Why:** only separate canon credit held ~20 kills at D 1000 (aim-synthesis-2026-11-19-the-circle); Φ refused because it biases aim; with the up-to-date image (comparisons/2026-11-19_image-one-decision-late.md), one-step credit read on the image is 0.100 offline. + +**Test plan:** judge the run on kills at fixed side 550 and at D 1000, hit/shell and dwell holding after save_8, vs 539 (probe kills 24 / 20 / 25.5 / 23 / 21 from s3 to s12, dwell 0.62 → 0.24 s). Known risk: H learns only where the agent fires; offline it credits nothing beyond 100 m. + +**Contested 2026-11-20:** the developer discovers H has its own CNN (3rd encoder, after actor and critic): « j'ai jamais dit oui à ça ». The « separate network » noted as validated was not validated in their eyes — only « Oui, code B » is found in the 2026-11-19 session. Lesson: have every new architecture piece (network, encoder) explicitly validated, not only the principle. + +**Redone 2026-11-20 (validated point by point by the developer, then interactive code review):** `ShotValue`/`ShotValueLearner`/options `--shot_value_*` deleted. H = `to_shot_value` (Linear only, init like `to_value`) at the output of LTC (`LiquidCritic`) or of `head` (`ValueFunction`), trained in `backward_critic`: MSE + `SHOT_VALUE_COEF` 0.1 × mean BCE of the batch's labelled shots (constant, no CLI). Canon credited on normalised γ·σ(H(s′)) − σ(H(s)) (`shot_value_advantages`), rest GAE, `GroupKlStop`, CSV `skip_canon` + `shot_value` (in-sample BCE per critic minibatch, not comparable to 540). `agents/shot_credit.{h,cpp}`: `ShotOutcomes` (struct fired/landed/hits), `ShotLabeller` (lives in the 3 rollout buffers, delivering `rollout.shot_labels`), BCE, credit. Trainers: `evaluate_critic` / `compute_gae` / `compute_aim_advantages` separated. `KlStop` and the one-advantage surrogate removed. The developer's review choices: no common class for the loss (independent trainers by philosophy), a single shot_credit file, critics' `value()` not renamed, critic tests only. (see docs/decisions.md 2026-11-22: separate aim credit removed) diff --git a/.claude/knowledge/comparisons/2026-11-19_image-one-decision-late.md b/.claude/knowledge/comparisons/2026-11-19_image-one-decision-late.md new file mode 100644 index 000000000..a94a1d671 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-19_image-one-decision-late.md @@ -0,0 +1,21 @@ +# Agent visual observation is one decision late (`draw_and_get_frame` reads the previous render) + +Runs: 538 (measurement), 539 (first run with the fix) + +2026-11-19: the agent's visual observation dates from one decision (0.1 s) — `draw_and_get_frame` reads the previous render; found by code reading + measurement. Fixed same day. + +Found 2026-11-19 while investigating why the shot value read from the image credits nothing at one step (aim-synthesis-2026-11-19-the-circle, report `outputs/comparisons/2026-11-19_bruit_avantage_visee/rapport.md` §8). + +- `VulkanOffscreenRenderer::draw_and_get_frame` (arenai_view/src/vulkan/scene/renderers/offscreen_renderer.cpp): `draw()` submits into `slots_[slot_index_]` then advances the index; the read takes `slots_[slot_index_]`, i.e. the other slot (`FRAME_SLOTS` = 2) = the render of the previous call. Since the Vulkan migration (0dc62306, 2026-07-18). +- `TrainTankEnvironment::step` renders once per decision ⟹ the image seen at decision t shows state t−1 (0.1 s); the proprio is up to date. +- Measurement (538 s12): H image variation over one step ↔ geometry variation of the previous step 0.148, of the same step 0.102. Gesture credit read in the image: 0 at 0.1 s, 0.056 at 0.2 s; geometry: 0.147 from 0.1 s. +- The delay does not explain the level (delayed geometry AUC 0.856 vs 0.863). Remaining image/geometry gap = data volume (AUC 0.68 → 0.75 from 9 to 36 episodes); colours, framing, resolution ruled out. +- Turret plant over two decisions + image one late: aim loop ≈ 0.3 s. + +**Why it matters:** any value or critic read from the image does not see, at one step, the action just taken; consistent with the useless λ 0 critic (one-step aim critic measurement on 522 s68, comparisons/2026-11-18_critic-blind-to-aiming-gesture.md). + +**Rule:** in any image ↔ geometry measurement, shift by one decision. Fix (read the slot just submitted) = behaviour change for all checkpoints + possible throughput cost: The developer's decision. + +**Fixed 2026-11-19 ~13:45 (validated by the developer, uncommitted):** `draw_and_get_frame` reads `slots_[(slot_index_ + FRAME_SLOTS - 1) % FRAME_SLOTS]`; « first image black » assertions removed from test_offscreen, test_offscreen_diffuse, test_vk_offscreen; build/: view 58, core 28, agent 2 442 tests ok. `cmake-build-release` not rebuilt (538 running there with the delay); CI goldens (lavapipe) not regenerated; comment « warm-up: 2 render loops to prime PBO double-buffering » of environment.cpp:200 became inexact, code left. + +**Measurement of B redone with the up-to-date image (report §9)**: one-step ρ of H learned from the image 0.00 → **0.100 ± 0.008** (1-10°: 0.139; criterion 0.08 reached, Φ level), AUC 0.749 → 0.797, geometric bound 0.170, image/geometry offset peak back to the same step. Export +7 % slower. Offline, one seed, policy 538 trained with the delay. No run with the fix at 2026-11-19 14:30: effect on kills unknown. (run 539 = 538 + this fix; see its run folder) diff --git a/.claude/knowledge/comparisons/2026-11-19_turret-gesture-noise-advantage.md b/.claude/knowledge/comparisons/2026-11-19_turret-gesture-noise-advantage.md new file mode 100644 index 000000000..dc944db83 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-19_turret-gesture-noise-advantage.md @@ -0,0 +1,217 @@ +# What a turret gesture changes, and what the events say about it + +Runs: 528, 529, 533-538 (537 s3/s4, 538 s3/s8/s12, 528 s9, 529 s3/s9). +Date: 2026-11-19. Frozen policies, no training code modified. Exports `arenai_agent_sigma_gradients` (12 episodes): 537 s3 and s4 (side 350, coloured noise ρ 0.9, σ canon 0.17), and those of 2026-11-18 for 528 s9 (white noise, σ 0.57), 529 s9 and s3 (white noise, σ 0.23). Scripts and data: `outputs/comparisons/2026-11-19_bruit_avantage_visee/` (`lagprofile.py`, `drift.py`, `command.py`, `counterfactual.py`, `detrend.py`, `hhead.py`, `hwhy.py`, `hlag.py`; outputs `outputs/comparisons/2026-11-19_bruit_avantage_visee/data/`, e.g. `data/lag_*.txt`, `data/detrend_538_s8_side*.txt`, `data/hhead_538_s12*.txt`, `data/frames_538_s12.png`, `data/hfix_538_s12_*`). Probes 533-537 for part 4. + +"Gesture" = normalised exploration noise of canon_x, signed toward the nearest target. ρ = per-row correlation; standard error by bootstrap over tank-episodes. + +## 1. Yaw moves because the turret commands itself, not because the target drifts + +Enriched export (positions, cannon and chassis headings; `drift.py`, `command.py`), 537 s3, 6 episodes, same nearest target < 100 m, |yaw| < 40°. The turret responds over two decisions (−8.8° then −8.6° per action unit, R² 0.92 of cannon heading motion). + +Yaw variation, variance share: + +| component | median per decision | at 0.1 s | at 1 s | at 0.1 s without the 10 % extremes | +|---|---|---|---|---| +| turret command (actions t and t−1) | 2.3° | 51 % | 61 % | 89 % | +| own translation (parallax) | 0.18° | 20 % | 16 % | 6 % | +| target displacement | 0.11° | 20 % | 11 % | 0 % | +| stabiliser, inertia | 0.13° | 4 % | 3 % | 2 % | +| unreconstructed | 0.24° | 5 % | 8 % | 2 % | + +Target bearing drifts 0.18° per decision (median), 1.6° in 1 s. The turret moves 2.2° per decision. **A first version of this report said the opposite ("85 % of the movement does not come from the command"): the regression used only the current decision's action and ignored the previous decision's. That was wrong.** + +Composition of the command (° of cannon heading per decision, median / p90): + +| | per decision | cumulative over 1 s | +|---|---|---| +| share of μ | 2.7° / 6.5° | 16.4° / 44.6° | +| share of exploration noise | 1.5° / 4.2° | 13.2° / 36.3° | +| μ + noise (corr −0.48 per decision, −0.65 over 1 s) | 2.2° / 5.9° | 8.9° / 33.3° | +| bearing drift | 0.18° / 0.75° | 1.6° / 7.4° | + +What μ commands as a function of yaw: 0.1° toward the target at 0-2°, 0.2° at 2-5°, 0.5° at 5-10°, 0.8° at 10-40°, nothing beyond 40°; equilibrium point shifted to +4°. The norm of μ's command is 3.2° per decision whatever the yaw. What explains tanh(μ): yaw 4 %, noise of the 5 past decisions 18 %, previous μ brings the cumulative to 44 %, bearing drift and chassis rotation 0 %. The rest (55 %) changes from one decision to the next with no link to geometry. + +## 1 bis. Replay: the target-linked part of μ, without the rest + +`counterfactual.py`: yaw replayed in 1D on the real segments (same nearest target, median duration 2.6 s), with the real bearing drift and, as the only command, the mean setpoint of μ as a function of yaw. Drift assumed unchanged (approximation). + +| | yaw < 5° | yaw < 2° | dwell < 5° | +|---|---|---|---| +| real | 6.8 % | 2.7 % | 0.31 s | +| no command | 3.5 % | 1.4 % | 1.90 s | +| yaw-linked part of μ alone | 15.2 % | 4.2 % | 2.77 s | +| same, setpoint ×2 | 22.9 % | 3.9 % | 3.00 s | + +Median |yaw| toward the nearest at < 100 m: 81° (the target is out of field most of the time, and the setpoint is zero beyond 40°). + +## 2. The effect of a gesture fades in under a second + +ρ(gesture, future state), yaw 1-40°, target < 100 m: + +| | 528 s9 | 529 s9 | 529 s3 | 537 s3 | 537 s4 | +|---|---|---|---|---|---| +| drop of \|yaw\| at 0.1 s | 0.142 | 0.075 | 0.066 | 0.047 | 0.038 | +| at 0.5 s | 0.051 | 0.031 | 0.040 | 0.027 | 0.019 | +| at 1 s | 0.025 | 0.012 | 0.011 | 0.010 | 0.003 | +| aligned < 5° at 1 s | +0.014 | +0.008 | +0.016 | −0.015 | −0.022 | + +Standard errors 0.003-0.008. In the 1-10° band the effect is null from 0.5 s everywhere. + +## 3. Events contain almost nothing about the gesture, whatever the slicing + +ρ(credit signal, gesture), yaw 1-40°, < 100 m: + +| signal | 528 s9 | 529 s9 | 529 s3 | 537 s3 | 537 s4 | +|---|---|---|---|---|---| +| run advantage (λ 0.95) | 0.006 | 0.012 | – | 0.002 | −0.004 | +| 30 s return without critic | 0.003 | 0.009 | 0.007 | −0.016 | −0.005 | +| sum of rewards 0-1.2 s | 0.012 | 0.008 | 0.017 | −0.009 | 0.003 | +| sum 0-0.4 s | 0.013 | 0.010 | 0.017 | −0.006 | 0.008 | +| optimal linear filter per lag slice (out of sample) | 0.013 | 0.003 | 0.017 | −0.008 | −0.006 | +| standard error | 0.004 | 0.003 | 0.005 | 0.009 | 0.009 | + +- Best band: 10-40° in 528 s9, 0.024-0.027. Band 1-10°: indistinguishable from 0 everywhere. +- Measured ceiling of credit from events alone: ρ ≈ 0.01-0.03, i.e. 6 to 30 rollouts for a gradient to come out of noise (t = 2), if the policy does not move meanwhile. +- References of 2026-11-12 and 2026-11-18: same-step Φ 0.10-0.13; geometric critic at λ 0.3 0.076. All signals that made the turret learn are state differences, not events. +- Coloured noise: no signal gain, and the standard error doubles at equal row count (plan effect 6-10: 6 to 10 times fewer independent samples). + +Variance composition of the return seen from these states (537 s3 ≡ 528 s9): hits 81-85 %, kills 11-13 %, damage received + death 5-7 %; by lag: 76-80 % comes from rewards beyond 2 s, 10 % from 0-1.2 s. The noise is not that of the other tanks: it is the tank's own future hits, unrelated to the present gesture. + +## 4. The policy cancels its own coloured noise + +corr(μ canon_x at t, noise at t−1) and corr of 1 s sums (probes, side 250): + +| | at 0.1 s | 1 s sums | +|---|---|---| +| 533 s0 (untrained) | −0.01 | −0.01 | +| 533 s1 / s3 | −0.25 / −0.25 | −0.31 / −0.40 | +| 534 s3 | −0.29 | −0.49 | +| 535 s5 | −0.28 | −0.39 | +| 537 s1 / s3 | −0.39 / −0.43 | −0.51 / −0.59 | +| 528 s9, 529 s9 (white noise, exports) | −0.03 / −0.01 | – | + +- Learned from 27 k in all coloured-noise runs; 10 to 28 % of μ's variance is explained by the past second's noise. +- The past second's noise explains nothing of the current yaw (R² 0.000). +- The "corrector" of probes 533/534 is not an artefact of this compensation: 0.624 → 0.620 once the part of μ linked to past noise is removed. + +## 5. Same decomposition in white noise (538 s3, same code, 12 episodes) + +| | 537 s3 (coloured) | 538 s3 (white) | +|---|---|---| +| bearing drift, median per decision | 0.18° | 0.16° | +| turret movement (μ + noise), median per decision | 2.2° | 2.7° | +| share of μ / share of noise | 2.7° / 1.5° | 2.6° / 0.9° | +| corr(μ command, noise command) per decision / over 1 s | −0.48 / −0.65 | −0.04 / −0.13 | +| cumulative μ over 1 s, median / p90 | 16° / 45° | 13° / 55° | +| autocorr of μ at 0.1 s | 0.62 | 0.87 | +| μ explained by: yaw / past noise / + previous μ | 4 % / 18 % / 44 % | 7 % / 2 % / 77 % | +| μ toward target at 2-5° / 5-10° / 10-20° (° per decision) | 0.24 / 0.54 / 0.76 | 0.26 / 0.50 / 0.70 | +| mean μ setpoint at yaw ±1° (° per decision) | −0.60 / −0.30 | −1.23 / −0.93 | +| replay, yaw-linked part of μ alone: yaw < 5° / dwell | 15.2 % / 2.77 s | 6.2 % / 0.87 s | +| real: yaw < 5° / dwell | 6.8 % / 0.31 s | 6.7 % / 0.33 s | +| ρ(events, gesture): sum 0-0.4 s / optimal filter | −0.006 / −0.008 | +0.017 / +0.024 | +| ρ(run advantage, gesture) | +0.002 | +0.009 | + +- In white noise the turret moves as much (2.7° per decision for a target drifting 0.16°), but differently: μ is smooth and carries a constant bias of −0.9 to −2.4° per decision at any yaw, i.e. a one-direction sweep of about 13° per second, on which the same corrector of 0.3 to 0.7° per decision is superposed. +- In coloured noise μ is choppy and partly serves to cancel the noise; the sweep bias is weaker (−0.3 to −0.8°). +- In both cases dwell on target is 0.3 s and the nearest enemy is 81° off-axis at the median. + +## 6. Inference-time intervention: sweep removed (538 s8, 216 k, 6 episodes per arm) + +Probe `--detrend_canon_x_steps N`: the sliding mean (N decisions) of μ canon_x is subtracted before the action draw, everything else is the policy. Script `detrend.py`, outputs `data/detrend_538_s8_side*.txt`. + +| side 250 / 550 | policy | removal 1.5 s | removal 0.5 s | +|---|---|---|---| +| kills per episode | 25.0 / 22.5 | 25.3 / 19.0 | 23.0 / 19.0 | +| hits per episode | 491 / 432 | 446 / 381 | 394 / 370 | +| hit/shell | 19.3 / 16.7 % | 18.6 / 15.2 % | 17.3 / 14.3 % | +| dwell < 5° | 0.31 / 0.30 s | 0.39 / 0.39 s | 0.49 / 0.50 s | +| dwells ≥ 1 s | 2.1 / 2.8 % | 5.6 / 6.0 % | 11.4 / 10.8 % | +| passes < 5° per tank-episode | 9.4 / 16.2 | 7.4 / 12.3 | 4.9 / 8.1 | +| yaw < 5° (target < 100 m) | 6.4 / 7.9 % | 6.1 / 6.5 % | 4.1 / 4.9 % | +| median \|yaw\| (target < 100 m) | 82° / 75° | 89° / 93° | 89° / 92° | + +Std of kills between episodes: 1.3 to 3.0 (standard error ≈ 1 per arm). + +- Removing the sweep lengthens dwell (0.3 → 0.5 s) but halves the passes: aligned time drops, hits drop 9 to 20 %, kills rise in no arm. +- The sweep is thus the policy's acquisition means, not a defect to remove. The "penalty on μ canon" lead is not supported. +- Camera field is ±39.5°: the zero setpoint beyond 40° corresponds to a target out of image. What is missing is the gain on a visible target (0.5 to 0.8° per decision at 5-40°, out of 9.2° possible). +- Limits: policy trained with its sweep (trigger and corrector adapted to it); the filter also removes the slow part of a sustained correction; one checkpoint, 6 episodes. + +## 7. Shot value learned from shot outcomes (lead B), offline on 538 s12 + +Export `arenai_agent_sigma_gradients` (columns `fired_shells`, `landed_shells`, `nb_hits`, option `--frames_fired`), side 550: 36 episodes for fitting (36 263 labelled shots, 23.6 % hits), 6 never-seen episodes for test (all images, 5 705 shots). H(image) = share of shells fired at that decision that hit; the run's 7-block CNN, from scratch, no proprio nor memory. Script `hhead.py`, outputs `data/hhead_538_s12*.txt`. Criterion fixed before the measurement: ρ(γH(s′) − H(s), gesture) ≥ 0.08 at one step, yaw 1-40°, target < 100 m. + +| | at 0.1 s | at 0.2 s | at 0.3 s | AUC hit / miss (test) | +|---|---|---|---|---| +| H read from geometry (upper bound) | +0.147 | +0.146 | +0.095 | 0.865 | +| H learned from image, 36 episodes | −0.001 | +0.056 | +0.052 | 0.749 | +| same, 18 episodes | +0.002 | +0.057 | +0.051 | 0.709 | +| same, 9 episodes | −0.002 | +0.055 | +0.050 | 0.684 | +| state reference, −\|yaw\| | +0.197 | +0.216 | +0.143 | – | + +Standard errors 0.004 to 0.008. Band 100-300 m: image H ≈ 0, bound 0.03. + +- The label carries the signal: the geometric bound (0.15) exceeds Φ (0.10-0.13 on 12 and 16/11). +- The image returns only a part: null at one step, 0.056 at two steps, below the criterion. Hit / miss separation improves with data (0.68 → 0.75), not the gesture credit. +- Image H by yaw (< 100 m): 0.26 at 0-2°, 0.22 at 5-10°, 0.15 at 10-20°, 0.07 at 20-40°; actual shot outcome: 0.54 / 0.39 / 0.30 / 0.16. +- Overfitting from the 6th pass at 36 episodes (measurement taken at the 5th). +- Unexplained: why the effect is null at one step in the image and entire in geometry. +- Limits: 36 episodes = one eighth of what a run sees up to D 650; one seed; frozen policy; the precedent of 532 (positive offline, negative online). + +## 8. Why the image returns less than geometry (538 s12, `hwhy.py`, `hlag.py`) + +Real images: `outputs/comparisons/2026-11-19_bruit_avantage_visee/data/frames_538_s12.png` (rows: aligned hit, aligned miss, yaw 10-20°, aligned at 80-100 m). Every part of every tank, the terrain and the decor objects have a random colour per episode; no reticle; target ~10 px wide at 80-100 m. + +**The image of a decision is that of the previous decision.** `VulkanOffscreenRenderer::draw_and_get_frame` submits the current render then reads the other slot (`FRAME_SLOTS` = 2), i.e. the render of the previous call; training renders once per decision (`render_frame` after the `action_repeat` frames). Present since the Vulkan migration (0dc62306, 18/07). Measurement: the variation of image H over one step tracks the geometry variation of the previous step (corr 0.148) more than that of the same step (0.102), then 0.01-0.02 elsewhere. + +| test | result | +|---|---| +| already-seen colours (same episodes, later) versus never seen | AUC 0.730 versus 0.688 (geometry 0.864 / 0.863) | +| centre 64×128 full resolution | AUC 0.767, ρ at 0.2 s 0.060 | +| centre 64×64 | AUC 0.737, ρ at 0.2 s 0.065 | +| vertical band 128×64 | AUC 0.722, ρ at 0.2 s 0.053 | +| geometry read 0 / 1 / 2 decisions before the shot | AUC 0.863 / 0.856 / 0.850 | +| volume: 9 / 18 / 36 episodes of shots | AUC 0.684 / 0.709 / 0.749 | + +- The lag explains the null one-step credit (the effect of a gesture appears in the image at 0.2 s), not the level: geometry delayed by one decision recognises hits almost as well. +- Neither colours, framing nor resolution close the 0.75 / 0.86 gap; only volume reduces it (+0.03 to +0.04 per doubling). +- Consequence of the lag for any value read from the image: the one-step difference does not contain the action just taken. Consistent with the critic's ρ ≈ 0 at λ 0 (16 and 18/11). +- Not measured: what the lag costs in hits and kills; the effect of its correction on training throughput; whether the game (rendered every frame) has the same lag in decisions. + +## 9. Image lag fixed: measurement of B redone (538 s12, same protocol and volumes) + +Fix (validated by the developer): `draw_and_get_frame` reads the slot just submitted. Three view tests expected a first black image, assertions removed; view 58, core 28, agent 2 442 tests passed in `build/`. New exports `data/hfix_538_s12_*`, outputs `data/hhead_538_s12_fix.txt`, `data/hwhy_lag_fix.txt`. The policy is 538's, trained with the lag, replayed without. + +| | lagged image (§7) | up-to-date image | +|---|---|---| +| ρ(γH(s′) − H(s), gesture), H learned from image, at 0.1 s | −0.001 ± 0.004 | **+0.100 ± 0.008** | +| same at 0.2 s / 0.3 s | +0.056 / +0.052 | +0.071 / +0.037 | +| same at 0.1 s, yaw 1-10° / 10-40° | +0.006 / −0.008 | +0.139 / +0.058 | +| same at 0.1 s, target at 100-300 m | −0.008 | +0.011 | +| geometric bound at 0.1 s | +0.147 | +0.170 | +| AUC hit / miss, image (5th pass) / geometry | 0.749 / 0.865 | 0.797 / 0.893 | +| labelled shots fit / test | 36 263 / 5 705 | 40 522 / 6 830 | +| image H ↔ geometry variation of same step / previous step | 0.102 / 0.148 | 0.253 / −0.046 | +| export duration of 36 episodes | 23 min 30 | 25 min 10 | + +- The criterion fixed before the measurement (0.08 at one step) is reached: 0.100, at Φ's level (0.10-0.13). +- The lag is gone: image variation tracks the same step's geometry. +- Nothing beyond 100 m, as for Φ out of field. +- Limits: one seed; offline, frozen policy; precedent of 532; the effect of the fix alone on a training (critic, trigger, kills) is not measured; CI reference images not regenerated. + +## Reading (Claude's) + +- The turret learned a weak but real corrector (0.2 to 0.8° per decision toward the target). It is drowned in a command 4 to 15 times larger, unrelated to the target, part of which serves to cancel the coloured noise. Dwell on target (0.31 s) is set by this agitation, not by target movement (1.90 s with the turret still). +- An exploration gesture weighs 1.5° in a proper movement of 2.2° per decision, hence its weak trace on the state (part 2) and its near-null trace on events (part 3). +- No tuning of event credit (λ, γ, window, per-component head, batch) can exceed ρ ≈ 0.02: consistent with the failures of 526, 530, 531, 532. +- Coloured noise was meant to make the gesture last; the policy cancels it and the effect at 1 s did not move (0.010 versus 0.012). +- Two distinct limits appear: μ agitation (dwell) and the absence of setpoint beyond 40° (acquisition). + +## Not established + +- Where the part of μ unrelated to geometry (55 %) comes from: not measured. Untested hypothesis: random walk of the μ head under a gradient at ρ ≈ 0.01 (growing `‖mu.weight‖`, measured 2026-11-19 on 523-535, see `2026-11-18_skip-kl-rise-507-535.md`). +- What a strong gain on a visible target would bring, sweep kept out of field: not measured. +- Whether noise compensation explains the KL regime of coloured-noise runs. +- None of this is tested by intervention in training; the 1D replay is not a game simulation. diff --git a/.claude/knowledge/comparisons/2026-11-20_aim-trigger-loop-diagnosis.md b/.claude/knowledge/comparisons/2026-11-20_aim-trigger-loop-diagnosis.md new file mode 100644 index 000000000..953dd9ff6 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-20_aim-trigger-loop-diagnosis.md @@ -0,0 +1,34 @@ +# Aim/trigger loop diagnosis: probes 508-543 cross-read, trigger sorts as well without Φ + +Runs: 508-543 (510-522 Φ runs; 524-539 event runs; 541-543 H runs), 543, 544, 545 + +2026-11-20: the trigger sorts as well without Φ, it is the turret that lets go when the trigger closes; empty-reserve penalty ruled out as a cause (543). Requested by the developer the evening of 2026-11-20 after 543's failure (« analyse tous les runs pour comprendre »). Report: `outputs/comparisons/2026-11-20_diagnostic_gachette_visee.md`. Stochastic probes side 550, save ≥ 9. + +- **The trigger is not the failing piece**: aligned close / off-axis logit gap 2.2-3.2 in Φ runs (510-522), 3.0-4.3 in event runs (524-539) and H runs (541-543). +- **All families go through a closure at 240-430 k**, 522 included (armed p_fire 0.025 at s10, 0.017 at s16); the release fires 0.3-0.5/tank-s, like the « extinguished » phases of 524/528/529. +- **The difference is the turret during closure** (armed p_fire ≤ 0.035): < 5° 31-45 % of the time with Φ credit, 6-12 % event-only, 2-13 % with H. corr(rate, turret < 5°) between saves: −0.49 Φ, +0.57 events, +0.88 H. +- **CSV**: the 8 Φ-credit runs reach D 1000 with kill 17-22; none of the others holds kill ≥ 17 at D 1000. +- **Empty-reserve penalty ruled out**: 543 (constant 0.5) closes at D 700-750 / 351 k, earlier than 541. The dump resolves in all runs; CSV `reste` does not show it, only probes. +- Reading (inferred, not tested by intervention): aiming pays only if a shell leaves, firing pays only if aligned; without an aim signal independent of firing, the trigger's descent cuts the turret's signal ⟹ extinction or oscillation. H worsens (normalised advantage without labels). + +**Rule:** stop looking for the cause in the trigger, economy or penalty. Read a run on turret holding when the trigger is closed. Options posed to the developer 2026-11-20, not decided: Φ credit back on the current tree, target-independent potential (measure offline first), Φ as primer. Nothing to code before their answers. + +**Follow-up 2026-11-20/21 — the developer's objection and measurement.** Objection to any potential (Φ or hit probability): it does not represent what is most urgent to aim at, « ex : un ennemi sur le flanc ». Offline measurement requested (« ouai mesure le »), report `outputs/comparisons/2026-11-21_potentiel_proba_touche/rapport.md`, script `proba.py` (reusable on any `sigma_gradients` CSV, which exports positions + canon heading): +- P = lateral hit probability, 1 − ∏(1 − p_i) over all enemies, dispersion σ. ρ yaw gesture < 100 m, σ 1.6°: 0.051 / 0.052 / 0.050 / 0.113 (543 s8 c550, c1000, 541 s12, 543 s13) vs Φ replica 0.046 / 0.056 / 0.050 / 0.080 ⟹ P ≡ Φ, without designating a target. +- Event GAE (run's critic): 0.00-0.01 on all gestures, out-of-field included. Sum P + w·GAE: harmless at w ≤ 0.25, −20 to −40 % at w = 1, no measurable gain ⟹ the idea « events will choose the target » is not supported. +- Elevation: separate term 0.11-0.15; multiplied with yaw 0.06 and yaw falls to ~0.02 ⟹ one term per axis. +- Wide σ (10°) carries at 100-300 m on 543, not on 541. +- Nothing credits the gesture toward an out-of-field enemy (ρ ≈ 0 for all). Claude's Φ replica underestimates (0.05 vs 0.085-0.12 measured for real on 522): compare only P vs Φ on the same rows. +Decision of the developer awaited on the pieces (P per axis, σ, GAE weight, fate of H); nothing coded. + +**Φ₂ validated piece by piece and coded 2026-11-21 (uncommitted, `build/` only, the developer launches the run from CLion).** the developer: « ok d'optimiser l'action de visée si l'heuristique tient compte des ennemis sur le flanc », then « on tente d'abord la nouvelle heuristique et dans un second temps la résolution » (enlarged field of view = next separate trial). +- Formula: Φ₂ = max_i u_i · (bell_i + β · slope_i); bell = 1/(1+(miss/3 m)²) on the theoretical trajectory cut by terrain; slope = 1 − |horizontal bearing|/180° from the canon pivot; u = min(1, 50 m / distance); β = 1. All living enemies, no visibility test. Constants `AIM_TARGET_RADIUS`, `AIM_URGENCY_DISTANCE`, `AIM_BEARING_WEIGHT` (constants.h), public contract `EnemyTank::get_aim_potential(tanks)`. +- Offline measurement (`outputs/comparisons/2026-11-21_potentiel_proba_touche/flanc.py`): ρ yaw gesture < 100 m 0.077-0.081 (Φ 0.046-0.056), 100-300 m 0.047-0.056, out of field 0.014-0.030 (Φ 0). Nearest enemy at ≥ 40° in 75 % of decisions, ≥ 90° in 48 %. +- Wiring: canon_x/canon_y credited on normalised((γ·Φ₂(s′) − Φ₂(s))·(1 − cut)), rest GAE, reward unchanged. `agents/aim_credit.{h,cpp}` (AimPotentials before/after), `TrainTankEnvironment::last_step_aim_potentials()` (Φ₂ read at start and end of step), the 3 trainers. Head H, shot_credit, CSV column `shot_value` and probe column `shot_value` removed ⟹ critics of 541-543 no longer load (sigma_gradients); the probe, which no longer reads the critic, still works on their actors. +- Verified: ctest 5/5, 93 model tests, real 4-min trial (kl 0.006-0.010, skip 0). Throughput not cleanly measured (Φ₂ evaluated 2× per decision). +- Run markers: turret < 5° with closed trigger (target ≥ 30 % like 510-522), holding D 1000, kill ≥ 17. If turret aims but misses flanks ⟹ field-of-view trial. + +**Run 544 (= 543 + Φ₂ instead of H, launched 2026-11-21 02:54), point at 85 k / D 400:** D milestones 300 @ 21 k, 350 @ 48 k, 400 @ 67 k (541-543: 47 / 67 / 114 k); kill 25.7-27.4 at D 300-400 (541: 19.7-20.5; 539: 22-26), r +3.3e-3 (541 +1e-3); throughput 127 k steps/h alone on GPU. Probe s3 side 550: turret < 5° 23.4 % (541 s3 10 %, 539 s3 16 %), median angle 18°, trigger still flat (0.74/0.73, normal at s3), dump (empty 2.7 s, disarmed 31 %). Watch: σ canon already 0.03/0.05 (543 s8: 0.08/0.09), Hc −0.97 and kl 0.043 rising, alpha_canon_x 1.3e-3 rising. Next rendezvous: s9 (243 k) trigger, s13-s16 turret with closed trigger. + +**Run 545 = isolated control of Φ₂ (decided by the developer 2026-11-21, one question per setting, coded uncommitted, `build/` only).** 544 killed at 109 k at their request (D 400, kill 27, s4). Reset to 522 values: target_kl 0.10 → 0.05; shells per hit 5 → 2 (default `--shells_per_hit`); empty penalty 0.5 constant → −D/1000 (curriculum re-injected in the constructor of `TrainTankEnvironment`, 0 without curriculum hence 0 in the probe); canon entropy target −1 → 0; canon-specific ceilings removed (`CANON_LOG_SIGMA_MAX` 0.25 and `CANON_INITIAL_SIGMA_MAX` 0.20, SoftClamp scalar again). Left: linear command (a·|a| not restored, « comme 510 »). Kept: flattened CNN, up-to-date image, batch 2400, kills curriculum. Remaining gaps of 545 vs 522: these four + Φ₂ + a·|a|. 2447 agent tests, ctest 5/5. +(see docs/decisions.md 2026-11-22: Φ removed, 2026-11-24: separate aim credit on Φ refused) diff --git a/.claude/knowledge/comparisons/2026-11-20_review-since-v1-3-2-h-not-the-lever.md b/.claude/knowledge/comparisons/2026-11-20_review-since-v1-3-2-h-not-the-lever.md new file mode 100644 index 000000000..16b6a6e02 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-20_review-since-v1-3-2-h-not-the-lever.md @@ -0,0 +1,23 @@ +# Review of runs 523-542 since release v1.3.2 (= run 522): H is not the lever + +Runs: 522, 523-542, 538, 539, 541, 542, 543 + +2026-11-20: H calms the turret but does not learn aim; empty-reserve penalty = 40-70 % of the hit reward at D 800; no run holds D 1000. Requested by the developer 2026-11-20 (« récap et challenger les changements depuis la dernière release », « on peut revoir totalement l'économie / reward »). Report: `outputs/comparisons/2026-11-20_bilan_depuis_v1.3.2.md`. + +- Last release = tag v1.3.2 (0c678b42, 2026-11-16), state of run 522 (penalty at empty): kill 19.2, hit 0.38 at D 1000 over 1 M steps. `gh` not installed: read tags with `git ls-remote --tags origin`. +- 14 changes since: real gains = flattened CNN, up-to-date image; hygiene = batch 2400, kills curriculum, 5 shells/hit; the rest neutral or negative. +- **H (runs 541, 542)**: gain μ/yaw −0.002 to −0.011 and corrector 0.51-0.59, never above 539 s3 without credit; corr(ΔH, gesture) ≤ 0.06; reproduced effect = calmed turret (command 0.5-0.6 °/decision), no sweep, dwell 0.7-1.3 s; hits/tank-s 0.05-0.09 at side 550. Reading (Claude's, untested): H ≈ taking the canon out of GAE. +- **Trigger**: `reste` = r − r_hit − r_rcv = empty-reserve penalties; at D 800 they are 23-24 % of r_hit (522, 539), 39 % (541), 68 % (542, one dump / 21 s per tank, `r` < 0 from 210 to 345 k). Shell break-even: 6 % at D 800, 2.4 % at D 250; aligned shot +0.35 to +0.42 per shell but its trigger closes with the common level (fixed logit gap 3.4-4.1). Drops at D 750-850 in 538, 539, 541, 542. Cause via indexing on D: inferred, not tested. + +Choices posed to the developer, not decided: « canon without credit » control, constant empty penalty, economy overhaul. Nothing coded before their answers, one question per piece. + +**Decided and coded 2026-11-20 (« okay pour 0.5 en constante et on enlève le code qui sert plus », plan validated before code):** `EMPTY_RESERVE_PENALTY` 1 → 0.5 constant in `train_environment.cpp`, D indexing removed (constructor parameters `curriculum` / `initial_spawn_side` / `final_spawn_side` of `TrainTankEnvironment`, member `empty_reserve_penalty`). Penalty now 0.5 also in probe and `sigma_gradients` (before: 0 without curriculum). Uncommitted, `build/` only, 2 459 agent tests ok; `cmake-build-release` to be rebuilt by the developer. Run markers: fire cadence before 100 k (risk: run 479 dead trigger via death at empty), dump resolved or not at s9-s13, trigger holding at D 800 → 950. + +Same turn 2026-11-20: `discrete_target_proba` back to 0.01 in `liquid_ppo_hyperparams.h` at the developer's request ⟹ next run = 541 + constant empty penalty 0.5, only difference. + +**Run 543 (= 541 + constant penalty 0.5), at 176 k / D 450, 2026-11-20 21:00** (`outputs/train_543_ppo_liquid/analysis.md`): trigger not extinguished (fire 0.7-1.1, kill 20-23), but dump frequency unchanged vs 541 (one dump / 14-17 s per tank) despite penalty ×2 at D 250 ⟹ `reste` = 60-90 % of r_hit, `r` ≈ 0. kill/hit ≡ 541 up to D 400. Intended effect not readable before D 750-950. D milestones identical to the thousand in 539/541/542/543 (kills curriculum at max cadence): they separate nothing before D ~700. + +**Probe 543 save_8 (216 k, D 550), side 550** (`outputs/train_543_ppo_liquid/probes/save_8.md`): dump intact (median empty reserve 3.6 s, 82 % empty, 49 % disarmed), trigger selective (ratio 1.99, p_al 0.80, p_off 0.40), hit/shell 11.4 %, turret < 5° 12.9 % ⟹ ≡ 542 s9, below 541 s9 (23.1 % / 15.8 % / 29 % disarmed). To probe next: saves at D 800-950 vs 541 s12-s16. + +**Correction 2026-11-20 evening**: the dump RESOLVES itself in 539/541/542/543 between 300 and 430 k (probes side 550: disarmed < 5 %); the CSV `reste` does not show it. The real failure mode = closing of the whole trigger (p_al 0.08-0.17, < 0.15 shot/s); only 539 s12 sorts (p_al 0.56, p_off 0.03). **543 save_13 (351 k)**: p_al 0.148, p_off 0.006, 0.089 shot/s, disarmed 4 %, turret < 5° 4.4 %, mute in deterministic ⟹ closing of 541 s14-s16 reproduced earlier; constant penalty 0.5 does not change the outcome. Reading criterion to keep: success = p_off < 0.05 AND p_al ≥ 0.5 AND ≥ 0.4 shot/s. +(see docs/decisions.md 2026-11-22: empty-reserve penalty rule = refill + constant 0.25 under curriculum) diff --git a/.claude/knowledge/comparisons/2026-11-20_summary-since-v1.3.2.md b/.claude/knowledge/comparisons/2026-11-20_summary-since-v1.3.2.md new file mode 100644 index 000000000..4eef409ac --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-20_summary-since-v1.3.2.md @@ -0,0 +1,101 @@ +# Summary since release v1.3.2 — runs 523 to 542 + +Runs: 522 (release reference), 523-542 (focus 524, 525, 526, 527-529, 530-532, 533-538, 539, 540, 541, 542). +Date: 2026-11-20. + +- Reference release: v1.3.2 (0c678b42, 16/11 08:54) = state of run 522. +- Since then: 5 commits on develop (cfb76a2e → b83da585) + uncommitted tree (60 source files). +- Release marker, CSV of 522 at D 1000 over 1 640 rows (800 k → 1.9 M): kill 19.2, hit 0.38, fire 0.28/s, `r` +0.0025. No run since has held D 1000. + +## 1. Each change, its problem, its effect + +| # | Change (run) | Problem targeted | Measured effect | Verdict | In tree | +|---|---|---|---|---|---| +| 1 | Flattened 7-conv CNN instead of spatial softmax (other-PC witness, 523+) | softmax does not localise laterally (left/right 0.51 supervised) | left/right decodable 0.75-0.79; witness with separate credit: turret<5° 29 → 40 %, kill 17.8 at D 1000 ≡ 522 | real gain on perception, none on kills at D 1000 | yes | +| 2 | Single advantage: removal of the separate cannon credit and per-group KL stop (523, 524) | let the critic credit aim | turret<5° 16 → 8 %, kill 8 at D 1000 versus 17; cause isolated by the witness | negative, established | replaced by 13 | +| 3 | target_kl 0.05 → 0.10 (524) | the single KL stop cut 45 % of minibatches | skip still 20-34 % | neutral | yes | +| 4 | Φ removed from reward, pure event (525) | Φ aims at the enemy closest to the trajectory, bias | ≡ 524 at equal D | neutral: Φ in the reward alone did nothing | yes | +| 5 | Actor batch 512 → 2400 (526, default since 537) | per-step actor noise | kl ÷5, skip 0; aim unchanged, trigger slower | cleans the optimisation, not the skill | yes | +| 6 | Curriculum on kills per tank, 0.3 / 0.5 (527, 528) | the old hits/shots criterion was satisfied by closing the trigger | D settles where kills ≈ 16 (D 750-850); makes the drop visible, does not fix it | more honest instrument, not a gain | yes | +| 7 | 5 shells per hit instead of 2 (528) | trigger closed beyond 50 m (firing profitable only at 50 % success) | aligned p_fire 50-100 m 0.44 at s9 versus 0.14; then same closure 100-130 k later | delays, does not lift | yes | +| 8 | σ canon cap 0.25, σ init 0.20, canon entropy target −1 (529) | σ 0.5 made target holding unreachable | dwell ×2 at s5-s9 then sweep returned through μ; D never > 700 | hypothesis refuted | yes | +| 9 | Critic pilots: epochs 2 + lr 1e-4 (530), γ 0.99 (531), short value head γ 0.9 (532) | critic blind to alignment | slope of V null in all three; 531 degrades the actor | negative | no | +| 10 | Coloured AR(1) exploration noise (533-537) | corrective gesture drowned in white noise | control 538: white noise ≥ coloured everywhere | negative | no (removed) | +| 11 | Back to spatial softmax + linear command without a·\|a\| (536) | KL skip, growing μ head | skip 0.9, D stayed at 250 | softmax negative; a·\|a\| removal never isolated | a·\|a\| removed: yes | +| 12 | Up-to-date image, fix of one-decision lag (539) | the agent saw t−1 | dwell < 5° ×2 at s3-s5, kill +2 to +4 up to D 700; lost at s12 (0.24 s), kill 16 at D 800 | real bug fixed, gain not held | yes | +| 13 | Cannon credit on H, critic head, per-group KL stop (540 with 3rd CNN, 541, 542) | give the cannon a one-step signal without Φ | see section 2 | not the expected lever | yes | +| 14 | `discrete_target_proba` 0.01 → 0.05 (542) | trigger extinction | inert up to 450 k; `alpha_fire` 1e-4 → 4.5e-4 without retaining p_fire (0.063 → 0.024) | no visible effect | yes | + +Overall reading: two fundamental fixes (1, 12), three hygiene changes (5, 6, 7), the rest neutral or negative. No change brought back the release's level. + +## 2. Runs with H (540, 541, 542) versus 539 + +Probes at side 550, 4 episodes, stochastic. + +| run save | kills | hits/tank-s | hit/shell | yaw < 5° at < 100 m | dwell | μ/yaw gain | corrector | setpoint °/dec | +|---|---|---|---|---|---|---|---|---| +| 539 s3 | 19.8 | 0.067 | 7.5 % | 8.0 % | 0.62 s | −0.012 | 0.59 | 1.2 | +| 539 s5 | 24.0 | 0.082 | 9.1 % | 9.1 % | 0.73 s | −0.014 | 0.59 | 1.0 | +| 539 s12 | 21.0 | 0.053 | 20.8 % | 5.5 % | 0.23 s | −0.023 | 0.51 | 3.1 | +| 541 s3 | 15.2 | 0.046 | 6.8 % | 4.2 % | 1.13 s | −0.002 | 0.51 | 0.6 | +| 541 s9 | 27.5 | 0.088 | 15.4 % | 12.4 % | 0.78 s | −0.011 | 0.58 | 1.7 | +| 541 s12 | 25.8 | 0.073 | 16.9 % | 10.7 % | 0.64 s | −0.010 | 0.53 | 2.5 | +| 541 s16 | 2.5 | 0.007 | 22.3 % | 4.1 % | 0.67 s | −0.001 | 0.51 | 0.6 | +| 541 s20 | 27.0 | 0.066 | 16.6 % | 11.3 % | 1.28 s | −0.008 | 0.57 | 1.2 | +| 541 s26 | 20.8 | 0.062 | 28.6 % | 11.0 % | 0.75 s | −0.009 | 0.56 | 2.1 | +| 542 s3 | 22.2 | 0.069 | 8.2 % | 7.7 % | 1.32 s | −0.004 | 0.57 | 0.5 | +| 542 s9 | 20.5 | 0.057 | 10.3 % | 7.3 % | 0.88 s | −0.005 | 0.55 | 0.8 | +| 542 s13 | 23.0 | 0.059 | 15.1 % | 7.6 % | 0.69 s | −0.008 | 0.53 | 1.5 | +| 542 s16 | 20.0 | 0.048 | 19.4 % | 9.6 % | 0.86 s | −0.004 | 0.54 | 1.4 | +| 542 s19 | 12.8 | 0.043 | 27.5 % | 6.3 % | 0.87 s | −0.002 | 0.55 | 0.7 | + +540 (H on a 3rd CNN): stopped at 147 k, ≡ 541 at s3, nothing beyond. + +### What H does not do + +- **It does not learn the aiming gesture.** μ/yaw gain −0.002 to −0.011 and corrector 0.51-0.59 on all saves of both runs: never above 539 at s3 (−0.012 / 0.59), which has no aim credit. The separate credit on Φ gave turret<5° 29 → 40 % and a dwell of 1.0 s. +- **The signal it must carry is absent.** corr(one-step ΔH, yaw reduction): 0.00 to 0.03 on 541 (s12, s14, s20), 0.00 to 0.06 on 542 (s5 to s13). The measured usefulness threshold was 0.08; the offline measurement that had motivated B gave 0.10, with a dedicated memoryless CNN on a frozen policy. +- H recognises the aligned state (σ(H) 0.13-0.25 aligned versus 0.01-0.03 off-axis, AUC 0.78-0.83) but underestimates the hit ×2.5 to 4 and its one-step difference does not track rotation. + +### What H does + +- **It calms the turret**, on all three runs: setpoint 0.5-0.6 °/decision at s3 versus 1.2, gain divided by 3 to 6. The long dwell (0.7-1.3 s) comes from there. +- **It avoids 539's sweep** (setpoint 3.1 °/decision and dwell 0.23 s at s12). 541 and 542 stay at 0.6-2.5 °/decision and 0.64-1.28 s. +- CSV kills at D 800: 542 22.2, 541 17.5 (25 in high phase), 539 16.3, 538 18.8. One to two runs per arm. + +Reading (Claude's, untested): with a ΔH uncorrelated with the gesture, the cannon receives a normalised advantage close to noise. H's effect resembles that of "taking the cannon out of the GAE": the turret develops no sweep, stays almost still and fires in passing. + +### Verdict + +H is not the aim lever. Its benefit is real but indirect and capped: hits per tank-second 0.05-0.09 at side 550 over the whole duration of both runs, D 1000 never reached. + +## 3. The trigger that closes: what the reward balance says + +Independent of H: it affects 538, 539, 541 and 542, and 522 knew it too (trough at 420-460 k, "uniform tax on firing"). + +Balance per step and per tank, mean of CSV rows at given D (`rest` = r − r_hit − r_rcv = empty-reserve penalties): + +| D | run | kill | fire/s | r_hit | rest | penalty / r_hit | one emptying every | +|---|---|---|---|---|---|---|---| +| 800 | 522 | 18.1 | 0.27 | +0.0038 | −0.0009 | 24 % | 90 s | +| 800 | 538 | 18.8 | 0.62 | +0.0056 | −0.0017 | 30 % | 47 s | +| 800 | 539 | 16.3 | 0.30 | +0.0032 | −0.0007 | 23 % | 108 s | +| 800 | 541 | 17.5 | 0.54 | +0.0047 | −0.0019 | 39 % | 43 s | +| 800 | 542 | 22.2 | 0.90 | +0.0057 | −0.0039 | 68 % | 21 s | +| 950 | 542 | 14.2 | 0.28 | +0.0028 | −0.0012 | 42 % | 80 s | + +- In 542, from 210 k to 345 k, the empty-reserve penalty eats 70 to 80 % of the hit reward and `r` is negative. The only available response is to fire less, and that is what follows. +- Per-shell count at D 800 (hit ≈ +0.9, emptying −0.8, 10 shells + 5 per hit): a shell is profitable from 6 % success, 2.4 % at D 250. Off-axis shots (0.4-5 %) become loss-making as D rises; aligned shots (38-47 %) stay very profitable (+0.35 to +0.42 per shell). +- Yet the aligned trigger closes with the rest (542: 0.84 → 0.17; 541: 0.84 → 0.08). The aligned / off-axis logit gap stays 3.4-4.1: the actor's detector has fixed quality, only the common level moves. +- With a fixed-quality detector, the equilibrium level falls when good opportunities become rare (enemy at < 50 m: 40 % of the time at side 550, 9-18 % at side 1000) and when the false positive costs more (penalty ∝ D). The drops all start at D 750-850. +- The descent overshoots the equilibrium: at p_fire 0.02 there are almost no shots in the batch to learn that firing aligned pays, and the entropy regulator (α ≤ 5e-4) weighs nothing. + +Established: the table's figures, the constant logit gap, the coincidence with D. +Inferred, not tested by intervention: that indexing the penalty on D is the cause (later ruled out: see `2026-11-20_trigger-closure-diagnosis_508-543.md` §3.5). + +## 4. Open choices (as of 2026-11-20) + +1. Keep or remove the credit on H. Deciding control: cannon with no credit at all (zero advantage, entropy only), judged at s9-s12 against 541/542. +2. Constant empty-reserve penalty instead of −D/1000. +3. Review the economy as a whole. +4. The only setup that held D 1000 (kill 19, hit 0.38 over 1 M steps) remains the release's: separate cannon credit on Φ, set aside on 2026-11-19 because Φ biases target choice. diff --git a/.claude/knowledge/comparisons/2026-11-20_trigger-closure-diagnosis_508-543.md b/.claude/knowledge/comparisons/2026-11-20_trigger-closure-diagnosis_508-543.md new file mode 100644 index 000000000..a1b22e15d --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-20_trigger-closure-diagnosis_508-543.md @@ -0,0 +1,102 @@ +# Diagnosis — why the trigger closes (runs 508 to 543) + +Runs: 508-543 (focus 510, 514, 520, 522, 524, 525, 528, 529, 539, 541, 542, 543). +Written 2026-11-20 after the probe of 543 save_13. Sources: all stochastic probes at side 550 of runs 508-543 (`/probes/save_*_side550.json`, 4 episodes, 32 tanks) and the `metrics.csv`. Complements `2026-11-20_summary-since-v1.3.2.md`. + +## 1. The three run families + +| family | runs | signal driving the cannon | +|---|---|---| +| separate credit on Φ | 510, 512-515, 520-522 | geometric aim potential, one step, no critic; exists whether or not the agent fires | +| pure event | 524, 525, 528, 529, 539 | GAE on hits / received / empty-reserve penalty; exists only if a shell leaves | +| credit on H | 541, 542, 543 | one-step variation of the shot value learned from shots fired | + +## 2. Level reached (CSV) + +| run | family | final index | D max | kill at D max | last 100 rows: D / kill / fire | +|---|---|---|---|---|---| +| 510 | Φ | 867 k | 1000 | 21.4 | 1000 / 21.6 / 1.02 | +| 514 | Φ | 1 052 k | 1000 | 22.4 | 1000 / 22.2 / 0.96 | +| 520 | Φ | 1 136 k | 1000 | 20.1 | 1000 / 22.4 / 0.52 | +| 522 | Φ | 1 902 k | 1000 | 19.2 | 1000 / 20.4 / 0.30 | +| 524 | events | 699 k | 1000 | 8.3 | 1000 / 8.5 / 0.21 | +| 528 | events | 441 k | 750 | 14.9 | 750 / 14.1 / 0.35 | +| 529 | events | 794 k | 700 | 15.8 | 627 / 9.9 / 0.23 | +| 539 | events | 525 k | 800 | 16.3 | 786 / 18.1 / 0.39 | +| 541 | H | 860 k | 900 | 10.8 | 623 / 3.0 / 0.12 | +| 542 | H | 587 k | 950 | 14.2 | 909 / 6.7 / 0.07 | +| 543 | H, constant penalty | 384 k | 750 | 12.5 | 734 / 13.0 / 0.39 | + +All eight Φ-credit runs reach D 1000 (512, 513, 521 included, kill 17-21); none of the other eight holds kill ≥ 17 at D 1000. + +## 3. What the probes establish + +Probes of save_9 and later, side 550. + +| | Φ (45 probes) | events (17) | H (17) | +|---|---|---|---| +| turret < 5° from a target, median | 28 % | 11 % | 13 % | +| hits per tank-second, median | 0.20 | 0.10 | 0.12 | +| hit/shell, median | 0.21 | 0.20 | 0.18 | +| correlation fire rate / turret < 5° across saves | −0.49 | +0.57 | +0.88 | +| turret < 5° when trigger closed (armed p_fire ≤ 0.035) | 31 – 45 % (5 probes) | 6 – 12 % (5) | 2 – 13 % (6) | + +### 3.1 The trigger sorts as well without Φ + +Logit gap between p_fire aligned-near and off-axis, at maturity: + +- Φ: 2.2 to 3.2 (510, 514, 520, 522). +- events: 3.0 to 4.3 (524, 525, 528, 529, 539). +- H: 3.0 to 4.2 (541, 542, 543). + +The "now is the time to fire" detector is at least as good in the failing runs. The trigger is not the failing piece. + +### 3.2 Every family goes through a closure + +Between 240 and 430 k the empty-reserve penalty lowers the common level of the trigger, in all three families: + +- 522: armed p_fire 0.055 (s9) → 0.025 (s10) → 0.017 (s16), then 0.03-0.06 from s24 to s68. +- 520: 0.030 at s16, then 0.06-0.19. +- 524 / 525: 0.022 / 0.026 at s9, stay there. +- 541: 0.016 → 0.003 (s14-s16), 0.18 at s20, 0.015 at s24. +- 543: 0.009 at s13. + +The release (522) is itself a run with a very closed trigger: 0.3-0.5 shot per tank-second, the rate of the "extinguished" phases of 524, 528 and 529. + +### 3.3 What differs during the closure: the turret + +With the trigger closed, the turret of the Φ runs keeps aiming (31-45 % of the time at < 5°), because its signal does not depend on firing. The rare shells then leave well placed: hit/shell 0.36-0.46 in 522. Reward stays positive and the level stabilises. + +In the runs without Φ the turret signal exists only through shells fired. Trigger closed, the turret is at < 5° only 2 to 13 % of the time. The rare shells leave badly (543 s13: 51 % at more than 20°), nothing tells the trigger any more that firing aligned pays, and the level keeps dropping. The across-save correlation between fire rate and aim is positive in these runs (+0.57 and +0.88) and negative in the Φ runs. + +541 already showed it in both its drops: the turret lets go one save before the aligned trigger. + +### 3.4 H worsens the drop + +With trigger closed, the turret of the H runs falls lower (2-5 % in 541 s14-s16 and 543 s13) than that of the pure event runs (6-12 %), and so does the trigger level (0.003-0.016 versus 0.012-0.028). H is labelled only on shots fired and its advantage is normalised: without shots the cannon receives a unit-variance signal with no content. Mechanism inferred, not tested. + +### 3.5 The empty-reserve penalty is not the cause + +543 (constant penalty 0.5) closes at D 700-750 and 351 k, earlier than 541 (−D/1000, D 850, 378 k). The indexing on D, suspected in the summary, is ruled out. + +## 4. Diagnosis + +Two skills that condition each other share a single signal: + +1. aiming pays only if a shell leaves; +2. firing pays only if the turret is aligned. + +The empty-reserve penalty pushes the trigger level down, as intended. With an aim signal independent of firing, the descent stops on a stable point: turret aligned, few shells, well placed (510-522). Without it, the descent cuts the aim signal, the turret drifts, the remaining shells lose their value, and the loop closes on extinction (524, 525, 529, 543) or on a dump / extinction oscillation (541). + +Established: sections 2 and 3.1 to 3.3, 3.5. +Inferred: causal direction turret → trigger (temporal order in 541, correlations); mechanism of 3.4. +Not tested by intervention: that an aim signal independent of firing suffices on the current tree (flattened CNN + up-to-date image). The other PC's witness (flattened CNN, Φ credit, without up-to-date image) gives kill 17.8 at D 1000 and turret < 5° 40 %. + +## 5. Possibilities (none run as of 2026-11-20) + +1. **Restore the separate cannon credit on Φ** on the current tree. Only setup that held D 1000, eight runs out of eight. Never tried with the up-to-date image. Known objection: Φ picks the enemy closest to the trajectory, hence biases target choice. +2. **Same structure, target-independent potential**: cannon credit on a geometric quantity that does not designate an enemy (e.g. "the theoretical shell would hit an enemy body", already computed for runs 481-485). To define and measure offline (one-step correlation with the gesture, threshold 0.08) before any code. +3. **Φ as primer, removed afterwards**: Φ credit until aim holds, then weight brought to 0. Measured risk: without an independent signal, aim is not maintained (3.3). +4. **Stay without an independent aim signal**: no measured lever left; 16 runs (523-543) varied reward, penalty, economy, entropy, batch, noise, critic, H there. + +Ruled out by measurements: tuning the empty-reserve penalty (543), raising the trigger's entropy target (542), H as is (541-543). diff --git a/.claude/knowledge/comparisons/2026-11-21_hit-probability-potential-offline.md b/.claude/knowledge/comparisons/2026-11-21_hit-probability-potential-offline.md new file mode 100644 index 000000000..cf66ba16d --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-21_hit-probability-potential-offline.md @@ -0,0 +1,65 @@ +# Offline measurement — cannon credit on the hit probability (2026-11-21) + +Runs: 543 (save_8, save_13), 541 (save_12). +Question: does a "hit probability" potential P, alone or summed with the event advantage, credit the aiming gesture at one step? No training code touched. Scripts and data: `outputs/comparisons/2026-11-21_potentiel_proba_touche/` (`proba.py`, `flanc.py`, `data/*.csv`, raw output `data/proba_resultats.txt`). + +## Method + +- Data: `arenai_agent_sigma_gradients` (`build/` binary of 20/11 18:39), 4 episodes, 32 tanks, on 543 save_8 (sides 550 and 1000), 541 save_12 (550), 543 save_13 (550). +- P = 1 − ∏(1 − p_i), p_i = share of a Gaussian of dispersion σ centred on the cannon that falls within the angular width of enemy i (half-width 3.5 m). 2D positions of all living tanks; angle and distance of the nearest taken as the game gives them. +- Φ: lateral replica of the removed potential (max over enemies, 3 m bell). +- One-step advantage γ·X(s′) − X(s), γ 0.998. Event GAE = column `advantage` (run's critic, λ 0.95). +- Measure: correlation with the corrective gesture (definitions of `credit.py`), standard error by bootstrap over tank-episodes. Usefulness threshold fixed 2026-11-12: 0.08. + +Limits: no terrain occlusion, no ballistics; elevation (site) known only for the nearest enemy; the Φ replica gives 0.05 where the real Φ measured 0.085-0.12 on the 522 policies, so absolute values are not comparable to this threshold from one run to another. The reliable comparison is P against Φ on the same rows. + +## Results + +Yaw gesture toward the target, 1-40°, target within 100 m (± 0.01): + +| signal | 543 s8 s550 | 543 s8 s1000 | 541 s12 s550 | 543 s13 s550 | +|---|---|---|---|---| +| event GAE | +0.007 | −0.004 | +0.010 | +0.011 | +| Φ (replica) | +0.046 | +0.056 | +0.050 | +0.080 | +| P σ 1.6° | +0.051 | +0.052 | +0.050 | +0.113 | +| P σ 3° | +0.062 | +0.054 | +0.053 | +0.141 | +| P σ 6° | +0.076 | +0.056 | +0.049 | +0.167 | +| P σ 10° | +0.082 | +0.063 | +0.042 | +0.182 | +| P σ 1.6° + 0.25 × GAE | +0.051 | +0.049 | +0.050 | +0.112 | +| P σ 1.6° + 0.5 × GAE | +0.048 | +0.043 | +0.048 | +0.105 | +| P σ 1.6° + 1 × GAE | +0.040 | +0.031 | +0.041 | +0.085 | + +Other gestures: + +| gesture | signal | 543 s8 s550 | 543 s8 s1000 | 541 s12 s550 | 543 s13 s550 | +|---|---|---|---|---|---| +| yaw, target at 100-300 m | P σ 1.6° | +0.031 | +0.024 | +0.045 | +0.066 | +| yaw, target at 100-300 m | P σ 10° | +0.050 | +0.069 | +0.028 | +0.177 | +| yaw, enemy out of field (≥ 40°) | P σ 1.6° | −0.001 | +0.001 | +0.009 | +0.001 | +| yaw, enemy out of field (≥ 40°) | event GAE | +0.008 | +0.003 | −0.005 | +0.004 | +| yaw, enemy out of field (≥ 40°) | P + 1 × GAE | +0.004 | +0.003 | +0.003 | +0.003 | +| elevation (site) toward target | P (yaw only) | +0.006 | +0.006 | +0.001 | −0.002 | +| elevation toward target | site term alone, σ 1.6° | +0.112 | +0.135 | +0.148 | +0.142 | +| elevation toward target | P yaw × site, σ 1.6° | +0.060 | +0.062 | +0.056 | +0.059 | +| yaw toward target < 100 m | P yaw × site, σ 1.6° | −0.002 | +0.027 | +0.022 | +0.021 | + +## Reading + +Established: + +- **P equals Φ for yaw.** Equal on three checkpoints, above on 543 save_13. It designates no target, and costs nothing in signal. +- **Events do not credit the gesture**, at any distance: 0.00 to 0.01, within standard error. Neither pointing, nor turning toward an off-field enemy. +- **The sum does no harm at low weight** (≤ 0.25), loses 5-15 % at 0.5 and 20-40 % at equal weight. It brings nothing measurable, on any gesture. +- **Elevation needs its own term**: 0.11 to 0.15 alone, 0.06 multiplied with yaw, and the multiplication also divides the yaw signal by two or more. +- **A wider dispersion carries further**: at 100-300 m, σ 10° gives +0.05 to +0.18 versus +0.02 to +0.07 for σ 1.6°. Clear effect on 543 (two saves), null or inverse on 541. + +Not established: + +- The absolute level against the 0.08 threshold (see limits). With σ 1.6°, P is at 0.05 on the three open-trigger checkpoints. +- That the sum settles target choice. Nothing credits the gesture toward an enemy on the flank: neither P, nor Φ, nor events. + +## What it changes for lead 2 (see `2026-11-20_trigger-closure-diagnosis_508-543.md` §5, possibility 2) + +- P can replace Φ without loss and without designating a target. +- The argument "events will choose the target" is not supported by the measurement: their signal on the gesture is null at one step. The sum stays harmless at weight ≤ 0.25. +- The cannon has two axes and one term per axis is needed. diff --git a/.claude/knowledge/comparisons/2026-11-21_run-545-vs-546-early.md b/.claude/knowledge/comparisons/2026-11-21_run-545-vs-546-early.md new file mode 100644 index 000000000..6c632aa84 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-21_run-545-vs-546-early.md @@ -0,0 +1,48 @@ +# 545 vs 546 — early run (point at 101 k) + +Runs: 545, 546. +Date: 2026-11-21. + +## Runs + +| run | state | index | D | code | throughput | +|---|---|---|---|---|---| +| 545 | finished | 873 k | 1000 | `d85cc90f` | 96 k steps/h | +| 546 | **running** | 101 k | 400 | `1720af12` | 120 k steps/h | + +## Differences + +- `config.json`: none. +- Code (`d85cc90f` → `1720af12`): death on arena exit (square of half-side 2000) and direction of the received shot in proprioception (+3 inputs, held 2 s). Two **confounded** changes, plus the seed. +- Metrics: same columns; `s` and `r_rcv` now include arena exits. + +## At equal index (both at D 400 since 67 k) + +| index | kill 545 / 546 | fire (shots/s) | hit/shell | r_hit ×1e-3 | r_rcv ×1e-3 | s | kl | Hc | +|---|---|---|---|---|---|---|---|---| +| 20 k | 22.2 / 21.7 | 1.26 / 1.54 | 0.158 / 0.155 | 9.7 / 10 | −3.2 / −3.3 | 34.9 / 34.5 | 0.020 / 0.031 | −0.29 / −0.36 | +| 40 k | 25.5 / 25.7 | 1.26 / 1.85 | 0.173 / 0.164 | 10 / 12 | −3.5 / −3.9 | 37.1 / 32.2 | 0.036 / 0.038 | −0.64 / −0.55 | +| 60 k | 26.3 / 26.8 | 1.20 / 1.65 | 0.165 / 0.153 | 10 / 12 | −3.5 / −4.1 | 38.2 / 34.5 | 0.047 / 0.061 | −0.75 / −0.75 | +| 80 k | 25.1 / 26.9 | 0.98 / 1.77 | 0.154 / 0.147 | 9.7 / 13 | −3.2 / −4.2 | 45.6 / 33.8 | 0.043 / 0.054 | −0.68 / −0.94 | +| 100 k | 24.1 / 26.2 | 1.03 / 1.67 | 0.147 / 0.144 | 7.9 / 13 | −2.6 / −4.4 | 41.1 / 34.0 | 0.043 / 0.089 | −0.78 / −1.02 | + +`skip_canon`: 0.08 (545) vs 0.11 (546) at 100 k; `skip` 0 in both. + +## Trajectories + +- D milestones identical to the thousand up to D 400 (67 k): maximal curriculum cadence, separates nothing. 545 passes D 450 at 114 k; 546 is not there yet. +- 545: kill peak 26.6 at 58 k then drop to 24 from 80-100 k, fire falling to 1.0, then trough D 450-800 (r ≈ 0, kill 21.5-23). +- 546: kill held at 26-27 from 60 to 100 k, fire held at 1.7. + +## Verdict + +- **Kill: within noise** up to 60 k; +2 at 80-100 k, a single D level, not established. +- **Fire throughput +40 to +70 %, held on all slices**: established. Hit/shell −0.3 to −1.2 pt (within noise), hence more hits dealt (r_hit +30 to +60 %) and more received (r_rcv −4.4 vs −2.6). +- **Shorter episodes** (34 s vs 41-45 s): consistent with more combat and arena exits, not separable in the CSV. +- **kl above target** (0.089 at 100 k, max 0.100, target 0.05) and Hc −1.0 vs −0.78: 546 contracts faster. To watch. + +## To settle + +- Crossing of D 450 (545: 114 k) then kill holding on D 450-800, where 545 dips. +- Probe save_3/save_5 of both runs: share of deaths by arena exit, trigger vs alignment, turret reaction to the received-shot direction. +- The two changes separate only through a control run carrying only one. diff --git a/.claude/knowledge/comparisons/2026-11-21_target-localisation-source-cause.md b/.claude/knowledge/comparisons/2026-11-21_target-localisation-source-cause.md new file mode 100644 index 000000000..3dae602fc --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-21_target-localisation-source-cause.md @@ -0,0 +1,25 @@ +# Hypothesis « source = target localisation in the image » REFUTED by control run 548 + +Runs: 545, 546, 547, 548 (`train_548_temoin_gisement`), 550, 522 + +2026-11-21/22: hypothesis refuted by control 548 (target position as input, turret not servoed in 300 k); contains the audit, the aiming funnel, the first-person camera bench and the end-of-episode GAE bug. The developer's request 2026-11-21 (« Φ₂ n'est pas LA solution, cherche le problème de modélisation »). Scripts and plates: `outputs/comparisons/2026-11-21_cause_source/` (`funnel.py`, `gain.py`, `frames.py`, `.venv/bin/python`). + +Measured on 546 s20/s27 and 545 s16 (stochastic probes): +- Command directed toward the nearest visible enemy (5-30° off): +0.10 to +0.20 unit (≈ 1°/decision) at < 60 m, +0.05-0.10 at 60-100 m, ≈ 0 at 100-200 m, 0 out of field; full authority = 6-9°/decision. Yaw = 5-9 % of variance of μ canon_x. Target < 60 m brought < 5° in 1 s: 30-40 % (60 % side 1000 s27). +- Funnel side 550 s27 (armed decisions): close < 100 m 50 % → in field 19 % → yaw < 5° 11 % → aligned 5 % → fire 13 %. Out of field among close 59-67 %. +- σ canon_x 0.09-0.13 aligned, 0.3-0.5 at 5-40° (noise 4× the directed command); hold < 2° from one decision to the next 0.82 (0.90-0.95 at low noise). α_canon_x 0.001 → 0.087. +- Composition side 1000: 56 % of rows after 60 s for 23 % of hits, enemy < 100 m 6-12 % of the time (dead without respawn). +- Trigger: oscillation fire 0.15 ↔ 0.4 (period 100-150 k); sum of (shot − p)·A ≈ 0 at peak (s20, +72 ± 70), clear at trough (s27, +563) ⟹ corrects gae-advantage-trigger-546 (run 546 note): no cause in the actor update. +- Images (522, camera unchanged): 3rd person, agent tank on the firing axis, no reticle, random colours everywhere (terrain, tank parts, 120 objects, debris); enemy at 60-100 m ≈ 10-25 px. + +Code: end of episode on time (5400 frames) without `truncated` ⟹ `compute_gae` chains on V of the 1st state of the next episode for survivors (`final_state_` of the buffer never used); < 1 % of rows, not fixed. + +Reading (Claude's, by cross-reading comparisons/2026-11-16_cnn-bench-spatial-softmax.md, alignment decoding 522 s68, comparisons/2026-11-18_critic-blind-to-aiming-gesture.md, not by intervention): source = target localisation in the image, not learned; trigger, dump, economy = downstream. Deciding test proposed to the developer 2026-11-21 (not decided): disposable control run with target bearing in the state. Nothing coded without their answer. + +**First-person camera bench (2026-11-22, validated by the developer, `outputs/comparisons/2026-11-22_camera_premiere_personne/`):** camera at canon muzzle (0, 0, 10.5) vs (0, 4, −20), actor 546 save_0, 24 episodes side 550, ~5 k training images, CNN D of the 2026-11-16 bench, 4 seeds. Left/right 0.643 → 0.720; target < 100 m 0.720 → 0.813; corr 0.21 → 0.32; median error < 100 m 9.4° → 8.0°. At 5 episodes no gap. Net but partial gain. `canon.cpp` modification done in `build/` only then undone (source and `build/` restored). The canon camera is shared with the player (`JoltTank::camera`): a run requires deciding the separation. + +**Control run 548 (2026-11-22, pieces validated one by one by the developer):** `outputs/train_548_temoin_gisement`, binary of disposable worktree `/home/samuel/CLionProjects/arenai_wt_temoin` (HEAD 10211f76 + diff of 547 + control, clean `build/`, never merged), launched detached in parallel with 547 (identical config). Addition: 4 proprio values before the received-shot direction = nearest living enemy in field (±39.5° / ±22.5°, canon frame, no occlusion test): yaw/39.5°, elevation/22.5°, min(1, 50 m/d), presence. Probe with the worktree binary. Criterion: command directed toward visible target at 5-30° (≈ 1°/decision without control, full authority 6-9°) and target < 60 m brought < 5° in 1 s (30-40 %), vs 547 at same saves (`gain.py`). + +**548 at save_3 / save_7 (81 k / 189 k, side 550, `outputs/comparisons/2026-11-22_temoin_gisement/`):** directed command < 60 m 0.87 / 1.10°/decision vs 547 0.73 / 0.70; target < 60 m brought < 5° in 1 s 30 / 31 % vs 30 / 26 %; CSV kill and hit equal. Yaw-column weight in layer 1: 0.98 → 1.39 → 1.83 (others fixed): the input is read, the turret is not servoed. ⟹ Claude's « perception = source » reading not confirmed at 189 k; the developer (2026-11-22) leans to reward/economy, learning or control. Both runs σ canon 0.05-0.07 and kl 0.085-0.094 at 170-190 k. + +**548 at save_11 (297 k, D 750):** directed command < 60 m 0.96°/decision vs 547 0.97; brought < 5° in 1 s 42 % vs 30 %; yaw = 14 % of var(μ) vs 6 %; yaw-column weight 2.33; CSV kill/hit equal (27.1 / 0.141 vs 26.3 / 0.132). ⟹ **« perception = source » hypothesis refuted**: with the target position as input the turret is not servoed in 300 k. Look at command learning (σ canon 0.05-0.07 + kl 0.07-0.09 and 13-20 % canon steps skipped at 100-200 k), control (delay of 2 decisions), Φ₂ credit. Never present camera or colours as the main lever again. (see docs/decisions.md 2026-11-10: CNN perception ruled out) diff --git a/.claude/knowledge/comparisons/2026-11-22_canon-sigma-collapsed-early-in-run.md b/.claude/knowledge/comparisons/2026-11-22_canon-sigma-collapsed-early-in-run.md new file mode 100644 index 000000000..39637947d --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-22_canon-sigma-collapsed-early-in-run.md @@ -0,0 +1,33 @@ +# Canon σ collapsed early in run (0.02-0.04 up to 300 k); « collapsed σ = brake » hypothesis withdrawn + +Runs: 510, 514, 522, 546, 547, 548 (save_7/11) + +2026-11-22: σ canon_x 0.02-0.04 from 81 to 300 k then 0.3; hypothesis « collapsed σ = brake » WITHDRAWN (closure 0.3-1°/decision identical in 510-547 whatever σ); end-of-episode GAE + target −1 committed `dcca274e`. + +Measurement 2026-11-22 after the refutation of « perception = source » (comparisons/2026-11-21_target-localisation-source-cause.md), `sigma_gradients` on control 548 save_7 (`outputs/comparisons/2026-11-22_temoin_gisement/grad.py`, `grad_548_s7.csv`) + probes 546/547/548. + +- Φ₂ credit correct and monotone: action toward target > 0.2 unit ⟹ advantage +1.0; opposite −0.3; ρ(A, gesture) 0.10 at < 60 m. +- Entropy bonus traction on μ: 0.0009 vs 3.8 for credit. +- Turret delay minor: 8-10°/unit in the same decision, 1.4-5.7 at the next. +- Median σ canon_x: 0.033-0.038 (547 s3-s11), 0.024-0.028 (548 s7/s11), 0.14-0.16 at s13, 0.26-0.31 at s24-s27 (546/547). μ displacement allowed by KL threshold 0.075: σ·√0.15 ≈ 0.01 unit per rollout at start; kl 0.07-0.09 and skip_canon 13-20 % at 100-200 k; α_canon_x 0.004 at 189 k (regulator too slow at start, overshooting at the end). +- Control's yaw-column weight: +0.4 to +0.5 per 100 k, linear. +- Not demonstrated: that this brake alone explains the weak command (≈ 8 % of full authority). + +The developer's decisions 2026-11-22 (one question per piece): GAE bootstrapped on the last state of the episode at time limit; entropy target −1 on the four continuous actions, **without** hard σ floor nor faster regulator (proposed, set aside); empty end of game not handled in this run. + +Coded uncommitted in the repo (build/ compiled, 2 448 tests ok, only failure = pre-existing unstable `TruncatedNormalEdgeTest.LogPdfAndPdfConsistent`; real 4-min trial with 20 s episodes without error): `episode_ends` + `closing_states` in the 3 rollout buffers, `closed_next_values` / `with_episode_ends` in `ppo_objective`, the 3 trainers (GAE recursion and ReturnScaler cut at episode ends, bootstrap kept), default `continuous_target_entropy` −1 in the 3 hyperparams. Shells per hit back to 2 (like 546) 2026-11-22; `main.cpp` now reads the default from GAME_SHELL_ECONOMY. The developer runs themself, on the other PC, the twin run without Φ in full single advantage (one ratio, one KL stop). + +**Rule:** read the next run on median σ canon_x at saves 3-11 and the directed command (`compare.py`, `gain.py`); if σ falls under 0.09 at the start, re-propose the floor (but see withdrawal below). Never `pkill -f` a pattern present in the current shell's command line (redone 2026-11-22): kill by PID. + +**Hypothesis « collapsed σ = brake » withdrawn 2026-11-22 (inter-run comparison, probes side 550):** real closure on visible target < 100 m at 5-30° = 0.3-1.0°/decision and « < 5° in 1 s » = 19-33 % in ALL runs, whether turret σ is 0.03-0.05 (546 s9, 547 s11) or 0.2-0.55 (510 s9-s28, 514, 522 s10-s68); std of Δyaw 3-5°/decision everywhere. Invariant to σ, a·|a| (514/522), Φ/Φ₂, 2/5 shells, target position as input (548). Never propose a σ floor again (no patches; see docs/decisions.md 2026-11-22: hard σ floor refused). Unmeasured lead: Claude's « toward target » aims at the nearest visible while Φ₂ credits the argmax over all enemies. + +**Φ₂ target measured 2026-11-22 (`cible_phi.py`, `variance_credit.py`, horizontal replica of Φ₂ on `grad_548_s7.csv`, corr 0.61 with run credit):** when the nearest is visible < 100 m at 5-30°, Φ₂ designates that same enemy 94 % of the time ⟹ hypothesis « my measurement looks at the wrong target » rejected. ρ(credit, gesture toward Φ₂ target) 0.08-0.10 at any gap, out-of-field included; directed command 0.04 unit in view, 0.01 out of field. Variance of ΔΦ: 41 % own turret rotation, 65 % exogenous; exploration noise explains only 4-5 % of own rotation (corr −0.2). Control's directed command flat at s3/s7/s11 (0.87 / 1.10 / 0.96°/decision) while the input weight grows, and flat in 522 from s10 to s68 ⟹ plateau, not slow growth. Cause of the plateau not found; proposed test: replay a per-group update (canon only / rest only) from a save and measure displacement of the directed command. + +**Per-group update replay (2026-11-22, 548 save_11, 12 rollouts, `rejeu.py`, `rejeu_548_s11.csv`; tool `sigma_gradients --update_replay` + `LiquidPpoTrainer::update_replay` in worktree `arenai_wt_temoin` only):** quadratic displacement of the turret command per update 0.014-0.018 unit; the « rest » group update alone moves it as much or more than canon alone (0.018-0.020 vs 0.016) and moves log σ turret by +0.029 (canon alone +0.017) ⟹ interference through the shared trunk, established. Directed share ≤ 10 % of displacement: visible target < 60 m +0.0012 ± 0.0029 (real), +0.0016 ± 0.0024 (canon alone), −0.0040 ± 0.0036 (rest alone), not significant at 12 rollouts. Directed gain « in sample » also out of field (+0.003 ± 0.001), where direction is unobservable ⟹ suspicion of rollout fitting, to confirm out of sample. Trigger: aligned p_fire falls in all three modes, canon alone included (−0.0015). + +**Extended replay (2026-11-22, 548 save_11, 60 rollouts, `rejeu2.py`, `rejeu2_548_s11.csv`; per-group modes with Adam momentum zeroed; out-of-sample rows = previous rollout). Replaces the 12-rollout replay, whose « rest alone » mode was polluted by momentum.** Δ directed command per update, ×1e-3: +- canon alone, in sample: all rows +3.55 ± 0.66, out of field +3.47 ± 0.80 (direction unobservable), visible < 100 m +3.45 ± 1.01; +- canon alone, out of sample: all rows −0.52 ± 0.40, out of field +0.04 ± 0.54, visible < 100 m −0.33 ± 0.78, visible < 60 m +2.18 ± 1.15; +- quadratic displacement out of sample 0.0139 (canon alone), 0.0100 (rest alone), 0.0146 (real). +⟹ **the canon update fits its rollout and does not generalise**: the policy moves ~0.014 unit per update on unseen states, without direction; that is the plateau. Interference of the « rest » group through the trunk confirmed without momentum: 70 % of canon's own amplitude, undirected. +- Trigger, Δp ×1e-3 out of sample: real (momentum kept) −3.36 ± 0.42 aligned < 2°, −6.16 ± 0.78 off-axis; without momentum ≈ 0; rest alone +0.58 ± 0.43 (+1.51 ± 0.50 in sample). Confounded: the tool's environment lacks the empty-reserve penalty (0 without curriculum) and plays side 550, while momentum comes from real training; do not conclude « it is the momentum ». diff --git a/.claude/knowledge/comparisons/2026-11-23_direct-branch-liquid-cell.md b/.claude/knowledge/comparisons/2026-11-23_direct-branch-liquid-cell.md new file mode 100644 index 000000000..657467336 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-23_direct-branch-liquid-cell.md @@ -0,0 +1,15 @@ +# Direct branch encoder → heads in the liquid cell (run 551 test of cell delay) + +Runs: 550 (twin), 551 + +2026-11-23: direct branch encoder → heads (Linear 320→128 + LayerNorm + SiLU, concatenated at the cell output) coded in `LiquidActor` and `LiquidCritic`, uncommitted; tests the ~1.5-decision delay of the cell, without Φ. + +After the analysis of run 550, the developer chose « terme direct seul, sans Φ », then validated piece by piece: actor **and** critic, same form as the skip of 416-418 (commit `1604dc5c`), standard init (`init_hidden_weights` on the branch, heads unchanged). + +Code (uncommitted at the time): module `direct` in `arenai_agent/src/networks/recurrent/liquid_actor.{h,cpp}` and `liquid_critic.{h,cpp}`; heads μ, σ, fire and `to_value` as `Linear(2 × neuron_number → ·)`; `features` of `LiquidActorOutput` = concatenation (256). Compiled in `build/` (2442 tests OK, 109 pre-existing ignored), real 4-min trial without error. Checkpoints ≤ 550 incompatible: 550 probe binaries kept in `outputs/train_550_ppo_liquid/probe_bin` (probe, sigma_gradients, libarenai_agent.so). `cmake-build-release/` not rebuilt (550 was running there). + +**Why:** heads wired to the cell state only ⟹ μ canon_x reaches 48/76/89 % of a change in 1/2/3 decisions; every delay removed from the loop improved aim (stabiliser 2026-11-12, up-to-date image 2026-11-19). 417/418 had this skip but confounded with bigger CNN and LTC, before these fixes. + +**Test plan:** twin = 550 (same config, no Φ). Criteria at saves 3-11 then at equal D: μ response to a crossing target (`probes/reponse.py`), directed command decomposed by side, « < 5° in 1 s », dwell < 5°. Note: without Φ the gesture gradient is zero (ρ ≈ 0), this run tests the delay alone; a null result does not condemn the branch with Φ. + +**Outcome (same day):** branch **removed 2026-11-23** at the developer's request: delay removed but behaviour ≡ 550 (see comparisons/2026-11-23_turret-bimodal-per-pass-engagement.md; run 551 file). Probe 551 with `outputs/train_551_ppo_liquid/probe_bin`. diff --git a/.claude/knowledge/comparisons/2026-11-23_presence-head-cnn-enemy-map.md b/.claude/knowledge/comparisons/2026-11-23_presence-head-cnn-enemy-map.md new file mode 100644 index 000000000..dbd319d95 --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-23_presence-head-cnn-enemy-map.md @@ -0,0 +1,22 @@ +# Presence head on the CNNs: 8×16 enemy-presence map (coded 2026-11-23) + +Runs: 550, 551, 552 (first run), 536 (cited) + +2026-11-23 — auxiliary head « enemy presence map » coded on the actor and critic CNNs of the 3 trainers, validated piece by piece, uncommitted. (outcome: removed 2026-11-25 after game matches vs twin 550, see docs/decisions.md; superseded by the panorama mask loss 2026-11-27) + +Coded 2026-11-23 after the bimodal-engagement analysis (comparisons/2026-11-23_turret-bimodal-per-pass-engagement.md: the CNN does not extract one visible target in two). The developer lifted their refusal of the auxiliary head (« si le cnn n'apprend pas au final je suis ok »). Uncommitted; build/ compiled, ctest 5/5, 3 tests `PresenceTest`, real 5-min trial without error, map checked by eye (`outputs/comparisons/2026-11-23_origine_balayage/carte_entrainement_controle.png`). + +Pieces validated one by one: +- target: 8×16 map (after CNN block 4, `PRESENCE_BLOCKS`), 1 on all cells covered by a living enemy, in view (free ray within 8 m), footprint 7 m × 3 m; +- on both CNNs (actor and critic), the three trainers (ppo, ppo_liquid, ppg), permanent; +- Adam optimiser separate per CNN, `--presence_learning_rate` 3e-4, one pass per rollout in blocks of the carrier network's GPU size, after the PPO updates; +- loss: simple binary cross-entropy, unweighted (bench: ≡ weighted); +- projection: render matrix. Public contracts modified with his agreement: `AbstractRenderer::last_view_projection()` (lifted from `AbstractPlayerRenderer`), `EnemyVisionThreadPool::read_view_projection(int)`, `BaseTanksEnvironment::read_view_projections()` (protected). + +Code: interface `networks/presence_model.h` (`PresenceModel`: `presence_logits`, `presence_parameters`) implemented by ConvolutionNetwork, Actor, ValueFunction, LiquidActor, LiquidCritic — validated by the developer in place of a `vision()` getter that Claude had added without asking; `networks/vision.{h,cpp}` (`presence_grid_size`), `agents/presence_learner.{h,cpp}`, `TrainTankEnvironment::presence_maps`, `AbstractStepCollector::on_presence` (SAC: no effect), field `presence` of the 3 buffers. The probe has `--presence` and `--sightings`. Metric `pres` (head loss, actor and critic combined) added at the developer's request 2026-11-23, bar and CSV. Checkpoints ≤ 551 no longer load (extra `presence` parameter in the CNN). The Python ExecuTorch conversion script was not verified with this extra parameter. + +**Test plan:** first run = to read with `reaction.py` / `suite.py` (share of engaged passes at < 60 / 60-100 m, reference 551: 40 / 19 %, i.e. ~49 / 20 % net of background) and `decodage.py`. Non-recentring once stopped is a second defect this head does not target. + +**Variant planned by the developer (2026-11-23):** remove blocks 5 to 7 and `PRESENCE_BLOCKS`, presence head on the final 8×16 map, spatial softmax for the policy reading. They code it themself on their other PC, with Claude's help there; offline bench proposed here, declined. Warnings given: 2026-11-16 bench (4 blocks + softmax: left/right 0.51 even supervised, comparisons/2026-11-16_cnn-bench-spatial-softmax.md), run 536 lost (spatial softmax, without a·|a|), softmax without presence signal nor size; the combination softmax + presence supervision was never measured. + +**Three-readings bench (2026-11-23, `banc_lectures.py`, report §10, requested by the developer without touching code)**: horizontal position of the nearest visible enemy, unseen episode, left/right 0.86-0.96 for the three readings (4 blocks + spatial softmax, 4 blocks + flattened, 7 blocks flattened); with blocks 1-4 trained by presence alone: 0.90-0.95. The 0.51 of softmax in the 2026-11-16 bench does not reproduce. 7 blocks flattened most precise at ≥ 60 m (0.74-0.89° vs 1.1-2.5°), softmax least precise at < 60 m (2.0-2.4°). Supervised reading: does not say what PPO will do with it. (see docs/decisions.md 2026-11-03 auxiliary head lifted 2026-11-23, removed 2026-11-25) diff --git a/.claude/knowledge/comparisons/2026-11-23_sweep-origin.md b/.claude/knowledge/comparisons/2026-11-23_sweep-origin.md new file mode 100644 index 000000000..67a5bb31d --- /dev/null +++ b/.claude/knowledge/comparisons/2026-11-23_sweep-origin.md @@ -0,0 +1,161 @@ +# Origin of the sweep — 551 save_20 and 550 save_21, side 900 + +Runs: 551 (save_20, 540 k, D 900, direct branch), 550 (save_21, 567 k, D 900), 547/548 (reference). +Date: 2026-11-23. Data: stochastic probes `551/probes/save_20_side900` and `550/probes/save_21_side900`. Scripts and data in `outputs/comparisons/2026-11-23_origine_balayage/` (run with `.venv/bin/python