infection.util package

Submodules

infection.util.circular_button module

infection.util.individual module

This module defines the Individual abstract class, and its HeallthyIndividual and InfectedIndividual subclasses and all of their properties and methods.

class infection.util.individual.HealthyIndividual(simulation, infection_probability, **kwargs)[source]

Bases: Individual

This is the definition of the HealthyIndividual class. It inherits

from the Individual abstract class.

Args:

simulation (Simulation): Instance of the Simulation class. infection_probability (Float): A value from 0 to 1 that

determines how likely is an individual to get infected.

Attributes:

simulation: To store the instance of the simulation class. infection_probability: To store the infection_probability. recovered: Boolean property used to track when the individual has

recovered from an infection. False by default. True when it has recovered from an infection. An individual that has recovered from an infection can no longer get infected.

time_infected: Integer property that tracks during how many cycles

the individual has been infected.

max_time_infected: Integer property that defines how many cycles need

to pass until the individual recovers. Set to MAX_TIME_INFECTED.

cooldown: Integer property that tracks how many cycles have passed

after the last infection evaluation to avoid evaluating against the same individual multiple times after crossing paths.

max_cooldown: Integer property that defines how many cycles need

to pass until the infection evaluations restart. Set to MAX_COOLDOWN.

status: String property that tracks the infection status of the

individual. “healthy” by default.

property cooldown
count_infected_neighbors(circular_button, quad_tree)[source]
Method that searches the quad_tree to find the number of infected

individuals within the provided radius and returns the count in the infected_neighbor_count variable.

Args:
circular_button (CircularButton): Instance of the button

containing the individual.

quad_tree (QuadTree): A quadtree structure that contains the

positions of all the individuals in the simulation for fast neighbor search.

evaluate_infection(circular_button, quad_tree)[source]
Method that calls the count_infected_neighbors method and if

there’s one or more infected neighbors, a formula is used to randomly calculate if the individual should get infected based on the infection_probability and the number of infected neighbors.

Args:
circular_button (CircularButton): Instance of the button

containing the individual.

quad_tree (QuadTree): A quadtree structure that contains the

positions of all the individuals in the simulation for fast neighbor search.

infection(circular_button, quad_tree)[source]
Method that controls if the individual will get infected by

being around one or more infected individuals in the provided quad_tree, or if the individual is now recovered because self.max_time_infected cycles have passed after infection.

Args:
circular_button (CircularButton): The instance of the button

containing the individual to change its properties.

quad_tree (QuadTree): A quadtree structure that contains the

position of all the individuals in the canvas for fast neighbor search.

property infection_probability
property max_cooldown
property max_time_infected
recover(circular_button)[source]

Method to set the individual’s properties when it recovers.

Args:
circular_button (CircularButton): Instance of the button

containing the individual.

property recovered

Boolean property used to track when the individual has recovered from an infection.

sick(circular_button)[source]

Method to set the individual’s properties when it gets sick.

Args:
circular_button (CircularButton): Instance of the button

containing the individual.

property simulation

To store an instance of the simulation class.

property status

String property used to track the infection status of the individual.

property time_infected

Integer property to track how long the individual has been infected.

class infection.util.individual.Individual[source]

Bases: ABC

This is the definition of the Individual abstract class. It inherits from the ABC class to make it an abstract class.

abstract infection()[source]

Abstract method that will control the infection status of the individual and decide if it will get infected or if it will recover.

abstract recover()[source]

Abstract method that will set the properties when the individual recovers from infection

abstract property recovered

Boolean property used to track when the individual has recovered from an infection.

abstract property simulation

To store an instance of the simulation class.

abstract property status

String property used to track the infection status of the individual.

abstract property time_infected

Integer property to track how long the individual has been infected.

class infection.util.individual.InfectedIndividual(simulation, **kwargs)[source]

Bases: Individual

This is the definition of the InfectedIndividual class. It inherits from the Individual abstract class.

Args:

simulation (Simulation): Instance of the Simulation class.

Attributes:

simulation: To store the instance of the simulation class. recovered: Boolean property used to track when the individual has

recovered from an infection. False by default. True when it has recovered from an infection. An individual that has recovered from an infection can no longer get infected.

time_infected: Integer property that tracks during how many cycles

the individual has been infected.

max_time_infected: Integer property that defines how many cycles need

to pass until the individual recovers. Set to MAX_TIME_INFECTED.

status: String property that tracks the infection status of the

individual. “infected” by default.

infection(circular_button, quad_tree)[source]
Method that controls if the individual is now recovered because

self.max_time_infected cycles have passed after infection.

Args:
circular_button (CircularButton): The instance of the button

containing the individual to change its properties.

quad_tree (QuadTree): A quadtree structure that contains the

position of all the individuals in the canvas for fast neighbor search. Ignored in the InfectedIndividual class.

property max_time_infected
recover(circular_button)[source]

Method to set the individual’s properties when it recovers.

Args:
circular_button (CircularButton): Instance of the button

containing the individual.

property recovered

Boolean property used to track when the individual has recovered from an infection.

property simulation

To store an instance of the simulation class.

property status

String property used to track the infection status of the individual.

property time_infected

Integer property to track how long the individual has been infected.

infection.util.menu_bottom module

infection.util.menu_right module

Module contents