Show HN: Teaching a Dinosaur to Jump: Rust, WebAssembly, and Neural Evolution
a year ago
- #WebAssembly
- #Neuroevolution
- #Rust
- The project started as a simple clone of the Chrome Dino game using Rust and WebAssembly but evolved into a complex simulation involving neuroevolution, physics, and AI.
- Rust was used for its performance and memory safety, while WebAssembly enabled high-speed execution in the browser.
- The dinosaur's behavior was controlled by a neural network with inputs like obstacle distance and speed, and an output for jumping.
- An evolutionary algorithm was implemented to improve the neural network's performance over generations through mutation and selection.
- Visual debugging tools were added to monitor the neural network's decision-making, including fitness graphs and weight heatmaps.
- The neural network architecture was expanded to include a hidden layer, improving adaptability and decision-making.
- The simulation was scaled to run thousands of agents in parallel, with optimizations to maintain performance.
- The project was deployed as a static site on GitHub Pages, making it accessible for education and experimentation.
- Key lessons included the importance of real-time visualization, the power of evolutionary strategies, and the efficiency of Rust + WebAssembly.
- Future work could explore more complex actions, alternative activation functions, and user tools for inspecting neural networks.