dutch

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dutch implements the FIDE Dutch Swiss pairing system (C.04.3).

The Dutch system is the most widely used Swiss pairing system in chess. Players are grouped by score, then paired within brackets using transposition and exchange algorithms subject to 21 quality criteria.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPairingPossible = errors.New("no valid pairing exists for the remaining players")

ErrNoPairingPossible is returned when no valid pairing can be found.

View Source
var ErrTooFewPlayers = errors.New("swiss pairing requires at least 2 active players")

ErrTooFewPlayers is returned when there aren't enough active players.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Acceleration selects Baku acceleration mode.
	// Values: "none" (default), "baku".
	Acceleration *string `json:"acceleration,omitempty"`

	// TopSeedColor forces the top seed's color in round 1.
	// Values: "auto" (default), "white", "black".
	TopSeedColor *string `json:"topSeedColor,omitempty"`

	// ForbiddenPairs lists player ID pairs that must not be paired together.
	ForbiddenPairs [][]string `json:"forbiddenPairs,omitempty"`
}

Options holds Dutch-specific pairing configuration. All fields use pointer-nil pattern: nil = use default.

func ParseOptions

func ParseOptions(m map[string]any) Options

ParseOptions converts a generic map[string]any into typed Options.

func (Options) WithDefaults

func (o Options) WithDefaults() Options

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 FIDE Dutch Swiss pairing.

func New

func New(opts Options) *Pairer

New creates a new Dutch pairer with the given options.

func NewFromMap

func NewFromMap(m map[string]any) *Pairer

NewFromMap creates a new Dutch pairer from a generic options map.

func (*Pairer) Pair

Pair generates pairings for the next round using the FIDE Dutch system (C.04.3).

Algorithm:

  1. Build PlayerState for all active players
  2. Build score groups (all players enter matching pool)
  3. Global Blossom matching (PairBracketsGlobal) — includes Stage 0.5 completability pre-matching for bye determination with odd player count
  4. Order boards per FIDE A.6
  5. Allocate colors for all paired games
  6. Unmatched player (if any) receives PAB
  7. Return PairingResult

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL