WASM Game of Life
May 2024 - Jun 2024
Conway's game of life made in Rust using Web Assembly.
Project Details
A performant, multithreaded implementation of Conway’s Game of Life using Rust and WebAssembly. This interactive cellular automaton runs directly in the browser, leveraging Rust’s memory safety and WebAssembly's execution speed to deliver a responsive simulation rendered in HTML/JavaScript.
This project simulates Conway's Game of Life with a focus on performance, modularity, and WebAssembly integration. Written in Rust and compiled to WebAssembly, it offers a fast and memory-safe runtime with multithreaded simulation logic. Useful as an educational tool, playground for WebAssembly + Rust experiments, or foundation for more complex simulations.
-
The universe is stored as a 1D Vec
| with calculated 2D indexing | - Cells are either Alive or Dead (enum)
- Grid dimensions are defined by width and height
- On each tick, the simulation calculates the number of living neighbors
- Rules follow Conway’s original logic:
- Any live cell with 2–3 live neighbors survives
- Dead cells with exactly 3 live neighbors become alive
- The universe is divided into horizontal slices
- Each slice is processed in a separate thread using std::thread
- Slices are merged at the end to form the next universe state
- A Timer struct wraps execution steps
- Execution time is logged via web_sys::console::time() and .time_end()
🧱 Grid Model
🚦 State Transitions
🧵 Multithreaded Updates
⏱️ Performance Logging
Project Features
- 🕸️ WebAssembly Integration: Compiles to .wasm for browser execution
- ♻️ Multithreaded Update Logic: Uses native Rust threads to parallelize universe state updates
- ◼️ ASCII Output for Debugging: Simple visual feedback of simulation state
- 🧮 Cell Toggle Logic: Click to activate/deactivate individual cells (JS-side integration)
- ⏱️ Performance Profiling: Custom Timer struct logs execution times to the browser console
- 💻 Cross-Platform: Runs on any browser with WebAssembly support
Project User Workflow
- Launch the web application
- Watch Conway’s Game of Life evolve with real-time updates
- Click cells to toggle state
- Pause game state to stop game
- Modify update rules or grid size via Rust and recompile
Technologies Used
- 🦀 Rust --- Systems-level language for performance and safety
- 🕸️ WebAssembly --- Target for compiling Rust to run in browsers
- 🔁 wasm-bindgen --- Bindings between JS and Rust/WASM
- 🎲 std::thread --- For multithreading the simulation logic
- 🖨️ web_sys --- Access browser console logging
- 🧪 wasm-pack --- Build, test, and package WASM crate
Project Images
Below are some additional images showcasing the project.
◻◻◻◻◻◻◻◻◻◻
◻◻◻◼◼◼◻◻◻◻
◻◻◻◼◻◼◻◻◻◻
◻◻◻◼◼◼◻◻◻◻
◻◻◻◻◻◻◻◻◻◻
Description of this image or feature.
Explanation about this feature.
More details about the project component.