Commit Graph

72 Commits

Author SHA1 Message Date
Josh Creek 0e046aa9f1 chore(training): scrap generation 1-3 training data for generation 4
All checkpoints/logs/exported policies here are a continuous-Gaussian,
31-input action/observation shape that generation 4's MultiDiscrete
redesign is structurally incompatible with -- nothing to resume from (see
the prior commit and TRAINING.md's "Generation 4" section). Game/bots/promoted/
(easy.json, and the new reference-grounded.json copied from
curric-s5-aggression before this) is untouched -- both remain valid,
playable evaluation opponents forever via PolicyNetwork's format-versioned
JSON despite their own checkpoints/generation being gone.

- training/checkpoints/*, training/logs/* removed (~3.5GB of working tree,
  all generation 1-3 experiment runs).
- Game/bots/*.json flat dump removed (superseded exports; main_menu.gd's
  Spectate dropdown will just be empty until the first generation-4 export).
- curriculum_state.json -> curriculum_state_gen3.json, archived alongside
  the existing _gen1/_gen2 logs (all three are referenced as postmortem
  evidence in TRAINING.md/curriculum.py). A fresh curriculum_state.json
  will be created on the next curriculum.py run (load_state() already
  handles a missing file).

training/eval_history.json is deliberately NOT reset -- it's the one
continuous cross-generation progress record.

NOT YET PUSHED: this needs the remote Linux training box quiesced first
(kill any active tmux session, confirm it's synced to origin) so its own
run_training.sh doesn't race a still-running job's final commit against
this deletion.
2026-08-04 23:28:57 +01:00
Josh Creek 1811e9333e feat(training): curriculum generation 4 — MultiDiscrete action space redesign
Three curriculum generations (2026-07-21 through 2026-08-04) all tried
gating *when* the policy could use vertical thrust/pitch-roll on top of a
continuous Gaussian action space, and all three failed the same way: PPO's
action-distribution std collapsed within ~10% of steps and never recovered,
landing at a 15-32% win rate vs the grounded reference regardless of
mechanism (hard mask, then a gradual ramp). Generation 3's final attempt
just landed at 24% — the worst of the three.

Root cause, verified against this project's own physics: hovering this ship
requires *holding* thrust.y ~= 0.408 continuously (mass 5.0, vertical_thrust
120, gravity 9.8). A collapsed near-zero-mean Gaussian can brush that value
but never sustain it long enough to earn the reward gradient that would
move the mean — no amount of gating *when* the axis acts fixes a problem in
*how* the policy represents a decision on it. This also independently found
and fixes a real bug: godot_rl never marks an episode timeout as a
truncation, so PPO was bootstrapping V(s)=0 on every 30s draw in every
generation to date.

- Game/scripts/ship_action_codec.gd (new): single source of truth for a
  per-axis MultiDiscrete action space (7 heads, nvec [5,5,5,5,5,5,2]) shared
  by training and in-game inference, replacing the continuous Gaussian.
  thrust_y's bins are deliberately asymmetric so a random policy drifts
  through the volume instead of floor-pinning. Legacy continuous decode
  (ai_ship_controller.gd's old logic) preserved verbatim so every
  pre-generation-4 export (e.g. Game/bots/promoted/easy.json) keeps working
  unchanged via an optional "action_space" JSON field.
- ship_observations.gd: append own contact state (SIZE 31 -> 35, append-only)
  so the value function can see what wall_contact_penalty fires on.
- ship_ai_controller.gd: action space/decode via the codec; drop the
  vertical_ramp/pitch_roll_ramp mechanism entirely; tilt_penalty default
  lowered 4x (aerial approaches require pitching); flight telemetry
  (airborne_fraction, mean_altitude, air_touch_fraction, vertical_thrust_mean)
  and truncation-snapshot fields on get_info().
- training_mode.gd: new air_drill_chance state-setter branch (ball spawned
  high, ships low, kept clear of walls) so aerial practice is forced by the
  environment instead of relying on reward-driven exploration alone; snapshot
  terminal observations before a timeout reset for the truncation fix.
- cosmic_env.py: remap ShipAIController's truncated/terminal_obs info into
  SB3's TimeLimit.truncated/terminal_observation keys.
- train.py: --reset-logits (+ --reset-logits-heads) replaces the
  now-meaningless --reset-std; new EntropyFloorCallback (a persistent
  per-rollout ent_coef controller replacing the one-shot std-reset shock)
  and per-head entropy logging; FlightTelemetryCallback; --air-drill-chance/
  --tilt-penalty flags; optional AbortIfCallback kill-criterion.
- export_policy.py: writes the action_space block for MultiDiscrete models;
  index-level parity check (argmax per head) instead of comparing floats.
- curriculum.py: full rewrite — 3 stages (bootstrap/selfplay/gauntlet), no
  grounded stage, full action space live from step 1; deletes generation
  1-3's checkpoint-lineage machinery (nothing to resume from); final report
  evaluates against both promoted/easy.json and the new
  promoted/reference-grounded.json (a copy of curric-s5-aggression, the
  strongest grounded-era artifact, kept as a fixed yardstick).
- run_training.sh/.gitignore: commit only final.zip, not the ~2400
  intermediate checkpoint files a single stage was writing (~500MB ->
  ~0.2MB per run); requirements.txt pinned (behaviour here now depends on
  specific library internals, not just public APIs).
- test_action_space.py (new): offline rung-0 check catching a head-order
  mismatch before it silently corrupts 24h of training.

Validated: GDScript compiles clean (Godot --headless --import + script
validation), free_play.tscn and training.tscn both boot headless without
errors, offline action-space assertions pass. Not yet run: the actual
smoke-training/A-B validation ladder steps in TRAINING.md's "Generation 4"
section, before committing to the full ~32h curriculum.

See TRAINING.md's "Generation 4" section for the full design writeup.
2026-08-04 23:27:57 +01:00
CosmicClash Training Bot 6198dc67fc chore(training): Add 20260803-1829-curric-s4-unmask-retry2 checkpoints, logs, and exported policy 2026-08-04 22:06:04 +01:00
CosmicClash Training Bot 20f6be7e28 chore(training): curriculum progress after 20260802-1458-curric-s4-unmask-retry1 2026-08-03 18:29:13 +01:00
CosmicClash Training Bot 5fe53b2406 chore(training): Add 20260802-1458-curric-s4-unmask-retry1 checkpoints, logs, and exported policy 2026-08-03 18:27:21 +01:00
CosmicClash Training Bot 62dc0a2981 chore(training): curriculum progress after 20260801-1131-curric-s4-unmask 2026-08-02 14:58:25 +01:00
CosmicClash Training Bot f62ddde369 chore(training): Add 20260801-1131-curric-s4-unmask checkpoints, logs, and exported policy 2026-08-02 14:56:35 +01:00
CosmicClash Training Bot fa53d72f63 chore(training): curriculum progress after 20260801-0658-curric-s3-unmask-ramp75 2026-08-01 11:31:57 +01:00
CosmicClash Training Bot e5a0df63c5 chore(training): Add 20260801-0658-curric-s3-unmask-ramp75 checkpoints, logs, and exported policy 2026-08-01 11:31:48 +01:00
CosmicClash Training Bot be1bf37e0b chore(training): curriculum progress after 20260801-0223-curric-s2-unmask-ramp50 2026-08-01 06:58:20 +01:00
CosmicClash Training Bot 1615791ee0 chore(training): Add 20260801-0223-curric-s2-unmask-ramp50 checkpoints, logs, and exported policy 2026-08-01 06:58:11 +01:00
CosmicClash Training Bot e22b4814f5 chore(training): curriculum progress after 20260731-2149-curric-s1-unmask-ramp25 2026-08-01 02:23:37 +01:00
CosmicClash Training Bot 23b2cd19df chore(training): Add 20260731-2149-curric-s1-unmask-ramp25 checkpoints, logs, and exported policy 2026-08-01 02:23:27 +01:00
Josh Creek 3fd1c00895 feat(training): Replace all-or-nothing unmask with a gradual ramp
Generation 2's single "unmask" stage (flip vertical/pitch-roll locomotion
from grounded-only to full 3D in one step) failed 3 independent 240M-step
attempts, landing at a stable 32% / 28% / 31% win rate vs curric-s5-aggression
each time -- not noise, and not fixable by more training time (attempts 2-3
each continued the same checkpoint lineage for another full 240M steps with
zero improvement). Every attempt shows train/std collapsing from ~0.30 to
~0.13-0.15 within the first ~10% of steps and never recovering: the policy
locks the newly-opened axes back down before ever meaningfully exploring
them.

Replaces the boolean allow_vertical/allow_pitch_roll mask on ShipAIController
with float vertical_ramp/pitch_roll_ramp multipliers (0.0-1.0), scaling axis
effect in set_action() instead of gating it outright -- the action space
never changes shape, so checkpoints stay resumable across ramp values. The
single unmask stage in curriculum.py becomes 4: three ungated warmup stages
(25%/50%/75% authority, airborne_penalty ramping in step) that train,
checkpoint, and always advance with no eval gate, then the measured stage at
full authority -- same reference, opponent mode, and 240M budget as the 3
failed attempts, for a direct comparison. Adds a "gated" flag/branch to
main()'s loop for the ungated stages.

This is generation 3 of the curriculum; generation 2's state is archived to
curriculum_state_gen2.json (mirroring the earlier gen1 -> gen2 archival) and
curriculum_state.json resets fresh, since its stage 0 no longer means what it
used to. See TRAINING.md's "Generation 3" section for the full postmortem,
stage table, and the open question about whether scaling action effect in
Godot (which PPO's own entropy/exploration math never sees) actually
addresses the collapse.
2026-07-31 21:47:53 +01:00
CosmicClash Training Bot 0759e1514b chore(training): curriculum progress after 20260730-1224-curric-s1-unmask-retry2 2026-07-31 16:07:16 +01:00
CosmicClash Training Bot f03037a612 chore(training): Add 20260730-1224-curric-s1-unmask-retry2 checkpoints, logs, and exported policy 2026-07-31 16:04:58 +01:00
CosmicClash Training Bot 6084991f1c chore(training): curriculum progress after 20260729-0837-curric-s1-unmask-retry1 2026-07-30 12:24:45 +01:00
CosmicClash Training Bot f41702e7ea chore(training): Add 20260729-0837-curric-s1-unmask-retry1 checkpoints, logs, and exported policy 2026-07-30 12:22:54 +01:00
Josh Creek efda6c1a05 chore(training): Resume stage 1 unmask from its own checkpoint, not foundation
Generation 2's first two real stage-1 attempts both independently restarted
from curric-s5-aggression (reset_retry_checkpoint) with identical flags and
landed at 32% and 27% win rate vs the reference -- a real regression either
way, but too much spread between "identical" runs for repeat fresh restarts
to be a controlled test of anything. The first attempt's own trajectory
(ep_rew_mean climbing from -10.86 toward ~0 by the 240M-step cutoff,
briefly touching positive) looked closer to convergence than the second's,
so retries now continue that attempt's own checkpoint for another full
timesteps budget instead of resetting to foundation again.

Drops retry1 and retry2 (checkpoints, logs, exported bots, eval_history
entries) -- retry2 never trained meaningfully before crashing on the
GoalRateCallback bug just fixed, and retry1 was the inferior of the two
real samples. curriculum_state.json rewinds to attempt 1, in_progress, so
the next run resumes 20260726-1904-curric-s1-unmask/final.zip directly.
2026-07-29 08:35:34 +01:00
Josh Creek 259b2adc07 fix(training): Guard GoalRateCallback against a missing goal_scored key
The vendored godot_rl sync bridge (Game/addons/godot_rl_agents/sync.gd,
_training_process) snapshots each agent's info dict once per tick and its
own inline comment already flags that reset-timing path as incomplete
("NEEDS REFACTOR"); at least one agent's terminal-step info can arrive
without "goal_scored" at all. Indexing it directly crashed a training run
(20260729-0607-curric-s1-unmask-retry2) within minutes of starting. Skip
episodes missing the key instead of crashing training over a
monitoring-only metric.
2026-07-29 08:35:20 +01:00
CosmicClash Training Bot 8bc16ee048 chore(training): curriculum progress after 20260729-0607-curric-s1-unmask-retry2 2026-07-29 06:09:25 +01:00
CosmicClash Training Bot a6c2ed6177 chore(training): Add 20260729-0607-curric-s1-unmask-retry2 checkpoints, logs, and exported policy 2026-07-29 06:08:10 +01:00
CosmicClash Training Bot 0d29fc44e0 chore(training): curriculum progress after 20260728-0031-curric-s1-unmask-retry1 2026-07-29 06:07:26 +01:00
CosmicClash Training Bot cb3732fcb7 chore(training): Add 20260728-0031-curric-s1-unmask-retry1 checkpoints, logs, and exported policy 2026-07-29 06:05:33 +01:00
Josh Creek bca08d266e feat(*): Log live goal rate to TensorBoard during training 2026-07-28 21:33:41 +01:00
Josh Creek 01dbfc7ede feat(*): Add exported Linux binary training path for faster parallel instances 2026-07-28 20:56:14 +01:00
CosmicClash Training Bot 2533827cf8 chore(training): curriculum progress after 20260726-1904-curric-s1-unmask 2026-07-28 00:30:59 +01:00
CosmicClash Training Bot a0b527b8cb chore(training): Add 20260726-1904-curric-s1-unmask checkpoints, logs, and exported policy 2026-07-28 00:29:06 +01:00
Josh Creek 31aa5cae8c chore(*): Remove superseded pre-curriculum and dead-branch runs 2026-07-26 19:25:22 +01:00
Josh Creek f7d03b1e74 chore(*): Remove superseded curriculum branches 2026-07-26 19:19:01 +01:00
Josh Creek 390bd18be7 feat(*): Start curriculum generation 2, seeded from curric-s5-aggression 2026-07-26 19:00:38 +01:00
CosmicClash Training Bot 33b2c23f13 chore(training): curriculum progress after curric-s6-unmask-retry2 2026-07-26 13:08:35 +01:00
CosmicClash Training Bot 653afe4040 chore(training): Add curric-s6-unmask-retry2 checkpoints, logs, and exported policy 2026-07-26 13:06:31 +01:00
CosmicClash Training Bot 28109756dd chore(training): curriculum progress after curric-s6-unmask-retry1 2026-07-25 07:41:43 +01:00
CosmicClash Training Bot 4e0efec612 chore(training): Add curric-s6-unmask-retry1 checkpoints, logs, and exported policy 2026-07-25 07:39:52 +01:00
CosmicClash Training Bot 407a916b40 chore(training): curriculum progress after curric-s6-unmask 2026-07-24 02:25:37 +01:00
CosmicClash Training Bot f4dfc43d04 chore(training): Add curric-s6-unmask checkpoints, logs, and exported policy 2026-07-24 02:23:34 +01:00
Josh Creek 1afdc301ab feat(training): add airborne_penalty and a stage-6 "unmask" curriculum run
Stage 5 (aggression) passed (41-47 vs grounded curric-s2-defend, within
the lenient gate but not yet a clear win). Rather than keep the locomotion
mask on indefinitely, stage 6 reopens full 3D controls on top of the
aggression retune and pairs it with a new dense airborne_penalty (scaled
by height above the floor) so the policy learns to prefer staying grounded
through incentives instead of a hard mask — same regime shift that
regressed stage 3, but this time with a mitigation and ~12x the training
time (~240M timesteps / ~24h vs ~20M / ~2h) to actually re-converge
instead of stalling mid-shift.

airborne_penalty follows the existing SHIP_AI_OVERRIDES pattern: default
0 (off) on ship_ai_controller.gd, exposed via train.py's new
--airborne-penalty flag, added to training_mode.gd's allow-list. Also adds
a per-stage timesteps override in curriculum.py (STAGES[n]["timesteps"])
since this is the first stage to need a different budget than the rest.
2026-07-22 21:22:27 +01:00
CosmicClash Training Bot 2de3085f13 chore(training): curriculum progress after curric-s5-aggression 2026-07-22 20:33:07 +01:00
CosmicClash Training Bot fda784d50d chore(training): Add curric-s5-aggression checkpoints, logs, and exported policy 2026-07-22 20:31:54 +01:00
Josh Creek fca6a46200 fix(training): correct stage-3 eval (locomotion-mask bugfix) and add grounded aggression stage
Re-ran stage-3 (curric-s3-no_draws vs curric-s2-defend) and the missing
stage-4 gate now that the locomotion-mask inference bugfix is in. Both
reverse or contradict the pre-fix bookkeeping: curric-s2-defend (grounded)
beats curric-s3-no_draws 60-26 and curric-s4-mechanics 57-24 when fairly
evaluated, so lifting the locomotion mask in stage 3 was a real regression
in floor play, not the improvement the buggy eval reported.

Adds a stage-5 "aggression" curriculum entry that resumes from stage 2
directly (via new resume_from_experiment/reference_experiment stage-dict
overrides in curriculum.py) instead of compounding the regression through
stages 3-4, keeps the locomotion mask on, and retunes ball-pursuit reward
weights for much more aggressive floor play. Extends train.py with the
three new --velocity-to-ball-weight/--ball-distance-penalty/--ball-touch-reward
flags needed to forward that retune to Godot's existing SHIP_AI_OVERRIDES.

curriculum_state.json and TRAINING.md are corrected/annotated in place
rather than silently rewritten, so the regression stays visible in history.
2026-07-22 12:48:45 +01:00
CosmicClash Training Bot cf4859e61c chore(training): Add curric-s4-mechanics checkpoints, logs, and exported policy 2026-07-22 11:53:29 +01:00
Josh Creek 8c15c466ef fix(*): apply the locomotion mask during in-game/eval inference, not just training
AIShipController (eval + real gameplay) ran the raw policy output unmasked
regardless of allow_vertical/allow_pitch_roll, while ShipAIController
(training) correctly discarded those axes for grounded curriculum stages.
A grounded-trained model's untrained vertical/pitch-roll output reached the
ship as noise during eval, understating it against models that were never
handicapped this way.
2026-07-21 22:23:09 +01:00
CosmicClash Training Bot dd2b3c570b chore(training): curriculum progress after curric-s3-no_draws 2026-07-21 21:46:34 +01:00
CosmicClash Training Bot bc644e0305 chore(training): Add curric-s3-no_draws checkpoints, logs, and exported policy 2026-07-21 21:44:51 +01:00
CosmicClash Training Bot 44b1384a97 chore(training): curriculum progress after curric-s2-defend 2026-07-21 19:19:44 +01:00
CosmicClash Training Bot ffa9017cbd chore(training): Add curric-s2-defend checkpoints, logs, and exported policy 2026-07-21 19:17:32 +01:00
CosmicClash Training Bot 7e67998a23 chore(training): curriculum progress after curric-s1-score 2026-07-21 16:52:20 +01:00
CosmicClash Training Bot 523a26aa60 chore(training): Add curric-s1-score checkpoints, logs, and exported policy 2026-07-21 16:50:08 +01:00
Josh Creek 8e3fafcc8b feat(*): add staged curriculum training with an automated stage-by-stage orchestrator 2026-07-21 12:38:51 +01:00