d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Working With Elo
Add Reply New Topic New Poll
Member
Posts: 4,905
Joined: Feb 19 2012
Gold: 0.00
Sep 24 2017 06:07pm
Hey.. so I'm working on a small project that I need to build an Elo system into...


So I have a DB and each player has a rating assigned to them.

When inputting results of a match I need to adjust their rating accordingly.

The layout is as follows.

1: GUI Opens
2: SQL Select statement to grab all players names/rating
3: User selects the winner
4: User selects the loser (Cannot be done until a winner is selected)
5: SQL statement is fired to grab winners rating
6: SQL statement is fired to grab losers rating
7: Do Elo calculations
8: Spit out each players adjusted rating.


So I have 1-6 done, just need to figure out how to express their adjusted ratings.

I'm doing this in VB.net but the language doesn't matter since its just arithmetic's and can be used in all languages.

For the purpose of this example assume:

WinningPlayersRating = "1500"
LossingPlayersRating = "1300"

And hopefully once I see this expression I can figure out the following

WinningPlayersRating = "1500"
LossingPlayersRating = "1600"

And

WinningPlayersRating = "1500"
LossingPlayersRating = "1500"

Thanks for the help!
Member
Posts: 1,039
Joined: Jul 8 2008
Gold: 1,939.50
Sep 24 2017 06:13pm
Edit: Stupid me I was thinking of 'elo' as defined by numerous video games that isn't actually 'elo' as defined by this wiki page: https://en.wikipedia.org/wiki/Elo_rating_system
Do you wish to implement that algorithm? Here is some source code that does it in java (you should be able to read it if you are writing VB) https://github.com/radoneman/elo-rating-multiplayer/blob/master/src/com/elo/EloRating.java

This post was edited by waraholic on Sep 24 2017 06:28pm
Member
Posts: 4,905
Joined: Feb 19 2012
Gold: 0.00
Sep 24 2017 07:10pm
Hey, thanks for the input. I went from that to

https://dataskeptic.com/blog/methods/2017/calculating-an-elo-rating

Which broke it down very well for me :D

Code

Dim Rating1 = 2853
Dim Rating2 = 2400
Dim ExpectedRating1 As Decimal
Dim ExpectedRating2 As Decimal

Dim Calc1 As Decimal
Dim Calc2 As Decimal

Calc1 = 10 ^ (Rating1 / 400)
Calc2 = 10 ^ (Rating2 / 400)

Calc1 = Math.Round(Calc1, 5)
Calc2 = Math.Round(Calc2, 5)

ExpectedRating1 = Calc1 / (Calc1 + Calc2)
ExpectedRating2 = Calc2 / (Calc2 + Calc1)

ExpectedRating1 = Math.Round(ExpectedRating1, 5)
ExpectedRating2 = Math.Round(ExpectedRating2, 5)

Calc1 = Rating1 + 40 * (1 - ExpectedRating1)
Calc1 = Math.Round(Calc1)
Calc2 = Rating2 + 40 * (0 - ExpectedRating2)
Calc2 = Math.Round(Calc2)

Dim Final As String
Dim Final2 As String


Final = Calc1
Final2 = Calc2

MessageBox.Show(Final + vbNewLine + Final2)


So thus

PlayerA's new rating = 2,856
PlayerB's new rating = 2,397

:)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll