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

masters

v3.1.0

Published

Repeat elimination tournaments

Downloads

34

Readme

Masters tournaments

npm status build status dependency status coverage status

Overview

Masters tournaments consist of a pool of players, repeatedly fighting against each other and gradually reducing the number of players each round. We specify the number of players to knock out each round as an array of integers.

This tournament is a special case of an FFA tournament but with the sizes set equal to the number of players in each round to ensure one match per round.

Construction

Simply specify the number of players and an array of numbers to knock out per rounds. The resulting tournament will have the same number of matches as that array's length + 1.

// 5p match -> 4p match -> 3p match -> 2p final
var trn = new Masters(5);

// see below
var trn = new Masters(10, { knockouts: [3, 2, 2] });

This example will create:

  • 10 player match in round 1
  • 7 player match in round 2
  • 5 player match in round 3
  • 3 player (final) match

Limits

Limits adds a way to ensure we get the top n players from the final without having to do re-matches. Set the limit: n on the third options argument to the constructor to activate this.

This will simly engage a disambiguation clause for the final match.

Match Ids

Like all tournament types, matches have an id object that contains three values all in {1, 2, ...}:

{
  s: Number, // the bracket - always 1 - only WB supported
  r: Number, // the round number in the current bracket
  m: Number  // the match number - always 1 - only single match rounds supported
}

Finding matches

All the normal Base class helper methods exist on a Duel instance. That said, masters are so simple you can do this very simply anyway:

var r1 = trn.findMatches({ r: 1 });
// NB: equivalent to: [trn.matches[0]]

var firstThreeRounds = trn.findMatchesRanged({}, { r: 3 });
// NB: equivalent to: trn.matches.slice(0, 3)

var upcomingForSeed1 = trn.upcoming(1);
var matchesForSeed1 = trn.matchesFor(1);

Scoring Matches

Call trn.hscore(id, [player0Score, player1Score, ...]) as for every match played. The trn.unscorable(id, scoreArray) will tell you whether the score is valid. Read the entry in the tournament commonalities doc.

NB: Ambiguity restriction

Masters allow for ties everywhere except between the first knocked out player and the last advancing player. In the final, ties are fully allowed, so multiple players can share the first place. Check for this if it's unsuited to your game/application.

Special Methods

None.

License

MIT-Licensed. See LICENSE file for details.