Giter VIP home page Giter VIP logo

node-arpad's Introduction

Arpad: ELO Rating System for Node.js

This is an implementation of ELO for Node.js (ELO is named after Arpad Elo, hence the package name). This module is heavily tested and has many features used in real-world ELO situations.

Installation

$ npm install arpad

Simple Usage

This is a fairly simple example showing the most common usage for Arpad:

const Elo = require('arpad');

const elo = new Elo();

let alice = 1_600;
let bob = 1_300;

let new_alice = elo.newRatingIfWon(alice, bob);
console.log("Alice's new rating if she won:", new_alice); // 1,605

let new_bob = elo.newRatingIfWon(bob, alice);
console.log("Bob's new rating if he won:", new_bob); // 1,327

Complex Usage

This is a more complex example, making use of K-factor tables and score values:

const Elo = require('arpad');

const uscf = {
  default: 32,
  2100: 24,
  2400: 16
};

const min_score = 100;
const max_score = 10_000;

const elo = new Elo(uscf, min_score, max_score);

let alice = 2_090;
let bob = 2_700;

let odds_alice_wins = elo.expectedScore(alice, bob);
console.log("The odds of Alice winning are about:", odds_alice_wins); // 0.029
alice = elo.newRating(odds_alice_wins, 1.0, alice);
console.log("Alice's new rating after she won:", alice); // 2121

odds_alice_wins = elo.expectedScore(alice, bob);
console.log("The odds of Alice winning again are about:", odds_alice_wins); // 0.034
alice = elo.newRating(odds_alice_wins, 1.0, alice);
console.log("Alice's new rating if she won again:", alice); // 2144

Running Tests

If you'd like to contribute be sure to run npm install to get the required packages and then make changes. Afterwards simply run the tests. If everything passes your Pull Request should be ready.

$ npm test

License

MIT

node-arpad's People

Contributors

0xflotus avatar kenany avatar tlhunter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-arpad's Issues

Change in rating for the loser

Hi,
I am looking at using this for ranking wrestlers based upon the outcome of the match. You examples show the new rating for the loser, but how do I get a new rating for the loser.

Thanks

Edit. I figured it out. I am going to close this.

Add convenience method for getting new rating

e.g.

var odds_of_alice_winning = elo.expectedScore(alice, bob);
alice = elo.newRating(odds_of_alice_winning, 1, alice);

could be simply be

alice = elo.newRatingIfWon(alice, bob); // or newRatingIfLost

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.