cyks.in

Celeste RL

Five policies competing across 12 rooms alongside a 730K RSSM world model.

Run the recovery policy Diffusion rollout lab
LEVEL
DRAW
~/interactive/celeste-rl reinforcement learning / 002

Loading Celeste…

X-RAY Click a climber to inspect its policy probabilities and remaining dash stock.
◎ DREAMER WORLD MODEL ↗ open
RSSM 730K · click to dream
Transition table · 0 tiles · 0 ghosts
FROZEN TABLES
CLEAR RATE: —
PRETRAINED DEPLOY Five tabular policies are running — drag on the cliff to draw walls/coins/spikes for live adaptation, click ↺ Train from Scratch, or hit ▸ Play Yourself!
REWARD
~/diagnostics/world-model

Why x̂_t softens bricks, why 100 m – 500 m stay crisp while higher rooms snap back, and how the 730K RSSM compares to Shortcut Diffusion.

Diffusion Lab ↗ Drift Writeup ↗
1. Five-Frame Warmup Fixes Cold Start 23.3 → 4.3 px jump
1f cold (h₀=0) 46.9% code match No (vx,vy) → chasm smear +5 jump 23.3 px · 0/8 @+15 5f ctx (x₋₄..x₀) warms GRU h₀→h₅ Tracks arc + fixed camera +5 jump 4.3 px · 3/4 lock

Single frames hide whether Madeline is rising or falling. Five unshaken frames prime GRU velocity memory before dreaming open-loop.

2. Overlapping CNN + 16×8 RSSM (1.86 MiB) 89.3% @ +5f · 82.8% forks
64×64×3 stride-2 CNN h_t · 160d GRU motion + timers z_t · 16×8 tokens 48 bits/frame x̂_t (upsample) +15: 70.7% +30: 50.7%

Strided convolutions remove patch seams, and +5/+10/+15 open-loop rollouts teach long-horizon tracking in Float16 JS.

3. Why Dreams Soften Edges: Bottleneck vs. Pixel Loss 0.00416 codec MAE
RSSM v2 (discrete z_t) 48 bits/frame + MSE → soft bricks & edges ✓ +15 lock: 70.7% dev ✓ 1.86 MiB pure JS Shortcut Diffusion+DF Continuous 8×8×8 CNN → 99.21% sprite codec • +15 lock: 23.2% dev • 7.54 MiB ONNX WASM

Compressing 12,288 channels into 48 discrete bits softens high-frequency edges under MSE, while buying superior 15–30f control lock.

4. Room Generalization Cliff (Click any bar to load room) In-dist: 24.9–27.7 dB
Rooms 100 m – 500 m reconstruction PSNR vs. real frames; 600 m+ snap to nearest seen layout (e.g. 800 m → 400 m).
Paired Ablation Ladder · Sprite Tracking & Counterfactual Control All arms evaluated on clean unshaken renders (±4 px template detection).

:x CreditAssignment

Temporal Credit Assignment is the foundational challenge of Reinforcement Learning. In supervised learning (Backprop on image labels), a teacher tells the network the exact error after every single forward pass. In a game like Celeste, the reward stays 0 across hundreds of physics frames until Madeline either touches the Summit Flag (+10) or hits spikes (−4.5). RL algorithms must propagate that final outcome backward through time to figure out which earlier jump, wall-kick, or air-dash actually caused the win or crash.

:x RoomFrontierNovelty

room-frontier-novelty-v1 is the potential-based shaped reward used to train the Celeste PPO and DreamerV3 policies: r_t = 10 · max(0, h_t − h_best) + r_novelty + 10 · 1_exit − 0.1 · 1_death − 0.001. Because it pays 10 × Δbest_height only when Madeline beats her own personal-best height in the current episode, jumping up and down in place yields zero extra reward (preventing reward-hacking loops!), while a capped one-time 4×4 cell novelty bonus (+0.05, max 2.0/episode) encourages horizontal traversal before climbing.

