List of commits:
Subject Hash Author Date (UTC)
Traffic queues now implemented on all traffic. bcf0ece12b63e87894a2f9d1138145353054fbab Jan Allersma 2018-01-08 21:37:25
Pedestrian don't think they're cars anymore! Also small code cleanup. 7c6e2978497442330d56fd334cf8b33e73c7525a Jan Allersma 2018-01-08 20:53:51
Cars send signal once they're waiting, not before they're waiting. 49fda0804f0e056fe6a060ff13bd1c10408f696e Jan Allersma 2018-01-08 15:57:41
Assessment 8ad5b23b821e160483b919f0f375313ec6dc79be Jan Allersma 2017-12-20 11:37:13
TrafficLights working..? 7f12d9c9d44a2fa556d15e075723ec9c11c8b468 Jan Allersma 2017-12-19 15:22:32
Add lights and fully working train. ee0e851a1b482f162918f8723fc0c62d257aff83 Jan Allersma 2017-12-18 16:59:33
Commit after fixing issues during lecture 93b7f5e88a7a4427867054ebabe0505963b14da0 Jan Allersma 2017-12-13 12:49:55
Some more fixes :D 09f121a8de8ef6f49abbf0a52b0e9d9c033ade58 Jan Allersma 2017-12-09 15:09:38
Also added additional waypoints for 106. 1567c42fbaa689848d2ca2620e37bb83bb30eaf4 Jan Allersma 2017-12-07 13:40:56
Fixed some bugs (See TestResultsSimulator.txt for more info). 7c4466770f8b4da0af1156856a40b32cd11b6d37 Jan Allersma 2017-12-07 13:31:04
Werk van Simulator na testen 05/12/17. 80af7ffb5438b855a2e73fb185ba66c1cd50efe3 Jan Allersma 2017-12-05 09:45:11
Nieuwe plattegrond toegevoegd. b520f51bdd4a4d25e5d1a54cd094cf3b4632a369 Jan Allersma 2017-12-02 14:19:52
More Waypoints! 465108ac6a127bbda26b40989fd6a68cd3e00aad Jan Allersma 2017-11-30 12:52:22
Added voetganger. dad12c3d2eb2a7160838c3495e4a7a2d382e493f Jan Allersma 2017-11-30 12:32:35
Added all waiting waypoints for 1xx. bbba002738e0a26b085673400c76329d3055d8ba Jan Allersma 2017-11-29 12:00:37
Simulation now working correctly for ID's 101, 102 and 103. 1bc2fb65bb75b3a1f63cf7690472152fe1f32564 Jan Allersma 2017-11-28 16:22:53
Autos kunnen gespawned worden en rijden dan de goede richting op. b36ef1cafeda20d5753b72c6f8e6ac8423c42d95 Jan Allersma 2017-11-26 21:44:39
Last changes before test case 5. 258ba4735dfd2078f8e4f034fffed2bbbb086f2a Jan Allersma 2017-11-22 14:08:37
hallo dit is kapot maar het werkt woehoe 4475c2633e962688c71634d633ac8789524f16cf XCBouke 2017-11-22 13:58:54
It's actually working now! With a gameloop and new icons :D 0b65d450fea6d9f679029f2d6765c7e2d1126cdd Jan Allersma 2017-11-20 22:02:23
Commit bcf0ece12b63e87894a2f9d1138145353054fbab - Traffic queues now implemented on all traffic.
* Queues are more generalized using directions.
* Renamed 'trafficId' to 'internalTrafficId'.
* Renamed 'trafficType' to 'externalTrafficId'.
* Fixes should solve weird latency issues between user input and appearance of character.
* The previous commit fixed the count of transforms. Registration of amount of vehicles should be registered properly.
Author: Jan Allersma
Author date (UTC): 2018-01-08 21:37
Committer name: Jan Allersma
Committer date (UTC): 2018-01-08 21:37
Parent(s): 7c6e2978497442330d56fd334cf8b33e73c7525a
Signing key:
Tree: a7ef725b7c3d829f74cadd6fbd5ad54a938fa033
File Lines added Lines deleted
simulatie/pyg.py 38 34
simulatie/trafficModel.py 35 1
File simulatie/pyg.py changed (mode: 100644) (index 1c7e252..180cc84)
... ... class Light(object):
49 49
50 50
51 51 class Vehicle(object): class Vehicle(object):
52 def __init__(self, x, y, trafficId, dirRequest):
53 trafficType = tm.lights[trafficId]["Id"]
54 print("Traffic type: " + str(trafficType))
52 def __init__(self, x, y, internalTrafficId, dirRequest):
53 externalTrafficId = tm.lights[internalTrafficId]["Id"]
54 print("Traffic type: " + str(externalTrafficId))
55 55
56 if trafficType >= 100 and trafficType < 200: # Is een auto
56 if externalTrafficId >= 100 and externalTrafficId < 200: # Is een auto
57 57 self.auto = pygame.transform.scale(pygame.image.load("Auto.png"), (64,64)) self.auto = pygame.transform.scale(pygame.image.load("Auto.png"), (64,64))
58 elif trafficType < 300: # Is een bus
58 elif externalTrafficId < 300: # Is een bus
59 59 self.auto = pygame.transform.scale(pygame.image.load("Auto.png"), (64,64)) self.auto = pygame.transform.scale(pygame.image.load("Auto.png"), (64,64))
60 elif trafficType < 400: # Is een fietser
60 elif externalTrafficId < 400: # Is een fietser
61 61 self.auto = pygame.transform.scale(pygame.image.load("Fietser.png"), (64,64)) self.auto = pygame.transform.scale(pygame.image.load("Fietser.png"), (64,64))
62 elif trafficType < 500: # Is een voetganger
62 elif externalTrafficId < 500: # Is een voetganger
63 63 self.auto = pygame.transform.scale(pygame.image.load("Voetganger.png"), (64,64)) self.auto = pygame.transform.scale(pygame.image.load("Voetganger.png"), (64,64))
64 elif trafficType < 600: # Is een trein
64 elif externalTrafficId < 600: # Is een trein
65 65 self.auto = pygame.transform.scale(pygame.image.load("trein.png"), (64,64)) self.auto = pygame.transform.scale(pygame.image.load("trein.png"), (64,64))
66 66 else: # zijn slagbomen else: # zijn slagbomen
67 67 pass pass
 
