Dev runs a neural network entirely in CSS to play Flappy Bird — 20 inferences per second

JumpAppropriate714 · reddit · 2026-10-10

A developer open-sourced flappynn: a Flappy Bird clone whose "brain" is a neural network running entirely in CSS — no TensorFlow.js, no WebGPU, no hidden JS inference.

How it works: JavaScript only runs the game and feeds in state; the network itself uses CSS calc(), max() and exp() for weighted sums, ReLU activations and a sigmoid output. The latest actor is a 6→16→1 MLP (129 trainable parameters) whose inputs include bird position, velocity, pipe distance, gap position, pipe speed, and the next pipe's gap position — letting it see two pipes ahead.

Training & verification: trained with PPO across up to 512 parallel CPU environments; one 5-minute run processed 7.9M transitions over 121 PPO updates, reaching a 104.82 average score and a best episode of 514. After training, actor weights are exported to CSS and inference runs at 20 Hz (2,240 weight multiplications/sec). Comparing the browser CSS model against Python across 4,680 input states yielded zero decision mismatches with max probability error around 1.1e-16.

Original post →

More from coding & agent

coding & agent channel →