Documentation
¶
Overview ¶
Package doubleswiss implements the FIDE Double-Swiss pairing system (C.04.5).
The Double-Swiss system (approved Oct 2025, effective Feb 2026) treats each round as a 2-game match. Scores are cumulative game points (win=2, draw=1, loss=0 per match). The system uses lexicographic bracket pairing (Art. 3.6) from the shared pairing/lexswiss package.
Key characteristics:
- Each round is a 2-game match (colours alternate within the match)
- PAB awards 1.5 points (Art. 3.4)
- Lexicographic enumeration of pairings (no Blossom matching)
- Simplified criteria: C1 (absolute) + C8 (colour, relaxable in last round)
- Colour allocation with 5-step priority (Art. 4)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllocateColor ¶
func AllocateColor(a, b *lexswiss.ParticipantState, roundNumber, boardNumber int, topSeedColor *string) (string, string)
AllocateColor decides which participant gets White in Game 1 of the match and which gets Black, implementing Art. 4 of the Double-Swiss system.
In Double-Swiss, "colour" means who gets White in Game 1 of the 2-game match. The other participant gets White in Game 2 (colours alternate within the match).
Priority:
- Hard constraint: no participant plays Game 1 as the same colour 3 times in a row
- Equalise: participant with more white Game-1s gets Black in Game 1
- Alternate: participant who had White in Game 1 last round gets Black
- Rank tiebreak: higher ranked (lower TPN) gets White in Game 1
- Round 1: board alternation (odd board → higher ranked White, even board → Black)
Parameters:
- a, b: the two participants in the pairing
- roundNumber: 1-based round number
- boardNumber: 1-based board number (for round 1 alternation)
- topSeedColor: override for round 1 top seed colour (nil or "auto" = default)
Returns (whiteID, blackID) indicating who plays White in Game 1.
Types ¶
type Options ¶
type Options struct {
// TopSeedColor forces the top seed's colour in round 1.
// Values: "auto" (default), "white", "black".
TopSeedColor *string `json:"topSeedColor,omitempty"`
// ForbiddenPairs lists participant ID pairs that must not be paired together.
ForbiddenPairs [][]string `json:"forbiddenPairs,omitempty"`
// TotalRounds is the total number of rounds in the tournament.
// Used to determine "last round" for criteria relaxation (C8).
TotalRounds *int `json:"totalRounds,omitempty"`
}
Options holds Double-Swiss-specific pairing configuration. All pointer fields use nil = use default.
func ParseOptions ¶
ParseOptions converts a generic map[string]any into typed Options.
func (Options) WithDefaults ¶
WithDefaults returns a copy of options with defaults applied for nil fields.
type Pairer ¶
type Pairer struct {
// contains filtered or unexported fields
}
Pairer implements the chesspairing.Pairer interface for the Double-Swiss system.
func NewFromMap ¶
NewFromMap creates a new Double-Swiss pairer from a generic options map.
func (*Pairer) Pair ¶
func (p *Pairer) Pair(_ context.Context, state *chesspairing.TournamentState) (*chesspairing.PairingResult, error)
Pair implements chesspairing.Pairer for the Double-Swiss system.