The main difficulty comes from cheat prevention. It's very difficult because someone can modify the source code to cheat.
With that said, cheating is an issue for even large closed source games. I think it's reasonable to simply ignore the cheating (there's already systems in place that would prevent the easiest methods of cheating) and simply remove any cheating accounts that might show up.
In which case, it's mostly a matter of using the game stats that are
already sent to play.mg. The sent data would have to be modified to take accounts into affect. There's probably other issues -- I'm not very familiar with the multiplayer code. We could then create some kind of scoring system. For example, create ranks (based on points) and give points for winning games using the score times some rank multiplier (so beating rank 1 players doesn't reward as many points as beating a rank 10 player). The configuration of the game (players versus AI, players versus players, etc) needs to be taken into account. It's not that important right now (that's the easy part).
Of course, this opens additional complexities for those who want competitive play (namely the ability to find similarly ranked players), but that's not a big concern, particularly since our community is too small to sustain such a type of play.
That leaves most of the development on the creation and management of user accounts. It seems that the main difficulty is sending scores to this ranking site without allowing just anyone to send the score. This again ties into the cheating issue and would depend on what part of the game is sending these scores. If a master server can send the scores, this is more ideal. We could maintain a list of trusted master servers that have keys that they use to encrypt the score and only properly encrypted scores would be accepted. It does limit the ability to play ranked games (have to use an approved master server), but there's just no getting around the fact that we cannot trust the client (and the open source nature of MG prevents us from placing any kind of key inside MG). Again, I'm not familiar with the multiplayer code and it totally depends on that (it may already be the case that the master server is the only part reporting finished games).
The creation of user accounts is actually fairly straightforward (especially if we use a library). The game would login by connecting to this ranking server. We'd get current rank from this server. At the end of the game, we'd send the points earned by the game to the ranking server (securing this was the topic of the previous paragraph). Players would be able to create accounts in the game. The difficulty here is preventing easy creation of multiple accounts and playing against these accounts. I don't think there's any real solution. It shouldn't be necessary to verify the account since we don't want to exit the game. Similarly, we don't want to use the IP in the account because the same IP may have different users (consider the case of Titi and his son using the same computer even though they'll certainly have different accounts).
User accounts can simply be a username - password pairing. There's no need for anything else at the time (although future features could expand on that). Although an
optional email for the purpose of allowing accounts to be recovered is a good idea (no email = no recovery option). We can allow unregistered players to also play in a similar fashion, and treat them as players of the lowest rank when creating the scores for other registered players. Alternatively, we could force players to register (more enticing for competitive players who want to be able to maximize their score by playing against similarly ranked players). I don't see any reason that anyone would want to avoid registering besides the very small registration time (there's no required personal information being stored).
So in summary, we'd need to- Create ranking server that stores rankings online and provides the means to communicate with this server to authorized master servers.
- Master server must have some private key to show that it is trustworthy.
- After completion of games, master server sends the score change for all registered players. Alternatively, master server sends the data it already sends but with account information and the play.mg site calculates scoring and ranking.
- Change in scoring depends on factors such as game configuration and other player's ranks. Ranks are simply obtained by getting certain scores (like how the ranks on this forum depend on posts).
The security of this is important to keep in mind, since if the system gets easily and uncontrollably gamed, then the entire ranking system becomes worthless.
Sample scoring system- Use score from games (and the game's scoring system can/should be adjusted to better reflect skill). I implicitly refer to this score from now on.
- Games against AI where there are no humans on the AI's team are divided by 2h where h is the number of humans played against the AI and multiplied by the number of AI and the multiplier of the AI. So 2 humans versus 2 AIs with a 1.5 multiplier (CPU-ultra) is a score multiplier of (2 AI * 1.5 multiplier) / 22 humans = 0.75.
- Games where the human has AI on their team are further divided by the multiplier of that AI plus one. The plus one is to prevent increasing the score when humans have weaker AI on their team. So stronger AI teammate = score penalty. This effect stacks. For example, if you have a two normal AIs on your team (1.0 multiplier), your score is divided by 2 twice, resulting in a score multiplier of 0.25.
- Teams get the average AI-on-your-team score penalty of all other teams + 1. So if the above example of a team with two normal AIs was playing against a different team with no AIs, then the team with no AIs gets the 0.25 plus 1 = 1.25.
- Games against humans are ultimately going to depend on how hard it is to get ranks, but something like multiplying by the difference in your ranks divided by the number of ranks plus one seems like a quick approach. Thus, it's beneficial to play against higher ranked players and worse to play against lower ranked players. For example, if a rank 2 player plays against a rank 5 player and there are 10 ranks, that player gets a score multiplier of (5 - 2) / 10 + 1 = 1.3. On the other hand, the rank 5 player gets (2 - 5) / 10 + 1 = 0.7.
- To handle the case of teams of humans versus teams of humans, we use the algorithm from the above point and apply it against all other players. For your team, we take the average of comparing you against players not on your team and divide that by the average of comparing you against other players on your team. So if your team average compared to you is 0.5 (implying that your teammates are a lower rank than you) and the averages of players not on your team compared to you is 1.5 (implying they're a higher rank than you), you'll get 1.5 / 0.5 = 3.
- To make up for mismatched team sizes, if one team has less players than any other team, they get an added bonus of 0.25 * team size difference. For example, if there's game of 3 on 1, the player who is on the solo team gets a bonus of 0.25 * 2 = 0.5 added to his score multiplier.
- And of course, most importantly, winning doubles your score multiplier. Losing halves it. So all else equal, winners get 4 times the points that losers get. Big benefit for winning, but not too bad for losers. To increase the dependence on the multipliers and game score, this difference could be increased.
Example game with this scoring:Player | Rank | Team | Game score |
---|
Alice | 2 | 1 | 10,000 |
Bob | 3 | 1 | 12,000 |
Carol | 4 | 2 | 20,000 |
AI (0.5 multiplier) | N/A | 2 | Doesn't matter |
Assume that Carol beat Alice and Bob. Assume there is 10 ranks.
Carol's score: Since Carol has an AI on her team, her score is divided by the AI multiplier + 1. So her score multiplier is now 0.66 (1/ (0.5 multiplier + 1)). The difference in her score from Alice is (2 - 4) / 10 + 1 = 0.8 and the difference in her score from Bob is (2 - 3) / 10 + 1 = 0.9. Average of this is 0.85. So now her cumulative score multiplier is 0.66 * 0.85 = 0.56. She won, so her multiplier is doubled, making it 1.12. She gets 1.12 * 20,000 = 22,400 rank points.
Alice's score: The difference in Alice's score from Bob is (3 - 2) / 10 + 1 = 1.1. The difference from Carol's score is (4 - 2) / 10 + 1 = 1.2. The average of players on her team is obviously 1.1 and the obvious of players not on her team is 1.2. We then divide the players not on her team by those on her team, 1.2 / 1.1 = 1.09. Alice's team doesn't have an AI. The AI penalty of the only other team was 0.66, so this team gets a multiplier of 1.66 making the cumulative score multiplier 1.09 * 1.66 = 1.81. Alice lost, so her multiplier is halved to 0.91. She gets 0.91 * 10,000 = 9,100 rank points.
Bob's calculation is similar, so won't be shown here.
Points to ponder- Good thing about a system like this is that fair games will result in getting the same number of rank points as the number of game points. Multipliers only come into play when the game is unbalanced (or when we play against the CPU, since the CPU is so brain dead).
- Lots of potential for cool features such as achievements, where performing certain tasks gets more points (pre-multiplier). This is very difficult because achievements feel like something that should be moddable, yet we'd need to be able to approve achievements to prevent people from creating mods that have easy to obtain achievements that give a ton of points. Alternatively, achievements would be mod-neutral and be dependent on things like killing multiple enemies in a short period of time, killing enemies with a variety of different attacks (ie, using a variance of attacks), or killing enemies with an effective attack type for the target's armor type.
- Rank size and number of points required to reach is is going to depend heavily on the kinds of scores players easily get. Eyeballing past games, it looks like around 20,000 points is common for winners of medium length games. Something like 20,000 * 1.5rank + 1 creates a nice curve for 10 ranks. That creates an achievable first rank for new players. First rank needs 60,000, which is only 2 wins for a good player in medium length games (recall that wins get double points), but more for a novice -- new players will probably have multipliers due to their low rank, though. Achieving the top rank (rank 10) needs 1,729,951 points (about 45 wins at 20,000 game points per win).
- However, having such small ranks would inflate the rank difference multipliers. Perhaps better to have fewer large ranks. Perhaps also increase the loss penalty so that you have to win to rank up (and thus must be a good player to get a higher rank).
- Perhaps size difference should use a multiplier and not add a percentage to our running multiplier.
- Penalty/bonus from having AI teammates seems too severe.