GithubHelp home page GithubHelp logo

hoersamu / multi-elo Goto Github PK

View Code? Open in Web Editor NEW
23.0 1.0 5.0 500 KB

This package implements a multiplayer extension of the popular Elo rating system.

Home Page: https://www.npmjs.com/package/multi-elo

License: MIT License

TypeScript 100.00%
multiplayer elo chess elo-rating-algorithm

multi-elo's Introduction

multi-elo

npm version npm downloads bundle Codecov

This package implements a multiplayer extension of the popular Elo rating system.

This Package is based on djcunningham0s python implementation. For additional information, see his blog post on Towards Data Science (or try this link if you hit a paywall).

Installation

The package can be installed from GitHub or npm by using npm.

# npm
npm install multi-elo

# yarn
yarn add multi-elo

# pnpm
pnpm install multi-elo

# bun
bun install multi-elo

Import:

// ESM
import {} from "multi-elo";

// CommonJS
const {} = require("multi-elo");

Example Usage

The following example shows how to calculate updated Elo ratings after a matchup using the default settings in the package.

import { MultiElo } from 'multi-elo';

# player with 1200 rating beats a player with 1000 rating
MultiElo.getNewRatings([1200, 1000])
# [1207.68809835,  992.31190165]

# player with 900 rating beats player with 1000 rating
MultiElo.getNewRatings([900, 1000])
# [920.48207999, 979.51792001]

# 3-way matchup
MultiElo.getNewRatings([1200, 900, 1000])
#  [1208.34629612,  910.43382278,  981.21988111]

See demo.md for a more in-depth tutorial, including details on parameters that can be tuned in the Elo algorithm.

Methodology

For more Info on the methodology read djcunningham0s Readme.

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛 by Samuel Höra

Published under MIT License.

multi-elo's People

Contributors

atinux avatar danielroe avatar hoersamu avatar nozomuikuta avatar o-az avatar pi0 avatar renovate[bot] 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

Watchers

 avatar

multi-elo's Issues

Deprecation warning while using with NodeJS

Hi there! Here is the warning I'm getting, Not sure how to fix it.

(node:6929) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/.........../node_modules/multi-elo/package.json' of 'lib/index.js'. Please either fix that or report it to the module author
(Use node --trace-deprecation ... to show where the warning was created)

Incorrect scoring with greater than 9 results

The issue is that the .sort() in the argsort function will by default use a string conversion so "11" sorts ahead of "9". I found this when trying to run

elo.getNewRatings([1688,1590,1581,1582,1550,1500,1465,1455,1435,1453,1432,1472,1526], [1,2,3,4,5,6,7,8,9,10,11,11,12]);

It fails the validation since there is not a zero score and no tie for last place. If you sort the results by numeric values it all works correctly.

basically just need

export const argsort = (arr: number[]) =>
  arr
    .map((element, index) => decor(element, index))
    .sort((a, b) => (a[0] - b[0]))
    .map((element) => undecor(element));

If you want to give me ability to create a branch/PR I'd be happy to put that change up for you.

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.