The Simulator takes in a
seagull.Board, and runs a simulation given a
set number of iterations and a rule. For each iteration, the rule is applied to
the Board in order to evolve the lifeforms. After the simulation, run
statistics are returned.
import seagull as sg board = sg.Board() board.add(Blinker(), loc=(0,0)) # Initialize a simulator sim = sg.Simulator(board) stats = sim.run(sg.rules.conway_classic, iters=1000)
You can always get the history of the whole simulation by calling the
get_history() method. The length of the history will always be equal to
iters + 1 since we include the initial state
Running a simulation does not change the
state attribute of the
board. Internally, the simulator makes a copy of that layout and updates
that instead. This is to avoid unintended behaviour when running
simulations again and again.
Various statistics such as entropy, peak cell coverage, and the like are returned as a dictionary. This gives us an idea on the characteristics of the simulation experiment.
Some statistics are highly-dependent on the size of the board and the number of iterations. For example, peak cell coverage (pertaining to the max. amount of active cells during the whole run) depends on board size. If you have better ideas for computing these statistics, please open-up an Issue!
run() method only computes the progress of the board for the whole
simulation, but it does not animate it yet. To create an animation, call the
This returns a
matplotlib.animation.FuncAnimation that you can turn into
an interactive animation in your notebook or exported as a GIF.
When exporting to GIF, it is required to have the ffmpeg backend installed.
Initialize the class
board (seagull.Board) – The board to run the simulation on
animate(figsize=(5, 5), interval=100)¶
Animate the resulting simulation
Compute various statistics for the board
Get the simulation history
run(rule, iters, **kwargs)¶
Run the simulation for a given number of iterations