Skip to content

Commit

Permalink
Rework newbie matching (#958)
Browse files Browse the repository at this point in the history
* Rework random matching for newbies

* Add and fix tests
  • Loading branch information
BlackYps authored Mar 18, 2023
1 parent 22da0ff commit 314d1f0
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 273 deletions.
2 changes: 2 additions & 0 deletions server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def __init__(self):
self.LADDER_SEARCH_EXPANSION_STEP = 0.05
self.LADDER_TOP_PLAYER_SEARCH_EXPANSION_MAX = 0.3
self.LADDER_TOP_PLAYER_SEARCH_EXPANSION_STEP = 0.15
self.LADDER_NEWBIE_SEARCH_EXPANSION_MAX = 0.6
self.LADDER_NEWBIE_SEARCH_EXPANSION_STEP = 0.1
# The method for choosing map pool rating
# Can be "mean", "min", or "max"
self.MAP_POOL_RATING_SELECTION = "mean"
Expand Down
38 changes: 0 additions & 38 deletions server/matchmaker/algorithm/random_newbies.py

This file was deleted.

7 changes: 1 addition & 6 deletions server/matchmaker/algorithm/stable_marriage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ...decorators import with_logger
from ..search import Match, Search
from .matchmaker import Matchmaker, MatchmakingPolicy1v1
from .random_newbies import RandomlyMatchNewbies

WeightedGraph = dict[Search, list[tuple[Search, float]]]

Expand Down Expand Up @@ -100,13 +99,9 @@ def find(
_MatchingGraph.remove_isolated(ranks)
matches.update(StableMarriage().find(ranks))

remaining_searches = [
unmatched_searches = [
search for search in searches if search not in matches
]
self._logger.debug("Matching randomly for remaining newbies...")

randomly_matched_newbies, unmatched_searches = RandomlyMatchNewbies().find(remaining_searches)
matches.update(randomly_matched_newbies)

return self._remove_duplicates(matches), unmatched_searches

Expand Down
7 changes: 6 additions & 1 deletion server/matchmaker/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ def search_expansion(self) -> float:
self._failed_matching_attempts * config.LADDER_TOP_PLAYER_SEARCH_EXPANSION_STEP,
config.LADDER_TOP_PLAYER_SEARCH_EXPANSION_MAX
)
elif self.has_newbie():
return min(
self._failed_matching_attempts * config.LADDER_NEWBIE_SEARCH_EXPANSION_STEP,
config.LADDER_NEWBIE_SEARCH_EXPANSION_MAX
)
else:
return min(
self._failed_matching_attempts * config.LADDER_SEARCH_EXPANSION_STEP,
Expand Down Expand Up @@ -257,7 +262,7 @@ def cancel(self):
def __str__(self) -> str:
return (
f"Search({self.rating_type}, {self._players_repr()}, threshold="
f"{self.match_threshold:.2}, expansion={self.search_expansion:.2})"
f"{self.match_threshold:.2f}, expansion={self.search_expansion:.2f})"
)

def _players_repr(self) -> str:
Expand Down
Loading

0 comments on commit 314d1f0

Please sign in to comment.