pourcentage de ralentissement
This commit is contained in:
parent
578c433f99
commit
8a6368c50a
5
Car.py
5
Car.py
@ -58,6 +58,8 @@ class Car():
|
|||||||
self.leaderBefore=False
|
self.leaderBefore=False
|
||||||
self.distToInter=0
|
self.distToInter=0
|
||||||
self.timeStopped=0
|
self.timeStopped=0
|
||||||
|
self.speedPercentage=0
|
||||||
|
self.ticksLived=0
|
||||||
|
|
||||||
self.vmax=0
|
self.vmax=0
|
||||||
|
|
||||||
@ -422,6 +424,9 @@ class Car():
|
|||||||
if self.v == 0:
|
if self.v == 0:
|
||||||
self.timeStopped += dt
|
self.timeStopped += dt
|
||||||
|
|
||||||
|
self.speedPercentage += self.v/self.vmax
|
||||||
|
self.ticksLived += 1
|
||||||
|
|
||||||
lgt=self.v*dt
|
lgt=self.v*dt
|
||||||
|
|
||||||
self.dir = atan2(self.laneShape[self.laneInd+1][1]-self.pos[1],self.laneShape[self.laneInd+1][0]-self.pos[0])
|
self.dir = atan2(self.laneShape[self.laneInd+1][1]-self.pos[1],self.laneShape[self.laneInd+1][0]-self.pos[0])
|
||||||
|
@ -104,6 +104,7 @@ class CarController:
|
|||||||
self.spawnFailed = 0
|
self.spawnFailed = 0
|
||||||
self.totalStopped = 0
|
self.totalStopped = 0
|
||||||
self.carsDestroyed = 0
|
self.carsDestroyed = 0
|
||||||
|
self.speedPercentageTotal = 0
|
||||||
|
|
||||||
self.infoWidget = None
|
self.infoWidget = None
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ class CarController:
|
|||||||
self.spawnFailed += 1
|
self.spawnFailed += 1
|
||||||
#flow.addCar2Counter()
|
#flow.addCar2Counter()
|
||||||
flow.priority += 1
|
flow.priority += 1
|
||||||
print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
|
#print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
|
||||||
|
|
||||||
def draw(self,painter):
|
def draw(self,painter):
|
||||||
for ind,car in enumerate(self.cars):
|
for ind,car in enumerate(self.cars):
|
||||||
@ -195,6 +196,7 @@ class CarController:
|
|||||||
def destroyCar(self, car):
|
def destroyCar(self, car):
|
||||||
self.carsDestroyed += 1
|
self.carsDestroyed += 1
|
||||||
self.totalStopped += car.timeStopped
|
self.totalStopped += car.timeStopped
|
||||||
|
self.speedPercentageTotal += car.speedPercentage / car.ticksLived
|
||||||
self.cars.remove(car)
|
self.cars.remove(car)
|
||||||
|
|
||||||
def updateConstant(self, name, val):
|
def updateConstant(self, name, val):
|
||||||
|
3
main.py
3
main.py
@ -83,7 +83,8 @@ class MainWindow(QMainWindow):
|
|||||||
if controller.carsDestroyed==0:
|
if controller.carsDestroyed==0:
|
||||||
return
|
return
|
||||||
averageTimeStopped = controller.totalStopped / controller.carsDestroyed
|
averageTimeStopped = controller.totalStopped / controller.carsDestroyed
|
||||||
widget.setText(f"temps d'arrêt : {averageTimeStopped:.2f}s/voiture \n nombre de voitures qui n'ont pas pu apparaitre : {controller.spawnFailed}")
|
speedPercentage = controller.speedPercentageTotal / controller.carsDestroyed
|
||||||
|
widget.setText(f"temps d'arrêt : {averageTimeStopped:.2f}s/voiture \n nombre de voitures qui n'ont pas pu apparaitre : {controller.spawnFailed} \n <vitesse/vitesse max>T : {speedPercentage:.2f}")
|
||||||
|
|
||||||
@Slot(int)
|
@Slot(int)
|
||||||
def updatePhysicsFps(self,t):
|
def updatePhysicsFps(self,t):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user