Raised This Month: $51 Target: $400
 12% 

[Tutorial] ELO Ranking System in Pawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 07-23-2013 , 06:09   [Tutorial] ELO Ranking System in Pawn
Reply With Quote #1

ELO Ranking System in Pawn

Hello,
In this post I'll explain how to use the ELO Ranking System in Pawn.

So first, what's ELO?

Quote:
Originally Posted by Wikipedia
The Elo rating system is a method for calculating the relative skill levels of players in competitor-versus-competitor games such as chess.
It is named after its creator Arpad Elo, a Hungarian-born American physics professor.
So ELO is used to determine a players skill, this can be simply done using this formula :

PHP Code:
New ELO ELO ELO_K * ( ELO_SCORE_WIN LOSE E(XPECTATION)) 
ELO_K is maximum increase / decrease of Skill. You should use 15 for Beginner Matches and 25 for normal / professional matches. If you want more significant changes use about 50.

Quote:
Originally Posted by Christopher Allen & Shannon Appelcline
It's a good model because, using the two formulas, it means that a great player gains little from beating an average player, but an average player gains a lot from beating a great player.
To calculate E(xpectation), so what the system is expecting from the player based of his skill, we use this formula :

PHP Code:
E formula / [ 10 ^ ( [ELO ENEMY ELO OWN] / 400 ) ] 
Well, it's not very hard to transfer this formular into Pawn, it would look like this :

PHP Code:
E_P1 / ( 10 ^ (( g_iELO[P2] - g_iELO[P1] ) / 400 )) 
E_P2 / ( 10 ^ (( g_iELO[P1] - g_iELO[P2] ) / 400 )) 

