GithubHelp home page GithubHelp logo

m-dimmitt-forks / game-of-life Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simonestefani/game-of-life

0.0 1.0 0.0 159 KB

An Elixir implementation of Conway's Game of Life

Elixir 72.83% JavaScript 11.22% Vue 13.67% CSS 0.11% HTML 2.16%

game-of-life's Introduction

Conway's Game of Life

A concurrent implementation in Elixir

1. Introduction

The game of life is the best-known two-dimensional cellular automaton, invented by John H. Conway and popularised in Martin Gardner's Scientific American column starting in October 1970.

The life cellular automaton is run by placing a number of filled cells on a two-dimensional grid. Each generation then switches cells on or off depending on the state of the cells that surround them. The rules are defined as follows. All eight of the cells surrounding the current one are checked to see if they are on or not. The cells that are on are counted and this count is then used to determine what will happen to the current cell.

  1. Death: if the count is less than 2 or greater than 3, the current cell is switched off.

  2. Survival: if the count is exactly 2, or the count is exactly 3 and the current cell is on, the current cell is left unchanged.

  3. Birth: if the current cell is off and the count is exactly 3, the current cell is switched on.

(from http://mathworld.wolfram.com/GameofLife.html)

2. The OTP architecture

The following drawing describe the architecture of the Elixir app that contains the game:

Each cell is represented by a GenServer process and they are all controlled by the Cell.Supervisor with a strategy simple_one_for_one which informs the system that cells will be added and removed dynamically. The Universe.Supervisor controls the Universe together with the Cell.Supervisor and the Registry. The Universe describes the overall state of the game and can be ticked in order to advance to the next state. The Registry is a key-value storage structure and provides a comfortable way to link each Cell PID with a key which is its postion in the form {x, y}.

3. The bigger picture

In order to provide a front-end for the game, a Phoenix app interface has been created and added together with the game Elixir app under the game_of_life Elixir umbrella app. This allows the two apps to live independently but at the same time to easily communicate. The communication between the two apps is provided by the Phoenix Channels based on websockets.

The web interface, developed in VueJS, send *tick* messages to the Elixir `game` app which advances the state of the game and responds with the new configuration of the Universe.

game-of-life's People

Contributors

simonestefani avatar dependabot-preview[bot] avatar

Watchers

James Cloos 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.