dambrisco / swiss-pairing

Tiny swiss pairing library with basic deterministic functionality
MIT License
12 stars 6 forks source link

swiss-pairing

NPM version Dependency status CI status

swiss-pairing is a tiny swiss pairing library with basic deterministic functionality

Installation

Usage

swiss-pairing exposes the following three methods:

getMatchups(round, participants, matches)

See participants and matches formats below.

Determines the matchups for the given round by pairing participants:

When byes are needed (in the case of an odd number of participants), they bubble up from the lowest to the highest ranking, (starting with the lowest seed when no match history is available). participants cannot have more than one bye.

Matchups returned are in the form:

[
  {
    'home': home_participant_id,
    'away': away_participant_id
  },
  ...
]

getStandings(round, participants, matches)

See participants and matches formats below.

Determines the standings for a given round by accumulating won points and lost points and calculating modified median scores. Standings are ordered by wins, modified median score, and (inverse) seed in that order.

Standings returned are in the form:

[
  {
    'id': participant_id,
    'seed': seed,
    'wins': won_points,
    'losses': lost_points,
    'tiebreaker': modified_median_score
  },
  ...
]

getModifiedMedianScores(round, participants, matches)

See participants and matches formats below.

Caculates modified median scores based on the given participants and paired match history.

Scores returned are in the form:

{
  <participant_id>: modified_median_score,
  ...
}

participants argument

The participants argument expects an array in the form:

[
  {
    'id': participant_id,
    'seed': participant_seed
  }
]

matches argument

The matches argument expects an array in the form:

[
  {
    'round': match_round,
    'home': {
      'id': home_participant_id,
      'points': home_won_points
    },
    'away': {
      'id': away_participant_id,
      'points': away_won_points
    }
  }
]

Contributors