First we import all necessary files.
In [ ]:
from indra.agent import Agent
from indra.composite import Composite
from indra.display_methods import BLACK, SQUARE
from indra.env import Env
from indra.utils import get_props
from models.gameoflife import set_up
We then initialize global variables.
In [ ]:
MODEL_NAME = "gameoflife"
DEBUG = False # Turns debugging code on or off
DEF_HEIGHT = 30
DEF_WIDTH = 30
biosphere = None
groups = None
reset_lists = False
to_come_alive = []
to_die = []
Next we call the set_up function to set up the environment, groups, and agents of the model.
In [ ]:
(biosphere, groups) = set_up()
You can run the model N periods by typing the number you want in the following function and then running it.
In [ ]:
biosphere.runN()
You can view the position of all of the agents in space with the following command:
In [ ]:
biosphere.scatter_graph()
You can view the line graph through the following command:
In [ ]:
biosphere.line_graph()