Skip to content
🎲 Interactive Conway's Game of Life simulation written in Haxe
Haxe HTML CSS
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.
bin
screenshots
src More Websocket code, looks like it's working now Jan 11, 2020
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md

README.md

Project logo

Build Status License

Conway's Game of Life written using Haxe and WebGL. Run it in your browser.

Features

  • Select from thousands of Game of Life patterns, add them to the simulation with one click.
  • Speed up, slow down, frame-step, pause and clear the game world.
  • Browse, preview and pick the patterns to add interactively.

Usage

Run the demo, and press anywhere on the Game of Life canvas to add a pattern to the simulation. Here it is in action:

Animated Game of Life screenshot 1

Animated Game of Life screenshot 2

Select from thousands of different Life patterns via the selection dropdown or the pattern previews section:

Game of Life pattern selection area screenshot

Resize the browser window to change the simulation size. The canvas scales by powers of two (1024x512, 1024x1024 etc):

Game of Life on large canvas screenshot

How It Works

The Game of Life is a cellular automaton invented by John Conway in 1970. It is a simulation that takes place on a two-dimensional orthogonal grid of square cells, each of which can either be dead or alive.

Each time the simulation is updated, every cell in the grid interacts with its eight neighboring cells in accordance with these four rules:

  • Any live cell with fewer than two living neighbours dies (isolation).
  • Any cell with two or three living neighbours survives this time (survival).
  • Any cell with more than three living neighbours dies (overpopulation).
  • Any dead cell with three living neighbours comes to life (reproduction).

Conway designed these rules to produce interesting results - even self replicating patterns can be produced. Read more here.

In this implementation, the Game of Life rules are applied via a GLSL shader that runs on the graphics card. It uses a ping-pong technique with two render targets: one render target contains the current simulation step, and the other receives the results of applying the rules of the game to produce the next simulation step. In other words, we use the output of the last simulation step as input to the next one, alternating between render targets on every step.

Notes

  • The patterns are from the LifeWiki collection. Credit for these goes to the original creators.
  • This project was inspired by Golly, a cross-platform cellular automaton simulator.
  • Images can be sent to the software through a binary-mode WebSocket, enabled by appending "?socket=<your_ip>%3A<your_port>" to the URL. It expects messages in the form: width:int32, height:int32, RGBA8888pixels:array.
  • If you have any questions or suggestions then send Sam a message on Twitter or open an issue.

License

  • The Haxe and webpage code, but not the pattern files, are licensed under the GPL.
  • The noUiSlider settings sliders are WTFPL.
  • The three.js library is MIT.
You can’t perform that action at this time.