For a recent work ping pong doubles tournament, instead of just making fair-ish teams by matching the best player with the worst player, they decided to try something different and just have X random matches, each with a different partner. To keep the games kinda fair, we have an internal guess-timate of player strength, and wanted the matchups to reflect Player 1 Rank + Player 2 Rank =~ Player 3 Rank + Player 4 Rank. My attempt to google a solution didn't find anything so I wrote a quick generator in javascript. Note: there aren't any field checks so certain player/game number combinations may take a long while to generate, or not be generate-able.
— 2020/04/29Added a few field checks to stop impossible player/game combinations. Also adjusted the algorithm to lower the chance of it hitting an endless loop and added some checks to stop really long processes