npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

elo-mmr

v1.3.1

Published

A multiplayer ELO ranking system

Downloads

12

Readme

elo-mmr

A node implementation of the ELO-MMR player ranking.

This code is based on the Python version https://github.com/duhby/elommr which is Copyright 2023-2024 duhby, and released under the MIT license. It wouldn't be possible without their help and code.

Quick Example

This is the conversion from python example, and is in [node_example.ts](https://github.com/chad3814/elo-mmr/blob/main/node_example.ts):

import { EloMmr, Standing } from "./lib/elo_mmr"
import { Player } from "./lib/player";
import { Rating } from "./lib/rating";

function main(): void {
    const elo_mmr = new EloMmr();
    const player1 = new Player(new Rating());
    const player2 = new Player(new Rating())
    const standings: Standing[] = [
        [
            player1,
            0, 0  // Range of players that got or tied for first
        ],
        [
            player2,
            1, 1  // Range of players that got or tied for second
        ],
    ];

    // Note that the contest_time does not do anything in this example
    // because EloMMR.drift_per_sec defaults to 0, so contest_time
    // can be omitted from the round_update call, but it is included
    // here to show how it can be used.
    // Do note, though, that you should either always include
    // contest_time or never include it, because if you include it
    // in some competitions and not others, the ratings will be skewed
    // incorrectly.
    const contest_time = new Date();
    elo_mmr.roundUpdate(standings, contest_time);

    const next_contest_time = new Date(contest_time.getMilliseconds() + 10000);
    // Assumes the outcome of the next competition is the same as the
    // previous, so the standings aren't changed.
    elo_mmr.roundUpdate(standings, next_contest_time);

    for (const player of [player1, player2]) {
        console.log("\nrating_mu, rating_sig, perf_score, place");
        for(const event of player.eventHistory) {
            console.log(`${event.rating.mu}, ${event.rating.sig}, ${event.performanceScore}, ${event.place}`);
        }
        console.log(`Final rating: ${player.eventHistory[player.eventHistory.length - 1].toString()}`);
    }
    // >>>
    // rating_mu, rating_sig, perf_score, place
    // 1629, 171, 1654, 0
    // 1645, 130, 1663, 0
    // Final rating: 1645 ± 100
    //
    // rating_mu, rating_sig, perf_score, place
    // 1371, 171, 1346, 1
    // 1355, 130, 1337, 1
    // Final rating: 1355 ± 100
}

main();