I would like to suggest an algorithm to improve matchmaking and reduce cheating.
Short description: a player must play with a number of other unique players before he can be matched against another certain player.
Long description: Every (online) player has an index and we will add a small circular buffer in the database for each player to hold last n matches, let's say 5. So, let's say player of index 1 starts the game, the database row will look like this:
1,, 0, 0, 0, 0, 0
Now player of index 1 will play four matches against random opponents, players 25, 36, 200, 321:
1,, 25, 36, 200, 321, 0
Buffer almost full, now server chooses player 25 as the next opponent. Oops! 25 is already in the buffer, choose another: 666
1,, 25, 36, 200, 321, 666
Player of index 1 start another game, this time his opponent is player of index 701. But the buffer is full, so the writing position goes back to first position and overwrite the index 25:
1,, 701, 36, 200, 321, 666
Now the index 25 is no longer in the list of player 1 so after 5 matches player 1 can play again against player 25.
Tweaks: a) you can set the buffer as long as you consider 3, 5, 10 or even make it dynamic based on the number of players online; b) you may encounter the following case: a player A could match a player B, but player B cannot yet match player A because he didn't play enough matches to round the buffer. You will have two options: - use OR: if player A can match B OR player B can match A then match them; - use AND: if player A can match B AND player B can match A then match them; c) if a player logs out, references to his index may remain, but that won't affect the game in anyway; d) since players will now have 0% chance to meet the same person in a row, you may increase the matching rank range or even completely remove it (so rank 1 could be matched with a rank 8 for example) to make game more fun and the waiting queue shorter, but it's up to you.
Memory usage: assuming you have 500 players online at a time, and each index is a 2 byte long, this means 500 x 5 x 2 = 5000 bytes = 5 Kb. For today computers and especially for servers, 5 kb of memory isn't a problem.
Let me know if this was useful or if you have any questions.
|