Skip to content
Conway's Game of Life powered by WebAssembly.
Rust JavaScript HTML Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benches
pkg
src
tests
www
.cargo-ok
.gitignore
Cargo.toml
README.md
convida-alt.png
convida.png
convida.xcf
cross-compile.sh
perf.data
screenshot.png

README.md

Convida

An implementation of Conway's Game of Life based on this tutorial.

Quick Start

To start the server, enter:

git clone https://github.com/lbeckman314/convida
cd convida/www
npm install
npm run start

Screenshot of Convida

Development

Dependencies

wasm-pack

rust

Then, within the convida directory, enter:

wasm-pack build

to build the Rust code in src/lib.rs to the pkg directory.

Source Descriptions

File/Directory Description
Cargo.lock dependencies.
Cargo.toml dependencies.
README.md this README file.
benches used in optimizing runtime.
convida-alt.png alternative logo image.
convida.png logo image.
convida.xcf GIMP logo file.
cross-compile.sh beta cross compiling script.
perf.data used in optimizing runtime.
pkg destination directory for compiled rust code.
screenshot.png screenshot image.
src main source files.
target Rust's target directory.
tests used in testing ticks and created cell patterns.
www directory for web client.

Alternatives

Improvements on the Tutorial

  • Introduce an <input type="range"> widget to control how many ticks occur per animation frame.
  • Add a button that resets the universe to a random initial state when clicked. Another button that resets the universe to all dead cells.
  • On Ctrl + Click, insert a glider centered on the target cell. On Shift + Click, insert a pulsar.
  • At this point, the next lowest hanging fruit for speeding up Universe::tick is removing the allocation and free. Implement double buffering of cells, where the Universe maintains two vectors, never frees either of them, and never allocates new buffers in tick.

TODO

  • Implement the alternative, delta-based design from the "Implementing Life" chapter, where the Rust code returns a list of cells that changed states to JavaScript. Does this make rendering to <canvas> faster? Can you implement this design without allocating a new list of deltas on every tick?
  • As our profiling has shown us, 2D <canvas> rendering is not particularly fast. Replace the 2D canvas renderer with a WebGL renderer. How much faster is the WebGL version? How large can you make the universe before WebGL rendering is a bottleneck?
  • We only ever instantiate a single Universe, so rather than providing a constructor, we can export operations that manipulate a single static mut global instance. If this global instance also uses the double buffering technique discussed in earlier chapters, we can make those buffers also be static mut globals. This removes all dynamic allocation from our Game of Life implementation, and we can make it a #![no_std] crate that doesn't include an allocator. How much size was removed from the .wasm by completely removing the allocator dependency?
You can’t perform that action at this time.