comments
This commit is contained in:
parent
83c1bb0bab
commit
00be5580a1
13
Car.py
13
Car.py
@ -202,6 +202,7 @@ class Car():
|
|||||||
return cDist
|
return cDist
|
||||||
|
|
||||||
def getLeaderAtIntersection(self, prevInd, edgeInd):
|
def getLeaderAtIntersection(self, prevInd, edgeInd):
|
||||||
|
# On récupère les edges juste avant et juste après l'intersection
|
||||||
while(self.route[edgeInd].isSpecial()):
|
while(self.route[edgeInd].isSpecial()):
|
||||||
return
|
return
|
||||||
edgeInd = edgeInd + 1
|
edgeInd = edgeInd + 1
|
||||||
@ -213,17 +214,23 @@ class Car():
|
|||||||
if prevInd < 0:
|
if prevInd < 0:
|
||||||
print(self.id, "fu2")
|
print(self.id, "fu2")
|
||||||
return None
|
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()
|
inter = self.route[edgeInd-1].getFromNode()
|
||||||
connections = self.route[prevInd].getConnections(self.route[edgeInd])
|
connections = self.route[prevInd].getConnections(self.route[edgeInd])
|
||||||
if(len(connections)==0):
|
if(len(connections)==0):
|
||||||
print("aaaaaaaaa")
|
print("pas de connections")
|
||||||
return None
|
return None
|
||||||
connection = connections[0]
|
connection = connections[0]
|
||||||
|
|
||||||
|
# On récupère la matrice de priorité pour notre route
|
||||||
linkInd = inter.getLinkIndex(connection)
|
linkInd = inter.getLinkIndex(connection)
|
||||||
if(linkInd == -1): # Ca devrait pas arriver, mais de toute évidence ça arrive
|
if(linkInd == -1): # Ca devrait pas arriver, mais de toute évidence ça arrive
|
||||||
print(self.id, "fu3")
|
print(self.id, "fu3")
|
||||||
return;
|
return;
|
||||||
resp = inter._prohibits[linkInd] # Si je me souvient bien les variables précédées d'un _ doivent pas être touchées?
|
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()
|
connRaw = inter.getConnections()
|
||||||
conn = [0] * len(resp)
|
conn = [0] * len(resp)
|
||||||
for c in connRaw:
|
for c in connRaw:
|
||||||
@ -231,6 +238,8 @@ class Car():
|
|||||||
if(ind == -1):
|
if(ind == -1):
|
||||||
continue
|
continue
|
||||||
conn[ind] = c
|
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 = []
|
cars = []
|
||||||
for i,f in enumerate(reversed(resp)):
|
for i,f in enumerate(reversed(resp)):
|
||||||
if(f == '0'):
|
if(f == '0'):
|
||||||
@ -241,8 +250,6 @@ class Car():
|
|||||||
intLaneLgt = intLane.getLength()
|
intLaneLgt = intLane.getLength()
|
||||||
carsInEdge = self.controller.getCarsOnLane(edge.getID(), laneInd)
|
carsInEdge = self.controller.getCarsOnLane(edge.getID(), laneInd)
|
||||||
carsInEdge = list(filter(lambda c: c.nextNonSpecialEdge() == conn[i].getTo(), carsInEdge))
|
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:
|
if len(carsInEdge) != 0:
|
||||||
carsInEdge = zip([self.getCarDist(c, edge, laneInd)+intLaneLgt for c in carsInEdge], carsInEdge)
|
carsInEdge = zip([self.getCarDist(c, edge, laneInd)+intLaneLgt for c in carsInEdge], carsInEdge)
|
||||||
closest = min(carsInEdge, key=lambda c: c[0])
|
closest = min(carsInEdge, key=lambda c: c[0])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user