Concepts

There are three main components for an artificial life simulation:

  • The Board or the environment in which the lifeforms will move around

  • The Lifeform that will interact with the environment, and

  • The rules that dictate if a particular cell will survive or not

In the classic Conway’s Game of Life, there are four rules (taken from @jakevdp’s blog post):

  • Overpopulation: if a living cell is surrounded by more than three living cells, it dies

  • Stasis: if a living cell is surrounded by two or three living cells, it survives

  • Underpopulation: if a living cell is surrounded by fewer than two living cells, it dies

  • Reproduction: if a dead cell is surrounded by exactly three cells, it becomes a live cell

In Seagull, you simply define your Board, add your Lifeform/s, and run the Simulator given a rule. You can add multiple lifeforms as you want:

import seagull as sg
from seagull import lifeforms as lf

board = sg.Board(size=(30,30))
board.add(lf.Blinker(length=3), loc=(4,4))
board.add(lf.Glider(), loc=(10,4))
board.add(lf.Glider(), loc=(15,4))
board.add(lf.Pulsar(), loc=(5,12))
board.view()  # View the current state of the board

Then you can simply run the simulation, and animate it when needed:

sim = sg.Simulator(board)
stats = sim.run(sg.rules.conway_classic, iters=1000)
sim.animate()

Adding custom lifeforms

You can manually create your lifeforms by using the Custom class:

import seagull as sg
from seagull.lifeforms import Custom

board = sg.Board(size=(30,30))
board.add(Custom([[0,1,1,0], [0,0,1,1]]), loc=(0,0))

Obtaining simulation statistics and history

By default, the simulation statistics will always be returned after calling the run() method. In addition, you can also obtain the history by calling the get_history() method.

# The run() command returns the run statistics
stats = sim.run(sg.rules.conway_classic, iters=1000)
# You can also get it using get_history()
hist = sim.get_history()