Skip to content
Open
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
8 changes: 4 additions & 4 deletions server/matchmaker/algorithm/team_matchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,17 @@ def assign_game_quality(
minority_bonus = min(minority_bonus, config.MINORITY_BONUS)
rating_disparity = abs(match[0].cumulative_rating - match[1].cumulative_rating)
unfairness = rating_disparity / config.MAXIMUM_RATING_IMBALANCE
deviation = statistics.pstdev(ratings)
rating_variety = deviation / config.MAXIMUM_RATING_DEVIATION
max_team_deviation = max(map(statistics.pstdev, [match[0].displayed_ratings, match[1].displayed_ratings]))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using displayed ratings here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for the ratings separately for each team, I was not sure which is the correct value to use. Which value do you suggest to use?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use average_rating of the original searches like it is done here:

for search in team.get_original_searches():
ratings.append(search.average_rating)

max_rating_variety = max_team_deviation / config.MAXIMUM_RATING_DEVIATION
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the name rating_variety here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the point is that it is the maximum rating variety of all teams


# Visually this creates a cone in the unfairness-rating_variety plane
# that slowly raises with the time bonuses.
quality = 1 - sqrt(unfairness ** 2 + rating_variety ** 2) + time_bonus + minority_bonus
quality = 1 - sqrt(unfairness ** 2 + max_rating_variety ** 2) + time_bonus + minority_bonus
if not any(team.has_high_rated_player() for team in match):
quality += newbie_bonus
self._logger.debug(
"bonuses: %s rating disparity: %s -> unfairness: %f deviation: %f -> variety: %f -> game quality: %f",
newbie_bonus + time_bonus + minority_bonus, rating_disparity, unfairness, deviation, rating_variety, quality
newbie_bonus + time_bonus + minority_bonus, rating_disparity, unfairness, max_team_deviation, max_rating_variety, quality
)
return GameCandidate(match, quality)

Expand Down
8 changes: 4 additions & 4 deletions tests/unit_tests/test_matchmaker_algorithm_team_matchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ def test_team_matchmaker_algorithm(player_factory):

matches, unmatched = matchmaker.find(s, 4, 1000)

assert set(matches[1][0].get_original_searches()) == {c1, s[2], s[5]}
assert set(matches[1][1].get_original_searches()) == {c3, s[1], s[6]}
assert set(matches[0][0].get_original_searches()) == {c4, s[4]}
assert set(matches[0][1].get_original_searches()) == {c2, s[0], s[3]}
assert set(matches[0][0].get_original_searches()) == {c1, s[2], s[5]}
assert set(matches[0][1].get_original_searches()) == {c3, s[1], s[6]}
assert set(matches[1][0].get_original_searches()) == {c4, s[4]}
assert set(matches[1][1].get_original_searches()) == {c2, s[0], s[3]}
Comment on lines +83 to +86
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tests were not passing (i think even before the change) and this part actually looked wrong, at least the way I made sense of it this should be the correct assertions, but I am not sure.

assert set(unmatched) == {s[7]}
for match in matches:
assert matchmaker.assign_game_quality(match, 4, 1000).quality > config.MINIMUM_GAME_QUALITY
Expand Down
Loading