Pong AI trains an artificial-intelligence (AI) player in the browser. Its controller is a multilayer perceptron (MLP), a small neural network evolved through repeated games of Pong.
The debug information above each agent shows the 21 neurons that make up its "brain".
Press N to hide the debug information.
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 the AI you trained!
The code is available on GitHub.
This project revisits a formative collaboration with a former peer whose early contributions shaped its trajectory. The original implementation—a C++ genetic algorithm with a neural network to learn Pong—was largely his work. At the time, I lacked the technical depth to fully grasp it. He brought competitive programming rigor and algorithmic fluency that exceeded my understanding then.
Rebuilding it now in Rust serves a dual purpose: technical redemption and continued learning. The implementation uses ordinary compiler optimization, including automatic vectorization where the compiler finds suitable loops. More importantly, it’s been an exercise in understanding compilation, lowering and systems-level design—concepts I hadn’t appreciated during the original effort.
The broader arc is about catching up with the field. Back in 2015, transformers didn’t exist in the mainstream curriculum. Reconstructing this project from first principles is a way to retrace the path from classical neural networks to the architectures that define modern AI—following the breadcrumbs, step by step.