Game of Life: Cellular Automata


This example models probably the best-known classic cellular automaton (CA) model: Conway’s Game of Life. It shows an alternative use of System for synchronous updating of Equations.

Conway’s Game of Life.

Model description

In this model, the lattice is filled with cells of size $1$. Each cell counts the number of neighboring cells that are ‘alive’ and acts accordingly. The rules that make up the Game of Life are implemented in a System of Equations in which all Equations are updated synchronously.

Things to try

  • Change the Neighborhood from a Moore (2nd order) to von Neumann (1st order).


In Morpheus GUI: Examples 🠒 Miscellaneous 🠒 GameOfLife.xml.

<MorpheusModel version="3">
    <Description>Conway's Game of Life

Classical Cellular Automaton with synchronized updates.

- If alive, die when less than 2 live neighbors
- If alive, survive when 2 or 3 live neighbors (no change)
- If alive, die when more than 3 live neighbors
- If dead, become alive when exactly 3 live neighbors

        <Details>Simulates Conway's cellular automata model "Game of Life" by

1. summing the states of neighboring cells with NeighborhoodReporter
2. based on this sum, setting the cell state using a System of (synchronously updated) Rules.</Details>
        <Constant symbol="s" value="0"/>
        <Lattice class="square">
            <Size symbol="size" value="50 50 0"/>
                <Condition boundary="x" type="periodic"/>
                <Condition boundary="y" type="periodic"/>
        <SpaceSymbol symbol="space"/>
        <StartTime value="0"/>
        <StopTime value="500"/>
        <SaveInterval value="0"/>
        <TimeSymbol symbol="time"/>
        <CellType class="biological" name="cell">
            <Property symbol="s" value="0.0" name="State_Living"/>
            <Property symbol="sum" value="0.0" name="Sum_Neighbors"/>
            <System solver="euler" time-step="1.0" name="Rules of life">
                <Rule symbol-ref="s">
                    <Expression>if((s == 1 and sum &lt;  2), 0,
  if((s == 1 and sum >  3), 0,
    if((s == 0 and sum == 3), 1, s)
                <Input scaling="cell" value="s"/>
                <Output symbol-ref="sum" mapping="sum"/>
        <Population size="0" type="cell">
            <InitProperty symbol-ref="s">
                <Expression>if(rand_uni(0,1) > 0.75, 1, 0)</Expression>
        <Gnuplotter time-step="20" decorate="false">
            <Terminal name="png"/>
                <Cells value="s">
                        <Color value="1" color="black"/>
                        <Color value="0.0" color="white"/>