This is a demo of an AI that learns to play Pong using a multi-layer perceptron (MLP) evolved via an evolutionary algorithm.
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 performance gains from rustc and LLVM's modern optimization pipeline—including SIMD auto-vectorization—have made the reimplementation orders of magnitude faster. 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.