Module server.matchmaker.algorithm.matchmaker

Classes

class Matchmaker
Expand source code
@with_logger
class Matchmaker(ABC):
    @abstractmethod
    def find(
        self,
        searches: Iterable[Search],
        team_size: int,
        rating_peak: float
    ) -> tuple[list[Match], list[Search]]:
        pass

Helper class that provides a standard way to create an ABC using inheritance.

Ancestors

  • abc.ABC

Subclasses

Methods

def find(self,
searches: Iterable[Search],
team_size: int,
rating_peak: float) ‑> tuple[list[tuple['Search', 'Search']], list[Search]]
Expand source code
@abstractmethod
def find(
    self,
    searches: Iterable[Search],
    team_size: int,
    rating_peak: float
) -> tuple[list[Match], list[Search]]:
    pass
class MatchmakingPolicy1v1
Expand source code
@with_logger
class MatchmakingPolicy1v1(object):
    def __init__(self):
        self.matches: dict[Search, Search] = {}
        self.searches_remaining_unmatched: set[Search] = set()

    def _match(self, s1: Search, s2: Search):
        self._logger.debug(
            "Matching %s and %s (%s)",
            s1, s2, self.__class__
        )
        self.matches[s1] = s2
        self.matches[s2] = s1
        self.searches_remaining_unmatched.discard(s1)
        self.searches_remaining_unmatched.discard(s2)

    def _unmatch(self, s1: Search):
        s2 = self.matches[s1]
        self._logger.debug(
            "Unmatching %s and %s (%s)",
            s1, s2, self.__class__
        )
        assert self.matches[s2] == s1
        del self.matches[s1]
        del self.matches[s2]
        self.searches_remaining_unmatched.add(s1)
        self.searches_remaining_unmatched.add(s2)

Subclasses