Snake AI β€” DQN Trainer

Rebuilt learning core: space-aware observations (flood-fill free space per action), n-step Double-DQN targets with correct truncation handling, class-balanced prioritised replay with importance weights, evaluation-driven adaptive exploration, and greedy evaluation runs. The saved brain file format is byte-for-byte the same schema as before (12 inputs, 3 outputs, same weight ordering), so old brains still load and seed a run.

Progress

Episode0
Best score (apples)-
Avg score (apples)-
Eval avg (greedy)-
Eval best (greedy)-
Eval survival (steps)-
Steps / secidle
Epsilon-
Episodes / sec-
Avg episode reward-
Loss-
Avg Q-
Q max-
TD error-
Replay buffer-
Load GPU / CPU-
Learn samples / sec-
Active actors-
Chunk size (steps)-
Plateau-
Map (curriculum)-
Action distribution (straight / right / left)-
Replay composition (apple / death / danger / plain)-
Death reasons (training)-
Death reasons (evaluation)-

Settings

MAX mode maximises learning quality per second: it keeps the target network stable, samples a balanced mixture of apple / death / danger / ordinary transitions, measures real progress with exploration switched off, and only widens exploration when greedy evaluation actually stalls.

In MAX mode the GPU is the gradient engine when WebGPU is available, while CPU cores stay busy on parallel actors. If WebGPU is unavailable, the learner falls back to CPU.

Off by default, since it changes the scoring conditions mid-run. Turn it on to let the move limit grow every 10 episodes when runs keep hitting the cap or the score stalls. It never shrinks.

Part of AI MAXXING: the map grows mid-run instead of staying fixed. Budgets per stage β€” 6Γ—6 18k, 8Γ—8 30k, 10Γ—10 45k, 12Γ—12 75k, 14Γ—14 110k, 16Γ—16 150k, 18Γ—18 225k episodes, then 20Γ—20 keeps the rest (the biggest budget). A stage ends early if greedy evaluation already clears its apple target. The network transfers because every input is board-relative, and the move limit ratchets up with the map. Save format is untouched.

Rewards are normalised to roughly [-1,+1] (apple +1, death -1, small step cost, potential-based food shaping) so Q-values cannot explode. n-step returns, discount, replay mixture quotas and the exploration controller are fixed in code β€” see cfgRead() and EXPLORE in the script.