Infection Propagation Simulation

Healthy cells vs Infected cells. Python simulation using the Pygame framework.


Platform: PC

Application: PyCharm/Pygame

Language: Python

Team Size: 1

Created: 2015

The Contagion Simulation system created within Python comprises of multiple interacting agents within a spatial environment. These agents are divided into two specific states, healthy and infected with their goal being to eliminate the opposite agent type.

These agents each have a randomized fitness value which scales their movement speed, awareness and resilience. This becomes crucial as the agents evolve over generations, where each successful encounter with an agent of opposite type will increment the agent’s fitness. Inspired by SIR models the simulation can produce varied results in real-time which are graphically represented through graphs of the overall outcome upon completion.

In terms of implementation the contagion simulation I use Python 2.7 with two core libraries, Pygame and Matplotlib to assist in displaying the real time progress and output results respectively.

I used Pygame’s graphical library to display the simulation within a Pygame window as well as initializing each agent as a Sprite object. Using the Sprite module as a basis for the agents allows the utilization of useful functions for grouping sprites and detecting collisions.

For the display of simulation results I use Matplotlib and the maths library Numpy to collate the findings into arrays to be plotted according to the time passed. This library provides a wide selection of different graphing options to graphically represent the output data with ease.

Download, video and development details coming soon!

Say Hello!