Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send ratings of search parties in queue #1020

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion server/matchmaker/matchmaker_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,17 @@ def to_dict(self):
"""
Return a fuzzy representation of the searches currently in the queue
"""

granularity = 25
# Average rating is based on displayed rating, while the 1v1 queue uses mean rating for matching.
if self.team_size == 1:
active_rating_groups = {
round(search.ratings[0].mean / granularity) * granularity for search in self._queue.keys()
}
else:
active_rating_groups = {
round(search.average_rating / granularity) * granularity for search in self._queue.keys()
}
return {
"queue_name": self.name,
"queue_pop_time": datetime.fromtimestamp(
Expand All @@ -288,9 +299,13 @@ def to_dict(self):
ndigits=2
),
"num_players": self.num_players,
"active_rating_groups": sorted(active_rating_groups),
# TODO: Remove deprecated keys
# DEPRECATED, the client is supposed to use active_rating_groups instead
"boundary_80s": [search.boundary_80 for search in self._queue.keys()],
# DEPRECATED, the client is supposed to use active_rating_groups instead
"boundary_75s": [search.boundary_75 for search in self._queue.keys()],
# TODO: Remove, the client should query the API for this
# DEPRECATED, the client should query the API for this
"team_size": self.team_size,
}

Expand Down
8 changes: 5 additions & 3 deletions tests/integration_tests/test_matchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ async def test_matchmaker_info_message(lobby_server, mocker):
assert queue["queue_pop_time_delta"] == math.ceil(
config.QUEUE_POP_TIME_MAX / 2
)
assert queue["active_rating_groups"] == []
assert queue["boundary_80s"] == []
assert queue["boundary_75s"] == []

Expand Down Expand Up @@ -484,6 +485,7 @@ async def test_command_matchmaker_info(lobby_server, mocker):
assert queue["queue_pop_time_delta"] == math.ceil(
config.QUEUE_POP_TIME_MAX / 2
)
assert queue["active_rating_groups"] == []
assert queue["boundary_80s"] == []
assert queue["boundary_75s"] == []

Expand Down Expand Up @@ -512,10 +514,10 @@ async def read_update_msg():
queue_message = next(
q for q in msg["queues"] if q["queue_name"] == "ladder1v1"
)
if not queue_message["boundary_80s"]:
if not queue_message["active_rating_groups"]:
continue

assert len(queue_message["boundary_80s"]) == 1
assert len(queue_message["active_rating_groups"]) == 1

return

Expand All @@ -530,7 +532,7 @@ async def read_update_msg():
msg = await read_until_command(proto, "matchmaker_info")

queue_message = next(q for q in msg["queues"] if q["queue_name"] == "ladder1v1")
assert len(queue_message["boundary_80s"]) == 0
assert len(queue_message["active_rating_groups"]) == 0


@fast_forward(10)
Expand Down
3 changes: 3 additions & 0 deletions tests/integration_tests/test_teammatchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ async def test_info_message(lobby_server):
assert msg["queues"]
for queue in msg["queues"]:
boundaries = queue["boundary_80s"]
ratings = queue["active_rating_groups"]

if queue["queue_name"] == "tmm2v2":
assert boundaries == [[300, 700]]
assert ratings == [0] # team queues use displayed rating for matching
else:
assert boundaries == []
assert ratings == []


@fast_forward(10)
Expand Down
13 changes: 7 additions & 6 deletions tests/unit_tests/test_lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,13 +1003,13 @@ async def test_command_matchmaker_info(
player_factory,
mocker
):
queue = queue_factory("test", rating_type=RatingType.LADDER_1V1)
queue = queue_factory("test", team_size=3, rating_type=RatingType.LADDER_1V1)
queue.timer.next_queue_pop = 1_562_000_000
queue.push(Search([
player_factory(player_id=1, ladder_rating=(2000, 100), ladder_games=200),
]))
queue.push(Search([
player_factory(player_id=2, ladder_rating=(500, 120), ladder_games=100),
player_factory(player_id=2, ladder_rating=(600, 120), ladder_games=100),
player_factory(player_id=3, ladder_rating=(1500, 500), ladder_games=0),
]))
queue.push(Search([
Expand All @@ -1036,11 +1036,12 @@ async def test_command_matchmaker_info(
{
"queue_name": "test",
"queue_pop_time": "2019-07-01T16:53:20+00:00",
"queue_pop_time_delta": 1.0,
"team_size": 1,
"queue_pop_time_delta": 1,
"team_size": 3,
"num_players": 6,
"boundary_80s": [(1800, 2200), (300, 700), (800, 1200)],
"boundary_75s": [(1900, 2100), (400, 600), (900, 1100)]
"active_rating_groups": [125, 1125, 1700],
"boundary_80s": [(1800, 2200), (400, 800), (800, 1200)],
"boundary_75s": [(1900, 2100), (500, 700), (900, 1100)]
}
]
})
Expand Down
Loading