CSS is running a neural network to play Flappy Bird. Yes, actual CSS.
retained text
I built a Flappy Bird clone where the neural network inference **runs entirely in CSS**. Open source: [https://github.com/veuler/flappynn](https://github.com/veuler/flappynn) No TensorFlow.js. No WebGPU. No hidden JavaScript inference. JavaScript runs the game and passes the current state to CSS. The network itself uses CSS calc(), max() and exp() for the weighted sums, ReLU activations and final sigmoid output. I got ChatGPT help for Javascript code part while I've created the main idea. Also the flappy bird part has been created with the help of ChatGPT. A neuron is literally exported into CSS roughly like this: --h1-z: calc( var(--bird-y) \* 0.72 + var(--velocity-y) \* -0.31 + var(--pipe-distance) \* 0.18 + var(--gap-y) \* 0.44 + var(--pipe-speed) \* 0.27 + 0.14 ); --h1: max(0, var(--h1-z)); --jump-probability: calc(1 / (1 + exp(-1 \* var(--output-z)))); The latest actor is a **6 → 16 → 1 MLP** with **129 trainable parameters**. It sees: bird position + vertical velocity + next pipe distance + next gap position + pipe speed + **the following pipe's gap position** → 16 hidden neurons → **JUMP / WAIT** That sixth input is a small but interesting change: the network can now see **two gaps ahead**, instead of reacting only to the pipe directly in front of it. Inference runs at **20 Hz — 20 complete neural-network decisions every second**. The new model performs 112 learned-weight multiplications per forward pass, or about **2,240 weight multiplications/sec through CSS math**. Training is done with **PPO reinforcement learning**. I now run up to **512 parallel game environments** on the CPU. They all generate experience for the same actor/critic pair; only the trained actor is eventually exported to CSS. One recent **5-minute / 512-environment** training run processed: * **7,939,072 environment transitions** * **3,373 completed episodes** * **121 PPO updates** * **104.82 average score over the final 100 episodes** * **462 best episode in that run** And the new 6-input network has now produced a **best observed score of 514**. Interestingly, I've reached that while spending less time training this architecture than I had spent on the previous 5-input version. The episode cap has also been increased from 300 to **600 simulated seconds**, so longer surviving policies can actually keep flying instead of being cut off early. After training, PyTorch, the critic and the optimizer are no longer involved in gameplay. The actor weights are exported into CSS and CSS makes every JUMP / WAIT decision. To verify that this isn't just a visualization, I compare the real browser CSS model against Python across **4,680 input states**. Latest result: **zero decision mismatches**, with maximum probability error around `1.1e-16`. So yes — the “brain” controlling the bird in the video is actually running in CSS.
document fetched 2026-10-10 00:20 · canonical https://reddit.com/r/ChatGPT/comments/1x1roxe/css_is_running_a_neural_network_to_play_flappy