Examples:
Natural systems: climate, ecosystems, cells
Engineered systems: power grids, transportation networks, software systems
Social systems: cities, economies, online platforms
Wolfram described his work in detail in his book A New Kind of Science (2002).
Probably the most famous cellular automaton was invented by John Conway and is called the Game of Life.
Conway was a Professor Emeritus of Mathematics at Princeton University in New Jersey.
Conway's automaton consists of cells that are laid out on a two-dimensional grid.
Rules
A live cell that has fewer than 2 live neighbors dies from loneliness.
A live cell that has more than 3 live neighbors dies from overcrowding.
A live cell that has 2 or 3 live neighbors stays alive.
A dead cell that has exactly 3 live neighbors becomes alive.
import os
import random
width = 60
height = 60
screen = []
Step 1: Initialization
def Init():
for i in range(height):
line = []
for j in range(width):
if random.random() > 0.8:
line.append('#')
else:
line.append(' ')
screen.append(line)
Step 2: Show the screen
def PrintScreen():
for i in range(height):
for j in range(width):
print(screen[i][j] + ' ', end='')
print()
Step 3: Get cells
def TryGetCell(i, j):
i = i % height
j = j % width
return screen[i][j]
print(59 % 60) # 59
print(60 % 60) # 0
print(0 % 60) # 0
print(-1 % 60) # 59
Step 4: Count cells nearby
def GetNearbyCellsCount(i, j):
num = 0
for x in [
TryGetCell(i-1, j-1), TryGetCell(i-1, j), TryGetCell(i-1, j+1),
TryGetCell(i, j-1), TryGetCell(i, j+1),
TryGetCell(i+1, j-1), TryGetCell(i+1, j), TryGetCell(i+1, j+1)
]:
if x == '#':
num += 1
return num
Step 5: Update
def Update():
global screen
newScreen = [[' ' for x in range(width)] for y in range(height)]
for i in range(height):
for j in range(width):
count = GetNearbyCellsCount(i, j)
if count == 3:
newScreen[i][j] = '#'
elif count == 2:
newScreen[i][j] = screen[i][j]
else:
newScreen[i][j] = ' '
screen = newScreen
Step 6: Console (for win). For mac, replace "cls" by "clear".
def Start():
os.system("cls")
print('== Game of Life ==')
input('Press Enter to start...')
Init()
while True:
os.system("cls")
PrintScreen()
c = input()
if c == 'q':
break
Update()
print('End')
When the Game of Life begins, it often looks chaotic, with live cells quickly spreading and changing. After a while, it usually settles into a stable pattern or forms small groups that flip back and forth. Early researchers wondered: "Is there a starting pattern that keeps growing forever?"
Glider
Glider gun