forked from paulvangentcom/python_corona_simulation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.py
More file actions
41 lines (36 loc) · 1.47 KB
/
environment.py
File metadata and controls
41 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'''
file that contains all functions to define destinations in the
environment of the simulated world.
'''
import numpy as np
class environment:
def __init__(self, xmin, xmax, ymin, ymax, plt, addcross=True):
self.xmin = xmin
self.xmax = xmax
self.ymin = ymin
self.ymax = ymax
self.plt = plt
self.addcross = addcross
def build_hospital(self):
# plot walls
self.plt.plot([self.xmin, self.xmin], [self.ymin, self.ymax], color='black')
self.plt.plot([self.xmax, self.xmax], [self.ymin, self.ymax], color='black')
self.plt.plot([self.xmin, self.xmax], [self.ymin, self.ymin], color='black')
self.plt.plot([self.xmin, self.xmax], [self.ymax, self.ymax], color='black')
# plot red cross
if self.addcross:
xmiddle = self.xmin + ((self.xmax - self.xmin) / 2)
height = np.min([0.3, (self.ymax - self.ymin) / 5])
self.plt.plot([xmiddle, xmiddle], [self.ymax, self.ymax + height], color='red',
linewidth=3)
self.plt.plot([xmiddle - (height / 2), xmiddle + (height / 2)],
[self.ymax + (height / 2), self.ymax + (height / 2)], color='red',
linewidth=3)
def set(self, xmin, xmax, ymin, ymax, plt, addcross):
self.xmin = xmin
self.xmax = xmax
self.ymin = ymin
self.ymax = ymax
self.plt = plt
self.addcross = addcross
build_hospital()