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

Feature/#727 refactor matchmaker for 4v4 party algorithm #749

Conversation

cleborys
Copy link
Member

@cleborys cleborys commented Mar 21, 2021

Refactors server/matchmaker/algorithm.py such that the matchmaking algorithm is independent from the queue logic, with the intent that @BlackYps can simply subclass a new Matchmaker to propose a new algorithm.

For now I stuck to minimal/minor changes, although I think these files could still benefit a lot from more attention. For example I'm not convinced that these Matchmakers should have instance variables at all but left that as-is for a chance to get feedback first.

Closes #801.

@cleborys cleborys requested a review from Askaholic March 21, 2021 11:27
@cleborys
Copy link
Member Author

Github doesn't seem to re-use files for several diffs where a single file has been split into two. To get smaller diffs, you can compare
the deleted test_matchmaker_queue_algorithm.py to test_matchmaker_algorithm_bucket_teams.py and test_matchmaker_algorithm_stable_marriage.py and the deleted matchmaker/algorithm.py to all of the matchmaker/algorithm/*.py files.

@codecov
Copy link

codecov bot commented Mar 21, 2021

Codecov Report

Merging #749 (edaf13d) into develop (b3b7acd) will decrease coverage by 0.03%.
The diff coverage is 98.67%.

Impacted Files Coverage Δ
server/matchmaker/matchmaker_queue.py 92.42% <93.75%> (-0.06%) ⬇️
server/matchmaker/algorithm/matchmaker.py 96.42% <96.42%> (ø)
server/matchmaker/algorithm/stable_marriage.py 99.03% <99.03%> (ø)
server/matchmaker/algorithm/bucket_teams.py 99.19% <99.19%> (ø)
server/matchmaker/algorithm/random_newbies.py 100.00% <100.00%> (ø)

Copy link
Collaborator

@Askaholic Askaholic left a comment

Choose a reason for hiding this comment

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

I agree that there is no point in many of the objects used. If they're just holding 1 instance variable then that could really be moved to a function parameter.

server/matchmaker/algorithm/stable_marriage.py Outdated Show resolved Hide resolved
server/matchmaker/algorithm/stable_marriage.py Outdated Show resolved Hide resolved
server/matchmaker/matchmaker_queue.py Outdated Show resolved Hide resolved
@cleborys cleborys force-pushed the feature/#727-refactor-matchmaker-for-4v4-party-algorithm branch from 447a6a9 to 7fff817 Compare June 6, 2021 19:25
@cleborys
Copy link
Member Author

cleborys commented Jun 6, 2021

I finally included the suggestion to return a list of unmatched searches from the matchmakers, rather than taking the difference after the fact.
The remaining codacy issues all look like false positives.

@cleborys cleborys force-pushed the feature/#727-refactor-matchmaker-for-4v4-party-algorithm branch from fbf71ee to f1e1bc6 Compare June 29, 2021 22:32
server/matchmaker/algorithm/matchmaker.py Outdated Show resolved Hide resolved
Comment on lines +84 to +88
if team_size != 1:
self._logger.error(
"Invalid team size %i for stable marriage matchmaker will be ignored",
team_size,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should there be a return here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, I wouldn't say so - it will simply ignore what you passed in and the parameter is only there to comply with the Matchmaker interface. By "ignore" I mean it will continue to execute as if you had passed a team_size of 1 (and implicitly assume that all Searches passed in searches correspond to a single player).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh ok. So really the parameter is always ignored, and here it's just logging that something weird is going on. Wouldn't it be better to just assert team_size == 1 then to avoid programming errors?

server/matchmaker/matchmaker_queue.py Show resolved Hide resolved
server/matchmaker/matchmaker_queue.py Show resolved Hide resolved
tests/unit_tests/test_matchmaker_algorithm_bucket_teams.py Outdated Show resolved Hide resolved
tests/unit_tests/test_matchmaker_algorithm_bucket_teams.py Outdated Show resolved Hide resolved
tests/unit_tests/test_matchmaker_queue.py Show resolved Hide resolved
tests/unit_tests/test_matchmaker_queue.py Show resolved Hide resolved
@Askaholic Askaholic force-pushed the feature/#727-refactor-matchmaker-for-4v4-party-algorithm branch from 81f2e21 to 88de96e Compare July 13, 2021 02:11
@cleborys cleborys force-pushed the feature/#727-refactor-matchmaker-for-4v4-party-algorithm branch from 679dc35 to bce3504 Compare July 14, 2021 21:11
@Askaholic Askaholic force-pushed the feature/#727-refactor-matchmaker-for-4v4-party-algorithm branch from bce3504 to d9a314f Compare July 24, 2021 18:27
@Askaholic Askaholic force-pushed the feature/#727-refactor-matchmaker-for-4v4-party-algorithm branch from 3bb3125 to 5c25361 Compare July 24, 2021 19:04
@Askaholic Askaholic merged commit 369dc07 into FAForever:develop Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Searches don't register failed matching attempts if too few people are in queue
3 participants