I am currently developing an application in Python that has a match making functionality to form sports teams of 4 and group them by skill. The following has been implemented and works.


  • Form full matches of four level 5 players until there are non left
  • If there are some left, form a match with the remaining level 5 players and some level 4 players.
  • continue like this until all players have been put into a match and put potentially remaining players onto a waitlist

Now, the objective is to allow users to specify at signup if they want to play with a specific other player. This of course can cause chains of relationships. The choice does not have to be mutual to come into effect. These indications should overrule the skill matching.

I am struggling really hard to come up with solutions. Is there preferred existing algorithms that can solve for this? I was looking at assigning cost (Hungarian algorithm) etc. but that fairly extensively ruined my already working skill match making.

I am grateful for pointers in the right direction or any ideas, really.

Thank you!

  • 2
    2 questions for you to answer for yourself: 1. If a chain of players is longer than 4 (the team size), which part of the chain should become a team? The first 4, the last 4, the sub-chain with the highest combined level, something else? 2. If a chain is less than 4, where in your current algorithm should this partial team be completed? With level 5 players, with players matching the highest level already present, with players of the lowest level present, with players from the waitlist? Commented Nov 8, 2023 at 12:38
  • Thank you very much @BartvanIngenSchenau. Those are excellent questions. 1) The first part of the chain would become a team. First come, first serve. 2) Very good question indeed. Eventually we'd have to either balance the team skill, add player on the lower or higher skill level. That's maybe even an option for the backend later to favour higher/lower performance
    – serge
    Commented Nov 8, 2023 at 14:42

1 Answer 1


The choice does not have to be mutual to come into effect

Your game has a bug. I want to team with Alice but it keeps putting me with Bob.

Humans don't react well if you don't let them opt out of one sided relationships.

These indications should overrule the skill matching.

Yes but you don't want to overrule "sports teams of 4" right?

All this adds up to a need to do logic at sign up. A player needs to know, at signup, if someone has specified that they want to play with them, and who is eligible to chain with at different the different chain sizes the players can find themselves in. That will allow opting out and forming chains no larger than 4.

Once that's sorted out you can apply the rest of your criteria for those that remain in need of a team.

  • Hi @candiedorange. Appreciate the input. Players actually sign up for the weekly matches through a form asking for their email and skill level. I am currently struggling to work out a smart idea, how to ask for their player preference. At the moment I assume offering a dropdown menu that populates all registered players. Whilst I understand your point to opt out, I also need to keep the friction at signup low and only offer the player preference in the backend, if the player logs in. Player preference would then succeed the skill matching in the matches.
    – serge
    Commented Nov 8, 2023 at 14:47
  • @Serge "Now, the objective is to allow users to specify at signup if they want to play with a specific other player." "only offer the player preference in the backend" These two statements seem contradictory. Regardless of if it's done at sign up or later, when a player chooses someone to play with they need to know how large a chain they are creating. Commented Nov 8, 2023 at 14:59
  • You are correct. It's been a long day of many iterations of this. At Signup I will continue to only ask for email and skill level. Keeps the friction low and I don't have to bother right away with the chains. So eventually it will be accessible in the backend for the players. Does anything come to mind that can be implemented as best practise to also make this scalable? Maybe it is sending a notification to the other party that they have been 'requested' Yet that still leaves the length of a potential chain open.
    – serge
    Commented Nov 8, 2023 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.