Skip to content

This is the Go implementation of Gliko-2 Rating

License

Notifications You must be signed in to change notification settings

mashiike/rating

Repository files navigation

rating

GoDoc Go Report Card Test

Usage: basic

This is the Go implementation of Gliko2 Rating In a simple use case we use as follows

Import the package

import "github.com/mashiike/rating"

Batch by Rating Period.

At the end of each rating period, it reflects the results of the game played in that period.

player := rating.New(1500.0, 200.0, 0.06)
opponents := []rating.Rating{
	rating.New(1400.0, 30.0, 0.06),
	rating.New(1550.0, 100.0, 0.06),
	rating.New(1700.0, 300.0, 0.06),
}
scores := []float64{
	rating.ScoreWin,
	rating.ScoreLose,
	rating.ScoreLose,
}
updated, _ := player.Update(opponents, scores, 0.5)

Sequentially for each game

Use Esteminated struct as follows. Then save the information in a database or file system etc.

player := rating.New(1500.0, 200.0, 0.06)
e := rating.NewEstimated(r)
opponent := rating.New(1400.0, 30.0, 0.06)
err := e.ApplyMatch(opponent, rating.ScoreWin)
//when the rating period is over
err = e.Fix(0.5)
updated := e.Fixed

Usage: use rating util GoDoc

svc := ratingutil.New(ratingutil.NewConfig())
team1 := svc.NewTeam(
	"bovidae",
	ratingutil.Players{
		svc.NewPlayer(
			"sheep",
			rating.New(1700.0, 50.0, svc.Config.InitialVolatility()),
			svc.Config.Now(),
		),
		svc.NewDefaultPlayer("goat"),
	},
)
team2 := svc.NewTeam(
	"equidae",
	ratingutil.Players{
		svc.NewPlayer(
			"donkey",
			rating.New(1400.0, 50.0, svc.Config.InitialVolatility()),
			svc.Config.Now(),
		),
		svc.NewDefaultPlayer("zebra"),
	},
)
match, _ := svc.NewMatch(team1, team2)
match.Add(team1, 1.0)
match.Add(team2, 0.0)
err := svc.Apply(match)

About

This is the Go implementation of Gliko-2 Rating

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages