goglicko

package module
v0.0.0-...-a753c9c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2015 License: MIT Imports: 2 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go-Glicko

A Glicko2 Implementation in Go (golang)

To install, all you should need is

go get github.com/Kashomon/goglicko

Usage

To install:

go get github.com/Kashomon/goglicko

To use GoGlicko:

import (
  github.com/Kashomon/goglicko
)

func Rate() {
  player := DefaultRating()

  opponents := []*Rating{
    NewRating(1400, 30, DefaultVol),
    NewRating(1550, 100, DefaultVol),
    NewRating(1700, 300, DefaultVol),
  }

  results := []Result{1, 0, 0}

  newRating := CalculateRating(p, o, res)
}

Speed

For the simple example above, the algorithm is quite quick:

Benchmarks:
  BenchmarkSimpleExample	 1000000	      1089 ns/op

So roughly 1μs/call. Thus, we can expect that 1,000,000 such ratings should take about a second.

Documentation

Overview

Implementation of the Glicko 2 Rating system, for rating players. Glicko is an improvoment on ELO, but is much more computationally intensive.

For more information, see:

http://www.glicko.net/glicko/glicko2.pdf

http://en.wikipedia.org/wiki/Glicko_rating_system

The calculation process is broken into 8 steps.

Step 1: Determine initial values.

Step 2: Convert to Glicko2 Scale from the Glicko1 scale.

Step 3: Compute (v), the estimated variance based only on game outcomes.

Step 4: Compute the quantity Delta, the estimated improvement.

Step 5: Determine the new value, sigma', of the volatility, in an iterative process.

Step 6: Update the rating deviation to the new pre-rating period value, φ_z

Step 7: Update the rating and RD to the new values, μ′ and φ′:

Step 8: Convert back to the Glicko1 scale.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Constrains the volatility. Typically set between 0.3 and 1.2.  Often
	// refered to as the 'system' constant.
	DefaultTau = 0.3

	DefaultRat = 1500.0 // Default starting rating
	DefaultDev = 350.0  // Default starting deviation
	DefaultVol = 0.06   // Default starting volatility
)

Overrideable Defaults

Functions

This section is empty.

Types

type Rating

type Rating struct {
	Rating     float64 // Player's rating. Usually starts off at 1500.
	Deviation  float64 // Confidence/uncertainty in a player's rating
	Volatility float64 // Measures erratic performances
}

Represents a player's rating and the confidence in a player's rating.

func CalculateRating

func CalculateRating(player *Rating, opponents []*Rating, res []Result) (*Rating, error)

func DefaultRating

func DefaultRating() *Rating

Creates a default Rating using:

Rating     = DefaultRat
Deviation  = DefaultDev
Volatility = DefaultVol

func NewRating

func NewRating(r, rd, s float64) *Rating

Creates a new custom Rating.

func (*Rating) Copy

func (r *Rating) Copy() *Rating

Create a duplicate rating with the same values.

func (*Rating) FromGlicko2

func (r *Rating) FromGlicko2() *Rating

Creates a new rating, converted from Glicko2 scaling to Glicko1 scaling. This assumes the starting rating value is 1500.

func (*Rating) MostlyEquals

func (r *Rating) MostlyEquals(o *Rating, epsilon float64) bool

Ensure that some other Rating is equal to this rating, given some epsilon. In other words, find the error between this rating's values and the other rating's values and make sure it's less than epsilon in absolute value.

func (*Rating) String

func (r *Rating) String() string

func (*Rating) ToGlicko2

func (r *Rating) ToGlicko2() *Rating

Creates a new rating, converted from Glicko1 scaling to Glicko2 scaling. This assumes the starting rating value is 1500.

type Result

type Result float64

Used to indicate who won/lost/tied the game.

const (
	Win  Result = 1
	Loss Result = 0
	Draw Result = 0.5
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL