Skip to content

A Rust and WebAssembly tutorial implementing the Game of Life

Notifications You must be signed in to change notification settings

DavidCanHelp/wasm_game_of_life

 
 

Repository files navigation

Conway's Game of Life in Rust and WebAssembly

This repository contains the complete code for the Rust and WebAssembly tutorial. The tutorial builds increasingly featureful implementations of Conway's Game of Life.

Read the tutorial here.

Repository Structure

This repository has an unusual structure. Each chapter of the tutorial builds upon the last chapter's Game of Life implementation, and extends it. Each chapter's implementation is available in a branch of this repository. This enables us to commit fixes and updates to early chapters, and then cascade them through each later chapter via git merge, rather than manually applying the same change to every branch.

These branches are also available as git submodules within this master branch. The submodules enable browsing all versions at once, and running tests for the latest commits on every branch in Travis CI all at once.

Chapter branches/submodules:

  • chapter-zero: An initial template for this project that contains a Rust and WebAssembly "hello world" ready to go.

  • chapter-one: A working, if minimal, implementation of Conway's Game of Life.

    • chapter-one-with-bug: The same as chapter-one, but with a Real World bug I wrote. Debugging this is intended as an exercise for readers.
  • chapter-two: Added ability to pause and resume the game, as well as toggle individual cells by clicking on them.

  • chapter-three: Speed ups to rendering and computing the next generation of cells.

Cloning the Repository

In order to clone this repository and view the code for each chapter, you will need to initialize and update the submodules. This can be done using the following commands:

# Clone the wasm_game_of_life repository.
git clone git@github.com:rustwasm/wasm_game_of_life.git

# Initialize and fetch the submodules.
git submodule update --init

This can also be performed with a single command using the --recurse-submodules option.

git clone --recurse-submodules git@github.com:rustwasm/wasm_game_of_life.git

Sending Pull Requests

  1. Checkout the branch for the first chapter that needs to be updated. Apply your changes and commit them.

  2. Checkout the branch for the next chapter. Do a git merge $PREVIOUS_CHAPTER.

  3. Repeat step 2 until there is no next chapter.

  4. Checkout the master branch. Run

    ./update-submodules.sh
    

    to point the submodules to the latest commit on each branch. Commit this update.

  5. Send a pull request for each chapter branch that was modified, and for master.

Thanks!

About

A Rust and WebAssembly tutorial implementing the Game of Life

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%