glicko2_test.gno
0.96 Kb · 29 lines
1package glicko2
2
3import (
4 "testing"
5)
6
7func TestExampleCalculations(t *testing.T) {
8 // These are from the example in prof. Glickman's paper.
9 // At the end, t.Log should print for the first player updated values
10 // for Rating, RatingDeviation and RatingVolatility matching those in the
11 // examples.
12 ratings := []*PlayerRating{
13 {ID: "1", Rating: 1500, RatingDeviation: 200, RatingVolatility: 0.06},
14 {ID: "2", Rating: 1400, RatingDeviation: 30, RatingVolatility: 0.06},
15 {ID: "3", Rating: 1550, RatingDeviation: 100, RatingVolatility: 0.06},
16 {ID: "4", Rating: 1700, RatingDeviation: 300, RatingVolatility: 0.06},
17 }
18 scores := []RatingScore{
19 {White: "1", Black: "2", Score: 1},
20 {White: "1", Black: "3", Score: 0},
21 {White: "1", Black: "4", Score: 0},
22 }
23 UpdateRatings(ratings, scores)
24 r := ratings[0]
25 t.Logf("%.4f (± %.4f, volatility: %.4f); working values: %.2f / %.2f / %.2f\n",
26 r.Rating, r.RatingDeviation, r.RatingVolatility,
27 r.wr, r.wrd, r.wrv,
28 )
29}