Find out how HackerEarth can boost your tech recruiting

Learn more
piller_image

Elo rating system: Common link between Facemash and chess!

Elo rating system, Elo rating, elo rating algorithm, elo rating for chess, facebook algorithm, facemash algorithm

 

Remember the scene from the Facebook movie,  The Social Network where Mark Zuckerberg, while creating “Facemash” (the earlier version of Facebook), tells Eduardo Saverin, “I need the algorithm you used to rank chess players” who then writes an equation on the glass panel?

 

That equation is called the Elo rating or Elo rating system, named after its creator Arpad Elo. This rating system is used to rate the skills of the players in competitor-versus-competitor games like chess, football, baseball, and American football.

Elo believed in the following:

  1. Performance of each player in a game is a normal distribution of random variables
  2. The mean value of players irrespective of their performance in an individual game increases slowly.

Initially invented as a rating system for chess players, Elo is now used as a fundamental rating system in most video games, snooker, scrabble, etc.

Elo rating system explained –

This system is used to determine the output of a game by using a player’s Elo rating. It is all based on probability. Players with a higher Elo rating have a higher probability of winning a game than players with a lower Elo rating.

After the game, the winner takes points from the loser, thereby increasing his rating.

If a high-rated player wins, only a few points will be transferred from the lower rated player. However, if the lower rated player pulls off an upset win, then the number of points that are taken by the player with the lower rating is far greater. (Sounds unfair, doesn’t it?)

 

Elo rating system equation explanation –

Let’s take a look at the Elo rating equation. 

Elo rating, elo rating algorithm, elo rating for chess, facebook algorithm, facemash algorithm, Elo rating system

Elo rating, elo rating algorithm, elo rating for chess, facebook algorithm, facemash algorithm, Elo rating system

calc = (1.0 / (1.0 + pow(10, ((rating_2 – rating_1) / 400))));

In this equation, RA and RB stand for the current Elo ratings of a player.

In real-world competitive gaming, a player has a probability of winning, losing, and drawing a match. So when a player has a score of 0.64, the probability of winning, losing, and drawing is 64%, 26%, and 0%, respectively.

After the match, if a player’s match score exceeds his predicted score, then the player’s Elo rating is updated. Similarly, when a player’s match score falls short of the expected score, then the player’s rating is adjusted downward.

Assume that a player is required to score EA during a tournament but scores SA, then the player’s rating is updated by using the following formula:

Elo rating, elo rating algorithm, elo rating for chess, facebook algorithm, facemash algorithm, Elo rating system

calc = (rating + kfactor * (actual – expected));

K is known as “K factor”. It is a measure of how strongly a match will influence a player rating. If  K is of a lower value, then the rating is changed by a small fraction but if  K is of a higher value, then the changes in the rating are significant. Different organizations use different K factors; there is no universal value defined for it.

Pseudo code for the Elo rating system

import math;
class elo_core:
def getExpectation(rating_1, rating_2):
calc = (1.0 / (1.0 + pow(10, ((rating_2 – rating_1) / 400))));
return calc;
def modifyRating(rating, expected, actual, kfactor):
calc = (rating + kfactor * (actual – expected));
return calc;

Elo rating system example – 

Assume that Garry Kasparov has a rating of 2500 and Vishwanathan Anand has a rating of 2200.

Their expected scores are:

  • If Garry Kasparov (wins) = 1/1+10 to the power (2200 ? 2500)/400 = 0.849
  • If Vishwanathan Anand (wins) = 1/1 +10 to the power (2500 ? 2200)/400 = 0.151

Now believe that the Federation has decided that the value of K is 24.

The new ratings of the players are as follows:

If Garry Kasparov wins

  • Garry Kasparov = 2500 + 24 (1 ? 0.849) = 2503
  • Vishwanathan Anand = 2200 + 24 (0 ? 0.151) = 2196

If Vishwanathan Anand wins

  • Garry Kasparov = 2500 + 24 (0 ? 0.849) = 2479
  • Vishwanathan Anand = 2200 + 24 (1+ 0.151) = 2220

Since Garry Kasparov (with a better rating) is the favorite,  his win did not change the rating drastically. However, if the underdog, who in this case is Vishwanathan Anand wins, the ratings change drastically.

This is why in a cricket series between India and Zimbabwe, when Zimbabwe (with a lower rating) beats India, its rating changes quickly and it moves up the table. However, if India wins there is hardly any change in its ranking (Though ICC uses a modified version of Elo rating with some minor changes, the basic algorithm remains the same). 

Using the same Algorithm, Facemash assigned a specific rating to each individual. This rating increased with each favored click. 

Every girl on the Facemash database was assigned a specific base point.

When a user rated one girl based on her attractiveness in comparison to another, the rating of the selected girl increased while that of the other girl decreased. The number of users that rated a certain girl as attractive, the higher her ranking. Better the ranking, higher the possibility of being the most attractive girl on campus.

The Elo rating algorithm for a rating is used in almost every sports event either in its basic format or with some modifications. Now you know the algorithm which rates football players like Messi and Ronaldo in comparison to others, or how a player in a video game like Mortal Kombat or Tekken can get a higher rating than others.

It’s time you create your own Facemash or a rating-based video game. Practice your coding skills by solving HackerEarth’s challenges, which use the Elo algorithm.

If you want to read about more such amazing algorithms subscribe to our blog.

 

 

Hackerearth Subscribe

Get advanced recruiting insights delivered every month

Related reads

Best Interview Questions For Assessing Tech Culture Fit in 2024
Best Interview Questions For Assessing Tech Culture Fit in 2024

Best Interview Questions For Assessing Tech Culture Fit in 2024

Finding the right talent goes beyond technical skills and experience. Culture fit plays a crucial role in building successful teams and fostering long-term…

Best Hiring Platforms in 2024: Guide for All Recruiters
Best Hiring Platforms in 2024: Guide for All Recruiters

Best Hiring Platforms in 2024: Guide for All Recruiters

Looking to onboard a recruiting platform for your hiring needs/ This in-depth guide will teach you how to compare and evaluate hiring platforms…

Best Assessment Software in 2024 for Tech Recruiting
Best Assessment Software in 2024 for Tech Recruiting

Best Assessment Software in 2024 for Tech Recruiting

Assessment software has come a long way from its humble beginnings. In education, these tools are breaking down geographical barriers, enabling remote testing…

Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review
Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review

Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review

With a globalized workforce and the rise of remote work models, video interviews enable efficient and flexible candidate screening and evaluation. Video interviews…

8 Top Tech Skills to Hire For in 2024
8 Top Tech Skills to Hire For in 2024

8 Top Tech Skills to Hire For in 2024

Hiring is hard — no doubt. Identifying the top technical skills that you should hire for is even harder. But we’ve got your…

How HackerEarth and Olibr are Reshaping Tech Talent Discovery
How HackerEarth and Olibr are Reshaping Tech Talent Discovery

How HackerEarth and Olibr are Reshaping Tech Talent Discovery

In the fast-paced tech world, finding the right talent is paramount. For years, HackerEarth has empowered tech recruiters to identify top talent through…

Hackerearth Subscribe

Get advanced recruiting insights delivered every month

View More

Top Products

Hackathons

Engage global developers through innovation

Hackerearth Hackathons Learn more

Assessments

AI-driven advanced coding assessments

Hackerearth Assessments Learn more

FaceCode

Real-time code editor for effective coding interviews

Hackerearth FaceCode Learn more

L & D

Tailored learning paths for continuous assessments

Hackerearth Learning and Development Learn more