... ... class Vehicle(object):
77 77 self.rect = self.auto.get_rect() self.rect = self.auto.get_rect()
78 78 self.dest = [x,y] self.dest = [x,y]
79 79 self.speed = [0,0] self.speed = [0,0]
80 self.trafficId = trafficId
80 self.internalTrafficId = internalTrafficId
81 81 self.dirRequest = dirRequest self.dirRequest = dirRequest
82 82
83 83 self.wp = 1 self.wp = 1
 
... ... class Vehicle(object):
85 85 self.transform = 0 self.transform = 0
86 86 self.firedUpdate = False self.firedUpdate = False
87 87
88 self.rect.x = tm.queues[trafficId][0][0]
89 self.rect.y = tm.queues[trafficId][0][1]
88 self.rect.x = tm.queues[internalTrafficId][0][0]
89 self.rect.y = tm.queues[internalTrafficId][0][1]
90 90
91 91 # Bij sommige ID's moet de texture gespiegeld worden. # Bij sommige ID's moet de texture gespiegeld worden.
92 if trafficType == 103 or trafficType == 106 or trafficType == 108 or trafficType == 109 or trafficType == 110 or trafficType == 303 or trafficType == 402:
92 if externalTrafficId == 103 or externalTrafficId == 106 or externalTrafficId == 108 or externalTrafficId == 109 or externalTrafficId == 110 or externalTrafficId == 303 or externalTrafficId == 402:
93 93 self.auto = pygame.transform.flip(self.auto, True, False) self.auto = pygame.transform.flip(self.auto, True, False)
94 94
95 95 self.transform = self.checkForTransform() self.transform = self.checkForTransform()
96 96 print(self.transform) print(self.transform)
97 97
98 98 def checkForTransform(self): def checkForTransform(self):
99 trafficType = tm.lights[self.trafficId]["Id"]
99 externalTrafficId = tm.lights[self.internalTrafficId]["Id"]
100 100 for i in range(0, len(tm.transforms)): for i in range(0, len(tm.transforms)):
101 if tm.transforms[i]["from"] == trafficType:
101 if tm.transforms[i]["from"] == externalTrafficId:
102 102 return tm.transforms[i]["to"] return tm.transforms[i]["to"]
103 103 return 0 return 0
104 104
 
