I did this small project on a summer weekend in 2015. I just saw the movie “the Social Network” where Marc had this idea of rating girls using an algorithm called ELO which is actually used for rating chess players based on their wins and losses against other players.
Personally, I think rating girls is disgusting. But rating Bananas and Apples is fine. An I’m more interested in the theory and the Algorithm itself. So I thought, hm, how hard could it be to implement a system like this – turns out: not that hard.
Short theory of the ELO algorithm:
The ELO Algorithm is a very simple, but effective rating algorithm. Assume that we are in the world of fantasy curling players. Naturally there are good players out there with a high reputation and a high chance of winning, and not-so-good players wich are less likely to win a game against the big fishes. Let’s also assume you are a medium level player with a ELO number of 30. The best player has a ELO number of 70. Today is the big day and you will play a match against Player 2 with a rating number of 61. The rank list right now looks like this:
- Player 1: 70
- Player 2: 61
- Player 3: 32
- You: 30
- Player 5: 10
- Player 6: 2
According to the rules of fantasy curling, there has to be a winner and a looser – a remi is not allowed. At the end of the day, you either won or lost. The outcome of the match will affect both players ELO ratings. The more unlikely the win is, the more impact on the overall rating table this match will have. Let’s have a look at both possibilities.
Option 1 – You will loose
To calculate the new ElO ratings, you have to understand how the Algorithm works. You only need to calculate the expected point difference of one player, because of the simple fact that
R_A and R_B are the current “pre-match” ELO ratings of Player A and Player B.
E_A is a value between 1 and 0. The 400 you see here is a historic value chosen by a guy named Arpad Elo and is since used for the chess rating system. Surprisingly, fantasy curling uses the same value ;-). But feel free to modify it.
So you lost against Player 2 with a rating of 61, which leads to the E_A value for you of 0.4555054269169921. (This is close to 0.5 wich would mean that the parameter 400 is not idea, but works for our example. I would suggest choosing a smaller value if you working with ELO ratings that close to each other.) According to the rule, your opponent has an E_B of 0.544494573083008.
How does that value generate the new ELO rating?
This is actually even simpler:
Your new ELO number will be your current rating (30) plus a factor k (assumed 10) multiplied by the difference of the S_A value (0 , because you lost, 1 otherwise, 0.5 for a draw, which does not exist here) and your just calculated E_B value: 25.444945730830078.
Player 2 now has a new ELO number of 65.55505426916991.
The k factor defines the impact of the match on the game. The higher the k is, the more impact it has. You can also fine-tune here.
Option 2 – You win:
for the unlikely case of a win against one of the leaders of the list, we will result in the following ELO numbers:
Player 2: 55.55505426916992
You : 34.55505426916992
The impact of the match on the table is defined by the constants k, the constant value 400 and the point difference of the opponents (which is variable). The whole systems is based on the simple assumption that games between a higher rated player and a low rated player are more important and have a greater impact on the result. This allows new players wich usually start with an average value to climb up the ladder very fast.
Facemash
Similar to our example, Facemash also some kind of system with rounds where 2 opponents can either win or loose a match. Every element starts with a basic value of 2500 rating points. As a user, you now decide who wins the round and the ELO algorithm decides the new value.
Matchmaking is implemented to be random.
It’s a very simple way to get elements in some kind of order. I was actually surprised how well it works.
The face mash clone is written in Python and uses Flask as underlaying framework.
Check out the project on my GitHub – it’s open source.