GithubHelp home page GithubHelp logo

elo.js's Introduction

Overview

Minimalistic Javascript implementation of a Elo rating system. K-factor of 32 is used.

How to use

  1. Include elo.js
  2. Use Elo.getNewRating() to calculate the new rating, or Elo.getRatingDelta() to calculate the delta.

Methods

getNewRating(myRating, opponentRating, myGameResult)

Calculates my new rating given the following parameters:

  • myRating (number) - My rating before the game, e.g. 1600
  • opponentRating (number) - Opponent's rating before the game, e.g. 1700
  • myGameResult (number) - The result of the game, 1 if I won, 0 if I lost, or 0.5 if draw
Example
Elo.getNewRating(1600, 1700, 1)     // => 1620
Elo.getNewRating(1600, 1700, 0.5)   // => 1604
Elo.getNewRating(1600, 1700, 0)     // => 1588

getRatingDelta(myRating, opponentRating, myGameResult)

Calculates my new rating given the following parameters:

  • myRating (number) - My rating before the game, e.g. 1600
  • opponentRating (number) - Opponent's rating before the game, e.g. 1700
  • myGameResult (number) - The result of the game, 1 if I won, 0 if I lost, or 0.5 if draw
Example
Elo.getRatingDelta(1600, 1700, 1)     // => 20
Elo.getRatingDelta(1600, 1700, 0.5)   // => 4
Elo.getRatingDelta(1600, 1700, 0)     // => -12

elo.js's People

Contributors

moroshko avatar

Stargazers

Sam Itani avatar kaste avatar Musa AbdulKareem avatar 'lo avatar Vardhaman Ayyagari avatar Gabriel R. Coelho avatar  avatar  avatar Benoît Philibert avatar Anton Kuznetsov avatar Tim Smith avatar Jorge Sainz Sueiro avatar Tyler Fehr avatar Jorge Medina avatar Sep. avatar FlyElephant avatar 02 avatar Ivan Eisenberg avatar Keitaroh Kobayashi avatar  avatar Cam avatar Teddy Kishi avatar Brian Heidrich avatar Carmine Zonno avatar  avatar  avatar  avatar Andreas Partsch avatar Cengiz Gürtusgil avatar Tomas Belada avatar Thomas Offinga avatar Scott Vayner avatar Steven avatar Laurie avatar Ayomide avatar Travis Nischuk avatar Martin Sonesson avatar Coleman Rollins avatar John avatar Ian DesJardins avatar  avatar J.R. Ruggiero avatar Eric avatar Enzo Ferey avatar  avatar Eric Ryan Harrison avatar Joshua Dean avatar cfpperche avatar  avatar  avatar Kevin Bohinski avatar Tommaso Ricci avatar Dave Edelhart avatar Elliot avatar

Watchers

 avatar James Cloos avatar  avatar  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.