Skip to content

Main Loop

fhtanaka edited this page Oct 17, 2022 · 2 revisions

The simulation is ran by repeating the following actions certain number of steps. During each step, these are the operations that are executed:

  1. Update agents attributes
    • Updates updatable attributes like hunger, energy, etc
  2. Check for agent activities
    • For each agent, check if it already has an activity.
    • If the agent does not have an activity, it assigns it an activity based on the behavior this specific agent is following.
    • The function that checks for activities, return an array of movement actions to be used in the next step.
    • The activity itself is saved on the agent
  3. Calculate the pathfinding for each movement action that is determined on the previous step
    • Uses the A* algorithm to calculate the routes agents will use to move
    • At the moment (10/17/22) this is the bottleneck of the applciation
  4. Agents will perform the activity assigned to them.
    • For example, they will move a certain distance to its goal node, it will wait in place, etc
    • If the activity is finished after they perform this step, the action is removed from its attributes and next step it will be replaced
  5. Creates a dictionary that groups the agent by location
    • This dict has a location id as its key and an array of agents as its value
  6. Will trigger the events from the plugins
    • At the moment we have 2 plugins: evacuation and infection
    • The infection module will check for infections of agents, change their status (healthy, asymptomatic, symptomatic, sever), and change their behavior
    • The evacuation module may trigger an evacuation
      • In the future, it may also destroy buildings or roads
    • More information about the plugins can be found on its own page (to be linked here)

OBS: Please note that when using the visualization, the main loops is executed in View

Clone this wiki locally