g_iELO[P1] = floatround(g_iELO[P1] + ELO_K * ( ELO_SCORE_1ST E_P1), floatround_floor
g_iELO[P2] = floatround(g_iELO[P2] + ELO_K * ( ELO_SCORE_2ND E_P2), floatround_floor
But what is "ELO_SCORE_1ST"?

ELO_SCORE_1ST is the multiplier for the winner, with descending places the number gets smaller, here the numbers I use :

PHP Code:
#define ELO_SCORE_1ST     1.0 
#define ELO_SCORE_2ND     0.85 
#define ELO_SCORE_3RD     0.425 
#define ELO_SCORE_4TH     0.2125 
#define ELO_SCORE_5TH     0.10625 
#define ELO_SCORE_6TH     0.053125 
#define ELO_SCORE_7TH     0.0265625 
#define ELO_SCORE_8TH     0.01328125 
This code is for two players and would work fine, but what happens if we have more than two players?
The code wouldn't work with more than two players, because ELO is made for duels. So we have to find another way.
And finding this way isn't so hard. If you just get the base Idea of ELO, that it is made for duels, it's easy to add more players.

So, if we have three players, we have to think like this :

PHP Code:
A wins vs
B wins vs

So basically we add another duel between B and C in our code which would look like this :

PHP Code:
E_P1 / ( 10 ^ (( g_iELO[P2] - g_iELO[P1] ) / 400 )) 
E_P2 / ( 10 ^ (( g_iELO[P1] - g_iELO[P2] ) / 400 )) 
E_P3 / ( 10 ^ (( g_iELO[P2] - g_iELO[P3] ) / 400 )) 

g_iELO[P1] = floatround(g_iELO[P1] + ELO_K * ( ELO_SCORE_1ST E_P1), floatround_floor
g_iELO[P2] = floatround(g_iELO[P2] + ELO_K * ( ELO_SCORE_2ND E_P2), floatround_floor
g_iELO[P3] = floatround(g_iELO[P3] + ELO_K * ( ELO_SCORE_3RD E_P3), floatround_floor
You can advance it however you like, for my Bunnyhop Racers Plugin I use it for up to eight players.

PHP Code:
new szHUD1[64], szHUD2[64], szHUD3[64], szHUD4[64], szHUD5[64], szHUD6[64], szHUD7[64], szHUD8[64]

new 
Pri g_PartyData[id2][FIRST]
new 
Sec g_PartyData[id2][SECOND]
new 
Tri g_PartyData[id2][THIRD]
new 
Qua g_PartyData[id2][FOURTH]
new 
Qui g_PartyData[id2][FIFTH]
new 
Sen g_PartyData[id2][SIXTH]
new 
Sep g_PartyData[id2][SEVENTH]
new 
Oct g_PartyData[id2][EIGHTH]
    
new 
E_P1E_P2E_P3E_P4E_P5E_P6E_P7E_P8

static iOELO1iOELO2iOELO3iOELO4iOELO5iOELO6iOELO7iOELO8
static szName1[33], szName2[33], szName3[33], szName4[33], szName5[33], szName6[33], szName7[33], szName8[33]
    
E_P1 / ( 10 ^ (( g_iELO[Sec] - g_iELO[Pri] ) / 400 ))
E_P2 / ( 10 ^ (( g_iELO[Pri] - g_iELO[Sec] ) / 400 ))
E_P3 / ( 10 ^ (( g_iELO[Sec] - g_iELO[Tri] ) / 400 ))
E_P4 / ( 10 ^ (( g_iELO[Tri] - g_iELO[Qua] ) / 400 ))
E_P5 / ( 10 ^ (( g_iELO[Qua] - g_iELO[Qui] ) / 400 ))
E_P6 / ( 10 ^ (( g_iELO[Qui] - g_iELO[Sen] ) / 400 ))
E_P7 / ( 10 ^ (( g_iELO[Sen] - g_iELO[Sep] ) / 400 ))
E_P8 / ( 10 ^ (( g_iELO[Sep] - g_iELO[Oct] ) / 400 ))

get_user_name(PriszName1charsmax(szName1))
get_user_name(SecszName2charsmax(szName2))
get_user_name(TriszName3charsmax(szName3))
get_user_name(QuaszName4charsmax(szName4))
get_user_name(QuiszName5charsmax(szName5))
get_user_name(SenszName6charsmax(szName6))
get_user_name(SepszName7charsmax(szName7))
get_user_name(OctszName8charsmax(szName8))
    
g_iELO[Pri] = floatround(g_iELO[Pri] + ELO_K * ( ELO_SCORE_1ST E_P1), floatround_floor)
g_iELO[Sec] = floatround(g_iELO[Sec] + ELO_K * ( ELO_SCORE_2ND E_P2), floatround_floor)
g_iELO[Tri] = floatround(g_iELO[Tri] + ELO_K * ( ELO_SCORE_3RD E_P3), floatround_floor)
g_iELO[Qua] = floatround(g_iELO[Qua] + ELO_K * ( ELO_SCORE_4TH E_P4), floatround_floor)
g_iELO[Qui] = floatround(g_iELO[Qui] + ELO_K * ( ELO_SCORE_5TH E_P5), floatround_floor)
g_iELO[Sen] = floatround(g_iELO[Sen] + ELO_K * ( ELO_SCORE_6TH E_P6), floatround_floor)
g_iELO[Sep] = floatround(g_iELO[Sep] + ELO_K * ( ELO_SCORE_7TH E_P7), floatround_floor)
g_iELO[Oct] = floatround(g_iELO[Oct] + ELO_K * ( ELO_SCORE_8TH E_P8), floatround_floor)

formatex(szHUD1charsmax(szHUD1), "%s --- %i --- %s%i --- %i ^n",szName1iOELO1iOELO1 g_iELO[Pri] < "-" "+"iOELO1 g_iELO[Pri], g_iELO[Pri])
formatex(szHUD2charsmax(szHUD2), "%s --- %i --- %s%i --- %i ^n",szName2iOELO2iOELO2 g_iELO[Sec] < "-" "+"iOELO2 g_iELO[Sec], g_iELO[Sec])
formatex(szHUD3charsmax(szHUD3), "%s --- %i --- %s%i --- %i ^n",szName3iOELO3iOELO3 g_iELO[Tri] < "-" "+"iOELO3 g_iELO[Tri], g_iELO[Tri])
formatex(szHUD4charsmax(szHUD4), "%s --- %i --- %s%i --- %i ^n",szName4iOELO4iOELO4 g_iELO[Qua] < "-" "+"iOELO4 g_iELO[Qua], g_iELO[Qua])
formatex(szHUD5charsmax(szHUD5), "%s --- %i --- %s%i --- %i ^n",szName5iOELO5iOELO5 g_iELO[Qui] < "-" "+"iOELO5 g_iELO[Qui], g_iELO[Qui])
formatex(szHUD6charsmax(szHUD6), "%s --- %i --- %s%i --- %i ^n",szName6iOELO6iOELO6 g_iELO[Sen] < "-" "+"iOELO6 g_iELO[Sen], g_iELO[Sen])
formatex(szHUD7charsmax(szHUD7), "%s --- %i --- %s%i --- %i ^n",szName7iOELO7iOELO7 g_iELO[Sep] < "-" "+"iOELO7 g_iELO[Sep], g_iELO[Sep])
formatex(szHUD8charsmax(szHUD8), "%s --- %i --- %s%i --- %i ^n",szName8iOELO8iOELO8 g_iELO[Oct] < "-" "+"iOELO8 g_iELO[Oct], g_iELO[Oct])

add(szELOHUDcharsmax(szELOHUD), szHUD1)
add(szELOHUDcharsmax(szELOHUD), szHUD2)
add(szELOHUDcharsmax(szELOHUD), szHUD3)
add(szELOHUDcharsmax(szELOHUD), szHUD4)
add(szELOHUDcharsmax(szELOHUD), szHUD5)
add(szELOHUDcharsmax(szELOHUD), szHUD6)
add(szELOHUDcharsmax(szELOHUD), szHUD7)
add(szELOHUDcharsmax(szELOHUD), szHUD8
I hope some people can use this.

You may also use my Calculator to generate test results.
__________________

Last edited by Kia; 07-23-2013 at 06:19.
Kia is offline
Garey
Member
Join Date: Feb 2008
Location: Russian Federation
Old 07-23-2013 , 08:33   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #2

Is this work if we need to calculate Player A+Player B+Player C vs Player D+Player E+Player F ? like pug or something?
__________________
Sorry for my bad english
Garey is offline
Send a message via ICQ to Garey
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 07-23-2013 , 08:38   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #3

In this case you need to see the whole teams ELO's as one big ELO and calculate against the opponent team.
__________________
Kia is offline
Garey
Member
Join Date: Feb 2008
Location: Russian Federation
Old 07-23-2013 , 09:16   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #4

So then add to tutorial this case..
I think its should to be like this:
First we need to get sum pts of all team:
PHP Code:
for( new 1<= g_iMaxPlayersi++ )
    {
        if( 
is_user_connected) )
        {
            if(
get_user_team) == 1)
                
ePts[0]+= power(10.0,(iPts[i]/400.0))
            else if(
get_user_team) == 2)
                
ePts[1]+= power(10.0,(iPts[i]/400.0))
        }
    } 
then make same as for 2 players:
PHP Code:
 if( is_user_connected) )
        {
            if(
get_user_team) == 1)
            {
                
ePlrPts[i] = power(10,(iPts[i]/400.0))/ePts[1]
            }
            else if(
get_user_team) == 2)
            {
                
ePlrPts[i] = power(10,(iPts[i]/400.0))/ePts[0]
            }
            
            
// You need to detect when round(match) is draw
            
if(draw)
            {
                
iTotalPlrPts[i] = iPts[i]+15.0*(0.5-ePlrPts[i])
                
            }
            
// Also turn bool to each player when he won
            
else if(PlayerWin[i])
            {
                
iTotalPlrPts[i] = iPts[i]+15.0*(1-ePlrPts[i])
            }
            
// Or lose
            
else
            {
                
iTotalPlrPts[i] = iPts[i]+15.0*(0-ePlrPts[i])
            }
            
// Round result, then work with this value
            
new roundedpts floatround(iTotalPlrPts[i] , floatround_round)        

__________________
Sorry for my bad english
Garey is offline
Send a message via ICQ to Garey
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 07-23-2013 , 10:35   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #5

Will be edited when I'm at home.
__________________
Kia is offline
Old 07-24-2013, 01:10
LordOfNothing
This message has been deleted by ConnorMcLeod. Reason: troll, or posting random confusing code, or posting for posts count
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 07-24-2013 , 02:05   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #6

Quote:
Originally Posted by LordOfNothing
I don't can't.
That's a double negative, so what now?

This is just for understanding how ELO can be used in Pawn.
__________________
Kia is offline
MPD
Member
Join Date: May 2013
Location: Lithuania
Old 07-24-2013 , 04:53   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #7

Well, it's still hard to understand this for me, but I hope that after few more reading I will understand this. Still, great tutorial, never knew that this type of ranking system exists.
MPD is offline
Send a message via Skype™ to MPD
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 07-24-2013 , 05:00   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #8

It's used in Chess, but also in Games like World of Warcraft or League of Legends.
__________________
Kia is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-24-2013 , 10:35   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #9

Quote:
Originally Posted by Kia View Post
It's used in Chess, but also in Games like World of Warcraft or League of Legends.
Not only this, its used to calculate a skill in any game its used Player vs Player

And this formula can be used in different games


__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 07-24-2013 , 10:44   Re: [Tutorial] ELO Ranking System in Pawn
Reply With Quote #10

I was only giving examples. :p
__________________
Kia is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode