There should exist small initial patterns with chaotic, unpredictable outcomes.Conway looked to simplify Von Neumann's mathematical models to four rules that the Game of the Life should maintain. John Von Neumann, of creating universal constructors that could build copies of itself. It was influenced by an idea proposed by the mathematician, Mathematician John Horton Conway in 1970. You can see the whole module file with tests on GitHub.Glider - the simplest, but the most important pattern in Game of Life Ĭonway's Game of Life, also known more simply as Life, was a computer simulation created by the British A single cell can be a tuple ])enddefp neighbours(, neighbours), do: neighboursīasically, these are all rules implemented in the single module GameOfLife.Cell. We need to represent the alive cells on the board in our game. # lib/game_of_life.exdefmodule GameOfLife do use Application # See # for more information on OTP Applications def start(_type, _args) do import Supervisor.Spec, warn: false children = ), ] # See # for other strategies and supported options opts = Supervisor.start_link(children, opts) endend Represent the board in Game of Life In lib/game_of_life.ex file you will find an example of how to add child worker to supervisor. Normally an app is generated without a supervisor and without the app callback. $ mix new -sup game_of_lifeĪ -sup option is given to generate an OTP application skeleton including a supervision tree. We will use supervisor for our game server, you will learn more about it a bit later. Create new application in Elixirįirst things first, so we are going to create a new Elixir OTP application with supervision tree. The rules continue to be applied repeatedly to create further generations. The first generation is created by applying the above rules simultaneously to every cell in the seed - births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The initial pattern constitutes the seed of the system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |