Pong AI trains a Pong player in your browser. Its controller is a multilayer perceptron (MLP), a small neural network that evolves over repeated games.
The debug overlay above each paddle shows the 21 neurons in its network.
Press N to hide the debug overlay.
Press P to cycle between three control modes: AI vs AI, AI vs human,
and human vs human.
Control the left paddle with the W and S keys.
Control the right paddle with the ↑ and ↓ arrow keys.
See if you can beat your trained AI!
The code is available on GitHub.
The original version was a C++ genetic algorithm with a neural network that learned Pong, and it was largely the work of a former university peer. He brought a competitive programmer's rigour, and at the time I couldn't fully follow it.
Rebuilding it in Rust has been my way of finally understanding it, and of learning more about compilation and systems design along the way. It relies on ordinary compiler optimisation, including automatic vectorisation where the compiler finds suitable loops.
This rebuild is an early step in my roadmap to catch up with the field, working from classical neural networks towards transformers. I'll share further work on over|yonder.