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

go-pairer

v1.0.3

Published

`go-pairer` is a library for pairing Go tournaments. It efficiently computes an optimal weighted pairing.

Downloads

6

Readme

go-pairer

go-pairer is a library for pairing Go tournaments. It efficiently computes an optimal weighted pairing.

Tournament Settings

let t = new Tournament();
t.setHandicapType(HandicapType.FullHandicap);

The Tournament object holds the tournament settings. The most important setting is handicap type, which defaults to rank difference - 1.

go-pairer assigns penalties when possible matches are not optimal for one reason or another, and then finds the set of matches for the next round that minimizes the penalties. The size of some penalties can be adjusted in the Tournament object, e.g. t.setIntraStateGap(0.2).

Penalties

  • Playing someone whose tournament score is different: 10000 * <score difference>^2
  • Playing the same color three times in a row: 15000
  • Playing someone with a different score in the same direction twice in a row: 17500
  • Playing a game that requires a handicap: <handicap size>^2 *10000* <handicap gap>
  • Playing someone from the same family/club/city/state: 1000 * <intraFamily/Club/City/State gap>

Defaults

  • handicapGap: 0.3
  • intraStateGap: 0
  • intraCityGap: 0.36
  • intraClubGap: 0.56
  • intraFamilyGap: 0.81

Players

let p = new Player(id, initialScore, rating);

Player objects are created with a unique id, an initial score, and a rating. The initial score can be used to give stronger players an advantage in the tournament. The rating is an AGA rating: -1.9 to -1 is 1k, 1 to 1.9 is 1d, etc. You can also set the state/city/club/family to avoid matchups with familiar players, e.g. p.setState("Ohio").

Games

let g = new Game(blackId, whiteId, handicap, result);

Game objects are created with their player ids and the handicap. If a player had a bye, create a game with that player as both Black and White, and a result of Result.VoluntaryBye or Result.InvoluntaryBye. An involuntary bye counts as a win for the purposes of scoring. A voluntary bye counts as a loss (doesn't increase the players score).

Pairing Example

Here's an example of how to compute the pairing for the next round. This is a tournament for six players, in which two rounds have already been played.

const {WeightedPairingAlgorithm, Tournament, Player, Game, HandicapType, Result} = require("go-pairer");

let alg = new WeightedPairingAlgorithm();
let t = new Tournament();
t.setHandicapType(HandicapType.FullHandicap);

// Create player list.  There must be an even number of players.
// If a player has a bye this round, don't include them in the list.
// new Player(id, initialScore, rating)
let p1 = new Player(1, 0, 6.5); // 6d
let p2 = new Player(2, 0, 5.5); // 5d
let p3 = new Player(3, 0, 2.3); // 2d
let p4 = new Player(4, 0, 2.1); // 2d
let p5 = new Player(5, 0, 1.7); // 1d
let p6 = new Player(6, 0, 1.1); // 1d
let players = [p1, p2, p3, p4, p5, p6];

// Create games from previous rounds.
let round1Games = [
    // new Game(blackId, whiteId, handicap, result)
    new Game(2, 1, 1, Result.BlackWin),
    new Game(3, 4, 0, Result.BlackWin),
    new Game(5, 6, 0, Result.WhiteWin)
];
let round2Games = [
    new Game(3, 1, 4, Result.WhiteWin),
    new Game(6, 2, 4, Result.WhiteWin),
    new Game(5, 4, 1, Result.BlackWin)
];
let games = [round1Games, round2Games];

// Create array to hold new games, and do pairing.
let newGames = [];
alg.doPairing(t, players, games, newGames);

// newGames now contains game objects for next round with blackId, 
// whiteId, and handicap populated.