Skip to content

Commit

Permalink
Remove flickering from bot rank updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Rayman committed Oct 1, 2024
1 parent f04c3ed commit 09fbb67
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions racer/game_state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from copy import deepcopy
from time import time
from traceback import print_exception
from typing import Dict
from typing import Dict, List

from .bot import Bot
from .bots import all_bots
Expand Down Expand Up @@ -66,8 +66,10 @@ def get_bot_commands(self, bot, car_info):
cpu = time() - start
return result, cpu

def ranked(self) -> Dict[Bot, float]:
def ranked(self) -> List[Bot]:
# Search for the car_info with the longest waypoint_timing
bots = list(self.bots.keys())
bots.sort(key=lambda bot: (self.bots[bot].round, self.bots[bot].next_waypoint), reverse=True)
bots.sort(
key=lambda bot: (self.bots[bot].round, self.bots[bot].next_waypoint, -self.bots[bot].waypoint_timing[-1]),
reverse=True)
return bots

0 comments on commit 09fbb67

Please sign in to comment.