Jump to content

Recommended Posts

Hi,  I adapted http://www.glicko.net/glicko/glicko.pdf to apply to raitings bot.

import math

# Rating deviation extrema
RDmax = 140
RDmin = 40

# Linear mapping
GPthr = 100		# games played threshold
m = float(GPthr) / (RDmin - RDmax)		# slope

# Simple Glicko without rating deviation aging
def get_rating_adjustment2(rating, opponent_rating, games_played, opponent_games_played, result):
	r = rating
	rj = opponent_rating
	sj = (result + 1) / 2	# outcome

	# Linear mapping of games played to rating deviation
	# instead of RD = min(math.sqrt(RD_{old}^2 + c^2), 350)
	RD = RDmin if games_played > GPthr else m * games_played + RDmax
	RDj = RDmin if opponent_games_played > GPthr else m * opponent_games_played + RDmax

	# Rating delta
	q = math.log(10) / 400
	gj = 1 / math.sqrt(1 + 3 * math.pow(q * RDj / math.pi, 2))
	Ej = 1 / (1 + math.pow(10, gj * (rj - r) / 400))
	d2 = 1 / (math.pow(q * gj, 2) * Ej * (1 - Ej))
	value = 1 / RD / RD + 1 / d2
	# RDnew = math.sqrt(1 / value)	# not used for now
	return round(q * gj * (sj - Ej) / value)

It has 3 parameters that control how much a player gains or loses depending on its experience.
The rating deviation (RD) is like the standard deviation and states the certainty of a player's rating and determines how much a result influences rating.
To fit current code, I modified the algorithm to linearly assign RD \in [RDmax, RDmin] according to games played \in [0, GPthr]
and RDmin if games played > GPthr
With RDmax = 140 so inexperienced players dont jump too much, RDmin = 40 so experienced players can still slowly increase rating, and arbitrarily setting maximum experience with GPthr = 100 games played, we can test with

from random import choice, seed, randint
r1,r2 = 2100, 1200
seed()
for x in range(GPthr+10):
  print(r1, r2)
  res = choice([-1, 1])
  #r1 += get_rating_adjustment(r1, randint(1100, 2100), GPthr+x, randint(0, GPthr), 1)
  r1 += get_rating_adjustment2(r1, r2, GPthr+x, 0+x, res)
  r2 += get_rating_adjustment2(r2, r1, 0+x, GPthr+x, -res)
print(r1, r2)

Test 1: expert player like borg vs new player, 110 games with 50-50% wins

b.png.5d456c7f914cc2e2ec4f8b4d0b9474c4.pnga.png.70b4a6ee757efbfed76adc3014207402.png

You can see how with Glicko the expert is not greatly affected but possible smurfs.

Test 2: Average fully experienced player always winning vs all kinds of players

c.png.2651eee919fa1e2a47877efae039304a.pngd.png.01cbd719b6a9aa33bcba400243fc8e46.png

The original rating was pretty certain but RDmin gives chance for improvement, quite slowly.

Fics uses a variation of the algorithm: http://www.freechess.org/Help/HelpFiles/glicko.html

Edited by mapkoc
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×