Implementation of multi-agent simulations in PyGame.
Current examples cotain flocking, aggergation and disease spread.
-
main.py
The main file to execute, can specify here the general simulation settings:- the number of agents
- screen size
- swarm type (which experiment to run)
-
simulation folder Contains the general simulation design, as well as general multi-agent classes with properties that can be shared across the experiments.
simulation.py
The main execution loop: the simulation is initialized and ran until the user exits the window.swarm.py
General swarm properties and updatesagent.py
General agent properties and updatesphysical_objects.py
General obstacle propertieshelperfunctions.py
General vector transformation functions
-
experiments folder Contains separate folder for each experiment:
- flocking
- aggregation
- covid
-
flocking folder Contains detailed characteristics of a flocking behavior
flock.py
defines the environment of the flock, as well as specific flocking related functionsboid.py
defines a boid, with its possible actions and update rule- images folder where the images for the environment and boid design is stored
-
aggregation folder Contains detailed characteristics for aggregation behavior
aggreagte.py
defines the environment of the aggregation simuationcockroach.py
defines the specific agent actions
-
covid folder Contains experimental set-up for modeling disease spread based on the SIR model
population.py
defines the properties of the population, such as initial infected proportionperson.py
define the properties of each individual
Simply run the main.py file from terminal by specifying the type of swarm to use, and the number of agents
If you want to change the specific behavior of the given swarm, look into the corresponding swarm folder, and adjust the global variables
Have fun!
Here are some flocking examples:
Boids outside a circle object
Boids inside a circle object
Boids inside a convex object
Here is an Aggregation collective behavior example:
Here are simple disease spread example: