Giter Site home page Giter Site logo

elo's Introduction

Elo

The Elo Rating System is a widely used method for calculating the relative skill levels of players in two-player games such as chess, go, and various sports competitions. This Go package provides essential functions and structs for implementing the Elo Rating System in your application.

Installation

You can install the elo package using Go modules. Open your terminal and run the following command:

go get github.com/watson-sam/elo

Usage

Here's how you can use the elo package in your Go application:

package main

import (
	"fmt"
	"github.com/watson-sam/elo"
)

func main() {
	// Create Elo settings with custom parameters
    settings := elo.New(
        elo.WithKFactor(32),
        elo.WithInitRating(10),
        elo.WithExpectedFunct(elo.ExpProbability), // Use a custom expected function (optional)
		elo.WithObservedFunct(elo.ObsWinLooseDraw), // Use a custom observed function (optional)
    )

	// Initial ratings for two players
	playerA := settings.NewRating()
	playerB := settings.NewRating()

	// Simulate a match result
	scoreA := 1.0 // Adjust this based on the actual match result
	scoreB := 0.0 // Adjust this based on the actual match result

	// Calculate updated ratings
	newRatingA := settings.UpdateRating(playerA, playerB, scoreA, scoreB)
	newRatingB := settings.UpdateRating(playerB, playerA, scoreB, scoreA)

	fmt.Printf("Player A's new rating: %.2f\n", newRatingA)
	fmt.Printf("Player B's new rating: %.2f\n", newRatingB)
}

This example demonstrates how to create Elo settings with custom parameters and use them to calculate updated ratings after a match. You can customize the package's behavior by adjusting the settings and using different update, expected, and observed functions.

Contributing

If you'd like to contribute to this package or report issues, please visit the GitHub repository.

License

This Elo Rating System Package is open-source software licensed under the MIT License.

elo's People

Contributors

watson-sam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.