model module

model.gen_function()[source]

To be used by FuncAnimation from matplotlib to progress the simulation. Maximum number of frames chosen to be 2,000.

Global:
carry_on (bool): if false, gen function does not increase the frame number
model.run()[source]

Reads in parameters from silders and checkboxes and initiates the animation to be plotted. Used by run_stop_toggle to initiate simulation on buttonpress.

model.set_defaults()[source]

Requires the GUI widgets to exist before it is called.

model.start_kill_toggle()[source]

Function to be used by the run_button to start, kill, and restart the simulation. Implements the following functionality:

  1. If button is pressed for the first time, the simulation is run() and the button text changes to “Kill” and its colour to normal.
  2. If the now “Kill” button is pressed, simulation is stopped and text changed to “Restart” and to green colour.
  3. If the now “Restart” button is pressed, the simulation is re-run with new parameters from the GUI, and text changed to “Kill” and colour to normal.
  4. 2 and 3 are then repeated.

Functionality for returning this button to “Restart” if all sheep die is implemented in update_labels().

model.update(frame_number, max_age, optimised_movement, breed, min_age_for_preg, preg_duration, agents, environment)[source]

To be used by FuncAnimation from matplotlib to update the simulation.

Arguments passed through by the run() function which calls this update() function.

Argument:
frame_number (int): provided by FuncAnimate()
max_age (int)
optimised_movement (bool)
breed (bool)
min_age_for_preg (int)
preg_duration (int)
agents (list of Agent classes)
environment (list of list of numbers)
Global:
carry_on (bool)
model.update_labels(frame_for_display, num_agents_for_display)[source]

To be used within the update() function to update the display of frame number and number of sheep.

Arguments:
frame_for_display (int): frame number
num_agents_for_display (agents): number of sheep alive in the scene
Requires global:
run_button (tkinter button)
n_label (tkinter label)
frame_label (tkinter label)