pcc-tournament-pairs is a tiny swiss pairing library with basic deterministic functionality
npm install --save pcc-tournament-pairs
optionscontains the following variables:
maxPointsPerRound- the number of points a participant can score in a round - usually 1 or 2
rematchWeight- rematch penalty weight
standingPower- the power to which standings differences should be raised
seedMultiplier- the deterministic PRNG seed multiplier, ideally a prime of at least 4 digits
test/test.jsfor usage example
pcc-tournament-pairs exposes the following three methods:
getMatchups(round, participants, matches)
matches formats below.
Determines the matchups for the given round by pairing participants:
- who have not faced each other
- in order of:
- highest standing/score to lowest
- highest sohnebern-berger to lowest
- highest solkov to lowest
- highest seed to lowest
- where the highest ranked team in a pair is given the
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)
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 seed in that order.
Standings returned are in the form:
'id': participant_id'seed': seed'wins': won_points'losses': lost_points'sohne': sohne_points'solkov': solkov_points...
The participants argument expects an array in the form:
id: participant_idseed: participant_seed;
participant_seedmay be any directly sortable value, although numeric values are suggested for reliability
The matches argument expects an array in the form:
round: match_roundhome:id: home_participant_idpoints: home_won_pointsaway:id: away_participant_idpoints: away_won_points;
match_roundmust be a value sortable against the given
currentRoundargument - all
matcheswill be limited to those where the
roundis less than the
away_points_wonshould be numeric values, but currently can be anything that can be accumulated against
0 + ...and compared against numeric values - there are also no checks against whether or not these values overrun
maxPerRoundand any data that does overrun
maxPerRoundwill likely result in strange or erroneous results from every function in this library