... ... class Vehicle(object):
125 125
126 126 def anim(self): def anim(self):
127 127 if self.speed[0] == 0 and self.speed[1] == 0: if self.speed[0] == 0 and self.speed[1] == 0:
128 if self.waiting and self.wp < len(tm.queues[self.trafficId]): # Is nog naar het stoplicht aan het rijden..
128 if self.waiting and self.wp < len(tm.queues[self.internalTrafficId]): # Is nog naar het stoplicht aan het rijden..
129 129 if self.wp + 1 == len(tm.queues[self.wp]): if self.wp + 1 == len(tm.queues[self.wp]):
130 if self.trafficId == 3 or self.trafficId == 4 or self.trafficId == 10:
131 self.goto(tm.queues[self.trafficId][self.wp][0] + (connection.lights[self.trafficId][1] * 40), tm.queues[self.trafficId][self.wp][1])
132 elif self.trafficId == 7 or self.trafficId == 8 or self.trafficId == 9:
133 self.goto(tm.queues[self.trafficId][self.wp][0] - (connection.lights[self.trafficId][1] * 40), tm.queues[self.trafficId][self.wp][1])
134 elif self.trafficId == 0 or self.trafficId == 1 or self.trafficId == 2:
135 self.goto(tm.queues[self.trafficId][self.wp][0], tm.queues[self.trafficId][self.wp][1] - (connection.lights[self.trafficId][1] * 40))
136 elif self.trafficId == 5 or self.trafficId == 6:
137 self.goto(tm.queues[self.trafficId][self.wp][0], tm.queues[self.trafficId][self.wp][1] + (connection.lights[self.trafficId][1] * 40))
130 direction = tm.direction(tm.lights[self.internalTrafficId]["Id"])
131 if direction == "RIGHT":
132 self.goto(tm.queues[self.internalTrafficId][self.wp][0] + (connection.lights[self.internalTrafficId][1] * 40), tm.queues[self.internalTrafficId][self.wp][1])
133 elif direction == "LEFT":
134 self.goto(tm.queues[self.internalTrafficId][self.wp][0] - (connection.lights[self.internalTrafficId][1] * 40), tm.queues[self.internalTrafficId][self.wp][1])
135 elif direction == "UP":
136 self.goto(tm.queues[self.internalTrafficId][self.wp][0], tm.queues[self.internalTrafficId][self.wp][1] - (connection.lights[self.internalTrafficId][1] * 40))
137 elif direction == "DOWN":
138 self.goto(tm.queues[self.internalTrafficId][self.wp][0], tm.queues[self.internalTrafficId][self.wp][1] + (connection.lights[self.internalTrafficId][1] * 40))
138 139 else: else:
139 print("Not a car.")
140 print("Vehicle entry not found!")
140 141 else: else:
141 self.goto(tm.queues[self.trafficId][self.wp][0], tm.queues[self.trafficId][self.wp][1])
142 self.goto(tm.queues[self.internalTrafficId][self.wp][0], tm.queues[self.internalTrafficId][self.wp][1])
142 143
143 144 self.wp += 1 self.wp += 1
144 print("W: " + str(self.wp) + " / " + str(len(tm.queues[self.trafficId])))
145 print("W: " + str(self.wp) + " / " + str(len(tm.queues[self.internalTrafficId])))
145 146
146 147 elif self.waiting and not self.firedUpdate: # Wacht voor het stoplicht. elif self.waiting and not self.firedUpdate: # Wacht voor het stoplicht.
147 connection.update(self.trafficId, 1, self.dirRequest)
148 print("Wachten voor stoplicht..")
149 connection.update(self.internalTrafficId, 1, self.dirRequest)
148 150 self.firedUpdate = True self.firedUpdate = True
149 151
150 elif not self.waiting and self.wp < len(tm.waypoints[self.trafficId][self.direction]): # Al voorbij het stoplicht en nog aan het rijden.
151 self.goto(tm.waypoints[self.trafficId][self.direction][self.wp][0], tm.waypoints[self.trafficId][self.direction][self.wp][1])
152 elif not self.waiting and self.wp < len(tm.waypoints[self.internalTrafficId][self.direction]): # Al voorbij het stoplicht en nog aan het rijden.
153 self.goto(tm.waypoints[self.internalTrafficId][self.direction][self.wp][0], tm.waypoints[self.internalTrafficId][self.direction][self.wp][1])
152 154 self.wp += 1 self.wp += 1
153 print("NW: " + str(self.wp) + " / " + str(len(tm.waypoints[self.trafficId][self.direction])))
155 print("NW: " + str(self.wp) + " / " + str(len(tm.waypoints[self.internalTrafficId][self.direction])))
154 156
155 157 elif not self.waiting: # Check for transform elif not self.waiting: # Check for transform
156 158 if str(self.transform) != "0": if str(self.transform) != "0":
 
