Skip to content

A simple JS implementation of Conway's Game of Life to help discover the behavior of a few common objects.

License

Notifications You must be signed in to change notification settings

percevalve/game-of-life

Repository files navigation

Game of Life

=====

The aim of the tool is to help discover the different Conway's Game of Live patterns, see some of them in action. Secondly, by allowing changing the rules during the games, we can see how the rules can shape the way "life" can develop itself and what organizatinal form are typical. The idea, is not only to change the rules.

Usability:

Initially the "world" is empty, you need to add patterns (or objects). They are 3 different patterns for the moment:

Rules:

The rules are stored in an array, with the results coded at 0 for death and 1 for life. This way we can think of an extension of the rules to bring some randomness, with life having 60% chance of appearing if a dead cell has 2 neighbors for example...

World :

In order to prevent a border effect, the border of the world communicate, this also enable to have the objects "fly" around the space for a long period of time (like the gliders).

The files :

function.js

It contains the most generic functions used in life.js

cell.js

It is in charge of creating Cells. Each cell has the same prototype "Rules" that contains all the rules and can be modified during the game. There is no need to instantiate any cell object directly. Everytime the cell changes state (during the game of because someone clicked), it calls a "callback" function that inform the GameOfLife object it has changed its status. Once the GameOfLife object receive the message, he makes sure the board is up to date and updates the neighboring cells.

board.js

It is in charge of the representation of the Game. He has no clue on what is going on. The board is clickable.

gameoflife.js

It contains a clojure with an array of cells and control the board. He serves as a relay between the board and the actual cell.

About

A simple JS implementation of Conway's Game of Life to help discover the behavior of a few common objects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •