Esempio n. 1
0
 def move(self):
     #What angle it need to travel
     Angle = randrange(0,360)
     #How much time until it changes direction
     TOM = randrange(config.getVal("-turnIntervalMin"),config.getVal("-turnIntervalMax"),1)
     SPEED = config.getVal("-speed")
     #Translates this into how fast it should travel in each direction
     Movementx = math.cos(math.radians(Angle))*SPEED
     Movementy = math.sin(math.radians(Angle))*SPEED
     #Stops dead people moving
     if self.status == 2:
         Movementx = 0
         Movementy = 0
     return Movementx, Movementy, TOM
Esempio n. 2
0
 def resolveSpread(self):
     #Makes people sick
     if self.status == -1:
         self.status = 1
         self.color = config.getVal("-sickColor")
     #Person died
     elif self.status == -2:
         self.status = 2
         self.color = config.getVal("-deathColor")
     #Person became permanantly imune
     elif self.status == -3:
         self.status = 3
         self.color = config.getVal("-imuneColor")
     #Person is temporarily imune and we remove some of the time left as temporary imunity
     elif self.status == 4:
         self.healthyTime -= 1*loop_factor
         if self.healthyTime <= 0:
             self.status = 0
             self.color = config.getVal("-healthyColor")
Esempio n. 3
0
 def draw(self):
     
     r = config.getVal("-squareLength") #Radius of square drawn
     
     canvas.create_rectangle(self.x-r, self.y-r, self.x+r, self.y+r, fill=self.color) #Draws the square
     
     #See if persons direction should change
     if self.TimeOfMovement <= 0:
         self.Movex, self.Movey, self.TimeOfMovement = self.move()
     #Moves person in the choosen direction
     elif self.TimeOfMovement > 0:
         self.x += self.Movex * loop_factor
         self.y += self.Movey * loop_factor
         self.TimeOfMovement -= loop_factor
         #Makes sure people don't move out of bounds
         self.x = self.x % widthCanvas
         self.y = self.y % heightCanvas
     else:
         print("Error: TimeOfMovement below threshold")
Esempio n. 4
0
 def spread(self, folk):
     spreadType = config.getVal("-spreadType") #How it spreads from each person currently only one option
     spreadRadius = config.getVal("-spreadRadius") #How cole people need to be to spread dissease
     #Chances of changing into different state 1.
     deathChance = config.getVal("-chanceDeath")
     imunityChance = config.getVal("-chanceImune")
     healthyChance = config.getVal("-chanceHealthy")
     if self.status == 1:
         #Checks for every other person if they are so close as to spread disease to.
         for i in folk:
             if spreadType == 0:
                 if i.status == 0 and math.sqrt((self.x-i.x)**2+(self.y-i.y)**2) <= spreadRadius:
                     #Does makes it so it doesn't imeadieately spread from the person
                     i.status = -1
         #Checks for how a persons state changes
         if random.random() < deathChance*loop_factor:
             self.status = -2
             self.TimeOfMovement = 0
         elif random.random() < imunityChance*loop_factor:
             self.status = -3
         elif random.random() < healthyChance*loop_factor:
             self.status = 4
             self.color = "yellow"
             self.healthyTime = random.randint(config.getVal("-tempImuneMin"),config.getVal("-tempImuneMax"))
Esempio n. 5
0
from random import randrange

import sys
import time
import ParameterHandler as config

import random
import math
import matplotlib.pyplot as plt


#Initializes settings
args = sys.argv
config.initializeConfig(args)
#Parameters of canvas height and width
widthCanvas = config.getVal("-width")
heightCanvas = config.getVal("-height")

#Sets up tkinter canvas
root = tk.Tk()
canvas = tk.Canvas(root,height=heightCanvas,width=widthCanvas,background="grey")
canvas.pack()

#Tracks time
loop_factor = 0

#Arrays to store how many people are en each state at each iteration
dataHealthy = []
dataSick = []
dataDead = []
dataImune = []