... ... class Vehicle(object):
162 164 # self.firedUpdate wordt niet meer op false gezet, # self.firedUpdate wordt niet meer op false gezet,
163 165 # aangezien een transform voor het wachten geen pad heeft. # aangezien een transform voor het wachten geen pad heeft.
164 166
167 print("transform aan het wachten..")
165 168 connection.update(self.transform, 1, None) connection.update(self.transform, 1, None)
166 169 self.wp = 1 self.wp = 1
167 170 self.waiting = True self.waiting = True
168 self.trafficId = self.transform
171 self.internalTrafficId = self.transform
169 172 print("TRANSFORM: " + str(self.transform)) print("TRANSFORM: " + str(self.transform))
170 173 else: else:
171 174 pass # Destructor here? pass # Destructor here?
 
... ... class Vehicle(object):
173 176
174 177
175 178 def trafficCheck(self): def trafficCheck(self):
176 if tm.lights[self.trafficId]["Status"] != 0 and self.waiting and self.wp <= len(tm.queues[self.trafficId]):
179 if tm.lights[self.internalTrafficId]["Status"] != 0 and self.waiting and self.wp <= len(tm.queues[self.internalTrafficId]):
177 180 # If trafficlight 601 is red and vehicle also needs to wait for 601... # If trafficlight 601 is red and vehicle also needs to wait for 601...
178 if tm.lights[len(tm.lights) - 1]["Status"] == 0 and self.trafficId == 102 or 106 <= self.trafficId <= 108:
181 if tm.lights[len(tm.lights) - 1]["Status"] == 0 and self.internalTrafficId == 102 or 106 <= self.internalTrafficId <= 108:
179 182 return return
180 183 self.waiting = False self.waiting = False
181 184 self.wp = 0 self.wp = 0
182 connection.update(self.trafficId, -1, None)
185 print("TrafficCheck connection update.")
186 connection.update(self.internalTrafficId, -1, None)
183 187 self.update() self.update()
184 188
185 189 clock = pygame.time.Clock() clock = pygame.time.Clock()
File simulatie/trafficModel.py changed (mode: 100644) (index 6670c62..79ad33b)
... ... waypoints = [
468 468 ] ]
469 469 ] ]
470 470
471 transforms = [ # { "from": (trafficType)originalType, "to": (trafficId)newId }
471 transforms = [ # SYNTAX: { "from": (externalTrafficId)originalType, "to": (internalTrafficId)newId }
472 472 { "from": 401, "to": 26}, { "from": 401, "to": 26},
473 473 { "from": 402, "to": 23}, { "from": 402, "to": 23},
474 474 { "from": 403, "to": 22}, { "from": 403, "to": 22},
 
... ... transforms = [ # { "from": (trafficType)originalType, "to": (trafficId)newId }
476 476 { "from": 405, "to": 24}, { "from": 405, "to": 24},
477 477 { "from": 406, "to": 27} { "from": 406, "to": 27}
478 478 ] ]
479
480 def direction(externalTrafficId):
481 return {
482 101: "UP",
483 102: "UP",
484 103: "UP",
485 104: "RIGHT",
486 105: "RIGHT",
487 106: "DOWN",
488 107: "DOWN",
489 108: "LEFT",
490 109: "LEFT",
491 110: "LEFT",
492 201: "RIGHT",
493 301: "DOWN",
494 302: "LEFT",
495 303: "RIGHT",
496 304: "DOWN",
497 305: "DOWN",
498 401: "UP",
499 402: "LEFT",
500 403: "RIGHT",
501 404: "UP",
502 405: "DOWN",
503 406: "DOWN",
504 407: "RIGHT",
505 408: "LEFT",
506 409: "DOWN",
507 410: "UP",
508 411: "UP",
509 412: "DOWN",
510 501: "LEFT",
511 502: "RIGHT"
512 }[externalTrafficId]
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/kapstok/NHL-SoftDev

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/kapstok/NHL-SoftDev

Clone this repository using git:
git clone git://git.rocketgit.com/user/kapstok/NHL-SoftDev

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main