Giter Club home page Giter Club logo

game-of-life's Introduction

Project logo

License Build Status Badge

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.

game-of-life's People

Contributors

tw1ddle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.