From 00be5580a11e3ee0c67508a430098d094997640d Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 13 May 2022 14:25:05 +0200 Subject: [PATCH] comments --- Car.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Car.py b/Car.py index 60a3c2c..e073140 100644 --- a/Car.py +++ b/Car.py @@ -202,6 +202,7 @@ class Car(): return cDist def getLeaderAtIntersection(self, prevInd, edgeInd): + # On récupère les edges juste avant et juste après l'intersection while(self.route[edgeInd].isSpecial()): return edgeInd = edgeInd + 1 @@ -213,17 +214,23 @@ class Car(): if prevInd < 0: print(self.id, "fu2") return None + + # On récupère les connections entre l'edge précedent et l'actuel, et on garde que la première, si y en as pas on panique inter = self.route[edgeInd-1].getFromNode() connections = self.route[prevInd].getConnections(self.route[edgeInd]) if(len(connections)==0): - print("aaaaaaaaa") + print("pas de connections") return None connection = connections[0] + + # On récupère la matrice de priorité pour notre route linkInd = inter.getLinkIndex(connection) if(linkInd == -1): # Ca devrait pas arriver, mais de toute évidence ça arrive print(self.id, "fu3") return; resp = inter._prohibits[linkInd] # Si je me souvient bien les variables précédées d'un _ doivent pas être touchées? + + # On se fait une map de correspondance entre indice de link et connection connRaw = inter.getConnections() conn = [0] * len(resp) for c in connRaw: @@ -231,6 +238,8 @@ class Car(): if(ind == -1): continue conn[ind] = c + + # Pour chaque connection si on est pas prio on regarde si y as des voitures et comme d'hab on prend la plus proche cars = [] for i,f in enumerate(reversed(resp)): if(f == '0'): @@ -241,8 +250,6 @@ class Car(): intLaneLgt = intLane.getLength() carsInEdge = self.controller.getCarsOnLane(edge.getID(), laneInd) carsInEdge = list(filter(lambda c: c.nextNonSpecialEdge() == conn[i].getTo(), carsInEdge)) - #carsInEdge = list(carsInEdge) - #carsInEdge = list(filter(lambda c: c.nextNonSpecialEdge() == self.nextNonSpecialEdge(), carsInEdge)) if len(carsInEdge) != 0: carsInEdge = zip([self.getCarDist(c, edge, laneInd)+intLaneLgt for c in carsInEdge], carsInEdge) closest = min(carsInEdge, key=lambda c: c[0])