Skip to content

Commit

Permalink
Minor opponents reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
Torom committed Dec 3, 2023
1 parent b4ecf48 commit 0a305c0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions opponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_opponent(self,
if not bots:
raise NoOpponentException

for bot in sorted(bots, key=lambda bot: abs(bot.rating_diffs[matchmaking_type.perf_type])):
for bot in bots:
if bot in self.busy_bots:
continue

Expand Down Expand Up @@ -112,9 +112,10 @@ def add_timeout(self, success: bool, game_duration: timedelta, matchmaking_type:
timeout *= matchmaking_type.multiplier * opponent_multiplier

if opponent_data.release_time > datetime.now():
timeout += opponent_data.release_time - datetime.now()
opponent_data.release_time += timeout
else:
opponent_data.release_time = datetime.now() + timeout

opponent_data.release_time = datetime.now() + timeout
release_str = opponent_data.release_time.isoformat(sep=' ', timespec='seconds')
print(f'{bot.username} will not be challenged to a new game pair before {release_str}.')

Expand Down Expand Up @@ -152,7 +153,7 @@ def bot_filter(bot: Bot) -> bool:

return True

return list(filter(bot_filter, bots))
return sorted(filter(bot_filter, bots), key=lambda bot: abs(bot.rating_diffs[matchmaking_type.perf_type]))

def _find(self, perf_type: Perf_Type, username: str) -> Opponent:
try:
Expand Down

0 comments on commit 0a305c0

Please sign in to comment.