Giter Site home page Giter Site logo

game-of-life-elixir's Introduction

Game of Life the Erlang way

Conway's Game of Life implemented using Elixir processes as cells. There is no "central point" which controls game. Each cell progress on it's own and communicates with other to determine it's next state (live or dead).

Run with iex:

iex -S mix
# there are 2 predefined examples in .iex.exs: glider and gosper
GameOfLife.start(glider)
# or
GameOfLife.start(%GameOfLife.Board{width: 10, height: 10, live: [
  {5, 4}, {5, 5}, {5, 6} # specify cells that are alive on start
]})

How cells are kept in sync?

There are 2 mechanism to allow asynchronous progress of cells.

  • Each cell doesn't hold it's current state but history of states from the beginning. Cell can obtain other cell state at any point.

  • When cell gets a message for it's state in the future, the request is saved. When cell progress, it replies to previously stored requests.

What if cell dies?

  • GameOfLife.Timer holds estimate of current game time. When cell is created checks time and if needed, forwards it's evolution to match other cells.

game-of-life-elixir's People

Contributors

alukasz avatar

Stargazers

Dawid avatar

Watchers

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