:x RewardHacking

Reward Hacking (Goodhart’s Law in RL) happens when an agent discovers a loophole in a poorly designed proxy reward. If you pay +1 every time a climber touches a repeatable coin or steps upward without tracking personal-best frontier height, gradient ascent discovers that bouncing on the coin forever yields more discounted return (1 + γ + γ² + ... = 1/(1−γ) = 25 at γ=0.96) than climbing to the +10 Summit Flag once!

:x SparseReward

A Sparse Reward pays 0 on every intermediate step and only signals at terminal goals (+10 at the Flag). Under sparse rewards, the policy gradient is identically zero until at least one random trajectory stumbles into the Flag — making exploration strategy (entropy in SAC, novelty bonuses, or Dreamer world-model imagination) decisive.

:x MDP

A Markov Decision Process formalizes sequential decision-making as a 5-tuple (S, A, P, R, γ): state space S (satisfying the Markov property P(s_{t+1} | s_t, a_t) = P(s_{t+1} | s_0..s_t, a_0..a_t)), action space A, transition physics P(s'|s,a), reward function R(s,a,s'), and discount factor γ ∈ [0, 1).

:x Bellman

The Bellman Optimality Equation decomposes long-term value recursively into one step of immediate reward plus the discounted value of the best next state: Q*(s,a) = E[ r + γ · max_{a'} Q*(s', a') ]. Every TD backup ripples the Summit Flag’s +10 value one tile further backward down the cliff until a continuous value gradient connects Spawn to Summit.

:x Discount

The Discount Factor γ ∈ [0, 1) controls the effective planning horizon H ≈ 1 / (1 − γ) by weighting a reward k steps in the future by γ^k. At γ = 0.45, a +10 Flag 10 steps away is worth only 10 × 0.45¹⁰ = 0.0034, so climbers greedily take a nearby +2.5 strawberry; at γ = 0.96 (or 0.997 in 30fps neural training runs), the distant Flag dominates.

:x CNN

A Convolutional Neural Network processes raw 64×64×3 RGB pixels (12,288 numbers per frame) through strided 3×3 convolutional filters (Conv2d → LayerNorm → SiLU), extracting translation-equivariant spatial feature maps for rock edges, spike tips, springs, and Madeline’s hair color.

:x POMDP

A Partially Observable MDP occurs when a single observation o_t does not reveal the full underlying physics state s_t. One frozen 64×64 Celeste frame shows Madeline’s position (x, y), but hides her velocity (vx, vy), her 6-frame coyote timer grace, and whether her air-dash djump is spent.

:x GRUMemory

A Gated Recurrent Unit (GRU) is a compact working-memory cell inside a neural network. It uses two tiny gates (reset and update) to decide what past information to erase vs. carry forward in its hidden vector h_t = (1 − z_t) ⊙ h_{t-1} + z_t ⊙ h̃_t. In a fast game like Celeste, blending CNN features and previous actions across frames lets the network track velocity, coyote-jump timing, and whether an air-dash is still charged — turning a single blurry snapshot back into a full Markov state.

:x SGD

Stochastic Gradient Descent updates parameters via θ ← θ − η · g_t. Because RL trajectories change distribution as the policy changes (non-stationarity) and different network layers have wildly different curvature, plain SGD suffers from slow progress on flat plateaus and violent oscillation in steep ravines.

:x Adam

Adam (Adaptive Moment Estimation) tracks an exponential moving average of gradients (momentum m_t) and squared gradients (per-parameter variance v_t), scaling each weight update by m̂_t / (√v̂_t + ε). However, adding L2 regularization inside the gradient (g_t + λθ) causes weights with large historical gradients to receive almost zero weight decay.

:x AdamW

AdamW (Decoupled Weight Decay) separates weight decay from the adaptive gradient step: θ_{t+1} = (1 − ηλ) θ_t − η · m̂_t / (√v̂_t + ε). In Deep RL, AdamW prevents policy logits and recurrent GRU weights from drifting to extreme values on rare upper-mountain states while keeping fast adaptive learning rates.

:x QLearning

Q-Learning (Cyan Swarm) is an off-policy, value-based algorithm with no explicit policy network. It learns an action-value estimate Q(s,a) via Temporal-Difference (TD) backups: Q(s,a) ← Q(s,a) + α [ r + γ max_{a'} Q(s',a') − Q(s,a) ], and derives its policy implicitly by acting greedily (argmax_a Q(s,a)) with ε-random exploration.

:x DoubleDQN

In standard Q-learning / DQN, using the same noisy network both to select and evaluate max_{a'} Q(s',a') creates a systematic positive maximization bias (E[max(X₁, X₂)] > max(E[X₁], E[X₂])). Double Q-Learning / Double DQN maintains two value estimators (Q_A, Q_B): one selects the greedy action a* = argmax_{a'} Q_A(s', a'), and the other evaluates its value Q_B(s', a*), eliminating overestimation.

:x Rainbow

Rainbow DQN unifies six orthogonal improvements to value-based Deep RL: (1) Double DQN to cure overestimation, (2) Prioritized Experience Replay (PER) sampling high-TD-error transitions, (3) Dueling architecture Q(s,a) = V(s) + A(s,a) − mean A, (4) Multi-step n-step bootstrapping, (5) Distributional RL (C51) predicting the full return histogram instead of just the mean, and (6) NoisyNets for learned parametric exploration.

:x ActorCritic

Actor–Critic architectures combine policy-based and value-based RL: the Actor π_θ(a|s) outputs a stochastic probability distribution over actions, while the Critic V_ϕ(s) estimates the expected return from state s. Subtracting the Critic’s baseline gives the Advantage A_t = Q(s_t, a_t) − V(s_t) — measuring how much better action a_t performed than the climber’s average expectation at s_t.

:x PPOClip

PPO-Clip compares the current probability of a sampled action with its probability when that action was taken. With ratio ρ = π(a|s) / π_old(a|s) and advantage A, its objective is min(ρ A, clip(ρ, 0.8, 1.2) A). A sample with positive advantage stops rewarding increases above 1.2. A sample with negative advantage stops rewarding decreases below 0.8.

:x GRPO

Group Relative Policy Optimization estimates advantage by comparing returns across a group of trajectories. The arena groups the next four completed episodes and assigns A_i = (R_i − mean(R)) / (std(R) + ε) to each action in episode i. The gold line shows the group’s mean best height. Advantages use episode returns.

:x SAC

Soft Actor-Critic considers both reward and policy entropy. The pink climbers illustrate the same maximum-entropy principle with tabular soft Q-learning. The soft Bellman backup uses V(s) = α log Σ_a exp(Q(s,a)/α), and the policy samples from π(a|s) ∝ exp(Q(s,a)/α). Higher temperature α gives lower-valued moves more probability.

:x Entropy

Shannon Policy Entropy H(π(·|s)) = −Σ_a π(a|s) log π(a|s) measures the randomness or multi-modality of an agent’s action distribution. High entropy means the climber actively explores multiple ledges; near-zero entropy means the policy is deterministic and brittle to terrain changes.

:x WorldModel

A World model learns an internal simulator of the game so it can dream future outcomes before acting. In our browser 730K-parameter RSSM: x_t is the real 64×64×3 RGB game image; h_t is the 160-float GRU working memory tracking velocity (vx, vy) and dash timing; z_t is a 16×8 discrete categorical bottleneck summarizing what is on screen right now; and x̂_t (plus predicted reward r̂_t and alive flag ĉ_t) is the imagined frame decoded purely from (h_t, z_t).

:x OpenLoopDrift

Open-Loop Drift & Model Staleness is the fundamental failure mode of World Models: when rolling out multiple steps in imagination without observing real frames (or right after the real environment changes, such as when you draw a new wall), transition errors compound and imagined ghosts hallucinate paths straight through solid obstacles until real interaction recalibrates P(s'|s,a).

:x Interference

Multi-Room Gradient Interference occurs when one neural policy trains simultaneously on rooms with conflicting visual layouts or reward scales: frequent gradients from easier rooms overwrite features needed for harder rooms (e.g., 200m reaches 49/50 while 500m collapses to 0/50), motivating specialist-to-student policy distillation and Prioritized Level Replay (PLR).

:x ForwardPass

The Forward Pass pushes one 64×64×3 RGB screen forward through CNN filters, nonlinear activations (ReLU/SiLU), and GRU recurrent memory to output two predictions at once: the Actor’s action probabilities π(a|s) (via Softmax) and the Critic’s expected future score V(s).

:x ActivationFn

An Activation Function bends the output of each neural layer so stacked layers do not collapse into one giant linear matrix (W₂(W₁x) = (W₂W₁)x). In Deep RL, ReLU(z)=max(0,z) is fast but can suffer “dying neurons” when pushed below zero; modern residual RL networks (such as IMPALA-ResNet and DreamerV3) use smooth SiLU(z) = z · σ(z), while GRUs use Sigmoid (0..1 memory gates) and Tanh (−1..+1 bounded state).

:x SiLU

SiLU (Sigmoid Linear Unit, also called Swish) is a smooth nonlinear activation function defined as f(z) = z · σ(z), where σ(z) = 1 / (1 + e^{-z}). For positive inputs it grows linearly like ReLU, but near and slightly below zero it bends smoothly instead of hitting a hard zero wall — so neurons don’t permanently “die” with zero gradient during RL updates.

:x Backprop

Backpropagation computes how much every weight contributed to the scalar loss L by pushing derivatives backwards via the calculus chain rule, output → input. See BPTT for how Backprop flows backwards across multiple video frames through a GRU.

:x BPTT

Backpropagation Through Time (BPTT) is ordinary backpropagation applied to a sequence of frames connected by a recurrent layer like a GRU. By unrolling across a window (for example, 64 consecutive frames), gradient signals from a late +10 exit or −0.1 spike crash flow backwards in time to credit the exact earlier jump or wall-kick that caused it.

:x GradClip

Global Gradient Norm Clipping (clip_grad_norm_(params, 0.5)) rescales the entire gradient vector down to length 0.5 whenever a rare surprise reward causes a huge gradient spike — preserving the update direction without launching the weights to infinity. (Note: this is different from PPO Clipping, which flattens the sample objective on one side of the probability-ratio interval.)

:x AdaptiveMomentum

Adaptive Momentum combines two optimizer ideas: momentum smooths noisy gradients across batches into a moving average m_t (like a heavy ball rolling downhill), while adaptive scaling tracks how volatile each individual weight’s squared gradient v_t is and divides by √v̂_t + ε — automatically taking smaller steps on jittery weights and larger steps on steady ones.

:x WeightDecay

Weight Decay acts like gentle gravity pulling weights slightly toward zero on every step so parameters don’t grow huge, saturate activations, and lose flexibility in long RL runs. In AdamW, decay is decoupled — applied directly as (1 − ηλ)θ_t outside the adaptive 1/√v̂_t divisor so noisy and quiet weights shrink at the same steady rate.

:x LayerNorm

Layer Normalization (LayerNorm) rescales the activations inside a hidden layer to have mean 0 and unit variance across features for each frame independently. In RL, because the distribution of visited screens keeps shifting as an agent reaches higher ledges, LayerNorm stabilizes feature magnitudes without relying on batch-wide running averages.

:x ResBlock

A Residual Block (ResBlock) computes output = x + F(x), adding a direct skip connection around two convolution layers. During backprop, that identity highway lets gradients flow cleanly back to early pixel layers without vanishing, allowing deeper visual RL encoders (like IMPALA-ResNet) to extract sharper level geometry.