MrTimmyJ

Main Project Image

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.

Project Detail Image

    🧱 Grid Model

  • 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
  • 🚦 State Transitions

  • 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
  • 🧵 Multithreaded Updates

  • 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
  • ⏱️ Performance Logging

  • A Timer struct wraps execution steps
  • Execution time is logged via web_sys::console::time() and .time_end()

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 Detail Image

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
Project Detail Image

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.

                    ◻◻◻◻◻◻◻◻◻◻
                    ◻◻◻◼◼◼◻◻◻◻
                    ◻◻◻◼◻◼◻◻◻◻
                    ◻◻◻◼◼◼◻◻◻◻
                    ◻◻◻◻◻◻◻◻◻◻
                
Project Image 1

Description of this image or feature.

Project Image 2

Explanation about this feature.

Project Image 3

More details about the project component.