mmr

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	// K is the default K-Factor
	K = 32
	// D is the default deviation
	D = 400
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Elo

type Elo struct {
	K int
	D int
}

Elo calculates Elo rating changes based on the configured factors.

func NewElo

func NewElo() *Elo

NewElo instantiates the Elo object with default factors. Default K-Factor is 32 Default deviation is 400

func NewEloWithFactors

func NewEloWithFactors(k, d int) *Elo

NewEloWithFactors instantiates the Elo object with custom factor values.

func (*Elo) ExpectedScore

func (e *Elo) ExpectedScore(ratingA, ratingB int) float64

ExpectedScore gives the expected chance that the first player wins

func (*Elo) ExpectedScoreWithFactors

func (e *Elo) ExpectedScoreWithFactors(ratingA, ratingB, d int) float64

ExpectedScoreWithFactors overrides default factors and gives the expected chance that the first player wins

func (*Elo) Outcome

func (e *Elo) Outcome(ratingA, ratingB int, score float64) (Outcome, Outcome)

Outcome gives an Outcome object for each player for the given score

func (*Elo) OutcomeWithFactors

func (e *Elo) OutcomeWithFactors(ratingA, ratingB int, score float64, k, d int) (Outcome, Outcome)

OutcomeWithFactors overrides default factors and gives an Outcome object for each player for the given score

func (*Elo) Rating

func (e *Elo) Rating(ratingA, ratingB int, score float64) int

Rating gives the new rating for the first player for the given score

func (*Elo) RatingDelta

func (e *Elo) RatingDelta(ratingA, ratingB int, score float64) int

RatingDelta gives the ratings change for the first player for the given score

func (*Elo) RatingDeltaWithFactors

func (e *Elo) RatingDeltaWithFactors(ratingA, ratingB int, score float64, k, d int) int

RatingDeltaWithFactors overrides default factors and gives the ratings change for the first player for the given score

func (*Elo) RatingWithFactors

func (e *Elo) RatingWithFactors(ratingA, ratingB int, score float64, k, d int) int

RatingWithFactors overrides default factors and gives the new rating for the first player for the given score

type Outcome

type Outcome struct {
	Delta  int
	Rating int
}

Outcome is a match result data for a single player.

func (*Outcome) String

func (o *Outcome) String() string

Jump to

Keyboard shortcuts

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