Skip to content

Latest commit

 

History

History
49 lines (35 loc) · 1.33 KB

README.md

File metadata and controls

49 lines (35 loc) · 1.33 KB

Conway's Game of Life

Conway's Game of Life is a well-known 2D Cellular Automaton.

It can be defined with the Netomaton framework:

import netomaton as ntm

adjacency_matrix = ntm.topology.adjacency.cellular_automaton2d(rows=60, cols=60, r=1, neighbourhood='Moore')

initial_conditions = ntm.init_simple2d(60, 60)

# Light Weight Space Ship (LWSS)
initial_conditions[1125] = 1
initial_conditions[1128] = 1
initial_conditions[1184] = 1
initial_conditions[1244] = 1
initial_conditions[1248] = 1
initial_conditions[1304] = 1
initial_conditions[1305] = 1
initial_conditions[1306] = 1
initial_conditions[1307] = 1

# Glider
initial_conditions[1710] = 1
initial_conditions[1771] = 1
initial_conditions[1829] = 1
initial_conditions[1830] = 1
initial_conditions[1831] = 1

# Blinker
initial_conditions[2415] = 1
initial_conditions[2416] = 1
initial_conditions[2417] = 1

trajectory = ntm.evolve(initial_conditions=initial_conditions, network=network, timesteps=60,
                        activity_rule=ntm.rules.game_of_life_rule)

ntm.animate_activities(trajectory, shape=(60, 60))

The full source code for this example can be found here.

For more information about Conway's Game of Life, see:

Conway, J. (1970). The game of life. Scientific American, 223(4), 4.