-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpedestrian.py
More file actions
39 lines (34 loc) · 1.17 KB
/
pedestrian.py
File metadata and controls
39 lines (34 loc) · 1.17 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
from dataclasses import dataclass
from constants import *
@dataclass
class Pedestrian:
"""Class containing ped information"""
pos: [int, int]
direction: Neighbors
id: int
standing: bool
exit_id: int
not_moving: int = 1
def i(self):
return self.pos[0]
def j(self):
return self.pos[1]
def set_pos(self, new_pos):
if new_pos[0] < self.pos[0] and new_pos[1] == self.pos[1]:
self.direction = Neighbors.left
self.not_moving = 1
elif new_pos[0] > self.pos[0] and new_pos[1] == self.pos[1]:
self.direction = Neighbors.right
self.not_moving = 1
elif new_pos[0] == self.pos[0] and new_pos[1] < self.pos[1]:
self.direction = Neighbors.bottom
self.not_moving = 1
elif new_pos[0] == self.pos[0] and new_pos[1] > self.pos[1]:
self.direction = Neighbors.top
self.not_moving = 1
elif new_pos[0] == self.pos[0] and new_pos[1] == self.pos[1]:
self.direction = Neighbors.self
self.not_moving = self.not_moving + 1
else:
print('something wrong')
self.pos = new_pos