-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
44 lines (37 loc) · 1.59 KB
/
setup.py
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
42
43
44
from junction import Junction
from light import Light
class Setup():
def __init__(self) -> None:
self.setupRoad()
def setupRoad(self) -> None:
entryJunction1 = Junction(isEntryJunction=True)
entryJunction2 = Junction(isEntryJunction=True)
Junction1 = Junction()
Junction2 = Junction()
Junction3 = Junction()
Junction4 = Junction()
Junction1.addJunctionNeighbourPair(entryJunction1)
Junction1.addJunctionNeighbourPair(Junction2)
Junction1.addJunctionNeighbourPair(Junction4)
Junction2.addJunctionNeighbourPair(Junction3)
Junction3.addJunctionNeighbourPair(Junction4)
Junction3.addJunctionNeighbourPair(entryJunction2)
self.createLights()
self.createPedestrianLights()
#automatically creates the systems traffic lights. For every junction it creates a light coming from a neighbouring junction, and going
#to a neighbouring junction
def createLights(self):
for junction in Junction.getJunctions():
neighbouringJunctions = junction.getNeighbouringJunctions()
for prevJunction in neighbouringJunctions:
for destJunction in neighbouringJunctions:
if prevJunction != destJunction:
junction.addTrafficLight(prevJunction=prevJunction, destinationJunction=destJunction)
return
def createPedestrianLights(self):
for junction in Junction.getJunctions():
junction.addPedestrianLight()
def mainSetup():
setup = Setup()
if __name__ == "__main__":
setupTest = Setup()