First we import all necessary files.
In [ ]:
from models.flocking import set_up
We then initialize global variables.
In [ ]:
from indra.agent import Agent, X, Y
from indra.composite import Composite
from indra.display_methods import BLUE, TREE
from indra.env import Env
from indra.registry import get_registration
from indra.space import DEF_HEIGHT, DEF_WIDTH, distance
from indra.utils import get_props
MODEL_NAME = "flocking"
DEBUG = False # turns debugging code on or off
DEBUG2 = False # turns deeper debugging code on or off
BIRD_GROUP = "Birds"
DEF_NUM_BIRDS = 2
DEF_DESIRED_DISTANCE = 2
ACCEPTABLE_DEV = .05
BIRD_MAX_MOVE = 1
HALF_CIRCLE = 180
FULL_CIRCLE = 360
flock = None
the_sky = None
Next we call the set_up function to set up the environment, groups, and agents of the model.
In [ ]:
(the_sky, flock) = set_up()
You can run the model N periods by typing the number you want in the following function and then running it.
In [ ]:
the_sky.runN()
You can view the position of all of the agents in space with the following command:
In [ ]:
the_sky.scatter_graph()
You can view the line graph through the following command:
In [ ]:
the_sky.line_graph()