Game of Life: Cellular Automata

Persistent Identifier

Use this permanent link to cite or share this Morpheus model:

Introduction

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.
Conway´s Game of Life.

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).

Model

Get this model via:

  • Morpheus-Link or
  • Morpheus GUI: ExamplesMiscellaneousGameOfLife.xml or
  •  Download: GameOfLife.xml
  • XML Preview

    <MorpheusModel version="3">
        <Description>Conway's Game of Life
    ---------------------
    
    Classical Cellular Automaton with synchronized updates.
    
    
    Rules:
    - 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
    
    <Title>Example-GameOfLife</Title>
            <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>
        </Description>
        <Global>
            <Constant symbol="s" value="0"/>
        </Global>
        <Space>
            <Lattice class="square">
                <Size symbol="size" value="50 50 0"/>
                <BoundaryConditions>
                    <Condition boundary="x" type="periodic"/>
                    <Condition boundary="y" type="periodic"/>
                </BoundaryConditions>
                <Neighborhood>
                    <Order>2</Order>
                </Neighborhood>
            </Lattice>
            <SpaceSymbol symbol="space"/>
        </Space>
        <Time>
            <StartTime value="0"/>
            <StopTime value="500"/>
            <SaveInterval value="0"/>
            <TimeSymbol symbol="time"/>
        </Time>
        <CellTypes>
            <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)
      )
    )
                        </Expression>
                    </Rule>
                </System>
                <NeighborhoodReporter>
                    <Input scaling="cell" value="s"/>
                    <Output symbol-ref="sum" mapping="sum"/>
                </NeighborhoodReporter>
            </CellType>
        </CellTypes>
        <CellPopulations>
            <Population size="0" type="cell">
                <InitProperty symbol-ref="s">
                    <Expression>if(rand_uni(0,1) > 0.75, 1, 0)</Expression>
                </InitProperty>
                <InitCellLattice/>
            </Population>
        </CellPopulations>
        <Analysis>
            <Gnuplotter time-step="20" decorate="false">
                <Terminal name="png"/>
                <Plot>
                    <Cells value="s">
                        <ColorMap>
                            <Color value="1" color="black"/>
                            <Color value="0.0" color="white"/>
                        </ColorMap>
                    </Cells>
                </Plot>
            </Gnuplotter>
        </Analysis>
    </MorpheusModel>
    
    

    Downloads

    Files associated with this model:

    Next