Game of Life


This model was created as a response to a Forum article posted by pierre. See the original article, From Previous Forum: Game of Life using goldsim?

Description

The Game of Life is a board game where cells are either dead or alive and rules are defined to cause cells to change state. It is provided as demonstration of using the new script element for matrix manipulations.

The user supplies a probability that initial cells are live. A looping container is used to sample boolean vectors with that probability of being true. A script element inside the looping container is used to assemble the random vectors into a matrix which is the initial state of the board.

The Board script element simulates the game. At ETime of 0 days it takes on the value of the initial matrix from the looping container (which is also a conditional container). Thereafter, cells become live or dead based on the following rules:

  1. Any live cell (value of 1) with fewer than two live neighbours dies,
  2. Any live cell with more than three live neighbours dies,
  3. Any live cell with two or three live neighbours lives on to the next generation,
  4. Any dead cell (value of 0) with exactly three live neighbours becomes a live cell.

The Board script element assigns to the variable Result, which is a built in variable that causes assignment to the main output of the script element. It uses DO loops and if statements to count the number of living cells in each cell's 8 neighbors. There is no special treatment for border cells. A spreadsheet element exports the board's state to a spreadsheet on every change of day in the simulation. A daily time step should be used for this to be accurate. The progression of the board can be viewed in a dashboard with the run controller set to simulate slowly.

Download the model file


See Also

 

Making Better Decisions In An Uncertain World

RSS RSS

Navigation (Model Library)






Search the wiki
»

PoweredBy