How to run the ../models/wolfsheep model.

First we import all necessary files.


In [ ]:
from indra.composite import Composite
from indra.display_methods import TAN, GRAY
from indra.env import Env
from indra.registry import get_prop, get_group, get_env
from indra.space import in_hood
from indra.utils import init_props
from models.wolfsheep import set_up

We then initialize global variables.


In [ ]:
MODEL_NAME = "wolfsheep"
DEBUG = False  # turns debugging code on or off
DEBUG2 = False  # turns deeper debugging code on or off
NUM_WOLVES = 8
NUM_SHEEP = 20
HOOD_SIZE = 3
MEADOW_HEIGHT = 10
MEADOW_WIDTH = 10

WOLF_LIFESPAN = 5
WOLF_REPRO_PERIOD = 6

SHEEP_LIFESPAN = 8
SHEEP_REPRO_PERIOD = 3

AGT_WOLF_NAME = "wolf"
AGT_SHEEP_NAME = "sheep"

WOLF_GROUP = "wolves"
SHEEP_GROUP = "sheep"

ERR_MSG = "Invalid agent name"

wolves_created = 0
sheep_created = 0

Next we call the set_up function to set up the environment, groups, and agents of the model.


In [ ]:
set_up()

You can run the model N periods by typing the number you want in the following function and then running it.


In [ ]:
Env("meadow", members=members,
.runN()

You can view the position of all of the agents in space with the following command:


In [ ]:
Env("meadow", members=members,
.scatter_graph()

You can view the line graph through the following command:


In [ ]:
Env("meadow", members=members,
.line_graph()