Functions to generate pairings for tournaments
npm install tournament-pairingstournament-organizer.
import instead of require and add type: "module" to your package.json.
npm i tournament-pairings
`
Importing
Named imports:
`js
import {
SingleElimination,
DoubleElimination,
RoundRobin,
Stepladder,
Swiss
} from 'tournament-pairings'
`
Namespace import:
`js
import * as Pairings from 'tournament-pairings'
`
Interfaces for TypeScript:
`js
import {
Match,
Player
} from 'tournament-pairings/interfaces'
`
Functions
Single elimination:
`ts
SingleElimination(
players: Number | Array,
startingRound: Number = 1,
consolation: Boolean = false,
ordered: Boolean = false
): Array
`
Double elimination:
`ts
DoubleElimination(
players: Number | Array,
startingRound: Number = 1,
ordered: Boolean = false
): Array
`
Round-robin:
`ts
RoundRobin(
players: Number | Array,
startingRound: Number = 1,
ordered: Boolean = false
): Array
`
Stepladder:
`ts
Stepladder(
players: Number | Array,
startingRound: Number = 1,
ordered: Boolean = true
): Array
`
Swiss:
`ts
Swiss(
players: Array,
round: Number,
rated: Boolean = false,
seating: Boolean = false
): Array
Player {
id: String | Number,
score: Number,
pairedUpDown?: Boolean,
receivedBye? : Boolean,
avoid?: Array,
seating?: Array<-1 | 1>,
rating?: Number | null
}
`
$3
players: if provided a number n (except for Swiss), then players are array of numbers from 1 to n.
consolation: if there is an additional match in the final round to determine third place.
ordered: if the array provided for players is ordered.
rated: if the players have a rating to be considered for pairing.
seating: if the seating of the players needs to be considered.
$3
pairedUpDown: if the player has been paired with someone outside their point group in a prior round.
receivedBye: if the player was unpaired in a prior round.
avoid: an array of IDs representing prior opponents of the player.
seating: an array of either 1 or -1 to represent seating. The most obvious example is playing white or black in chess.
Return Value
Each function returns an Array.
`ts
Match {
round: number,
match: number,
player1: string | number | null,
player2: string | number | null,
win?: {
round: number,
match: number
},
loss?: {
round: number,
match: number
}
}
``