keizer

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: 5 Imported by: 0

Documentation

Overview

Package keizer implements Keizer-style pairing for chess tournaments.

Keizer pairing works by ranking players by their current Keizer score (computed by the Keizer scorer, or by rating if no rounds have been played), then pairing top-down: rank 1 vs rank 2, rank 3 vs rank 4, and so on. The lowest-ranked player gets a bye if there's an odd number of players.

Repeat avoidance: by default, players must wait at least 3 rounds before being paired against the same opponent again. When a conflict occurs, the partner is swapped with the nearest available lower-ranked player.

Color assignment uses a priority cascade: absolute preferences (imbalance or consecutive same color) take priority, followed by strong preferences, color history differences, rank tiebreak, and board alternation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// AllowRepeatPairings controls whether players can be paired against
	// the same opponent again within the tournament.
	// Default: true (Keizer tournaments often span many rounds).
	AllowRepeatPairings *bool `json:"allowRepeatPairings,omitempty"`

	// MinRoundsBetweenRepeats is the minimum number of rounds that must
	// pass before two players can be paired again.
	// Only applies when AllowRepeatPairings is true.
	// Default: 3.
	MinRoundsBetweenRepeats *int `json:"minRoundsBetweenRepeats,omitempty"`

	// ScoringOptions configures the internal Keizer scorer used for ranking.
	// When nil, the scorer uses its own defaults.
	ScoringOptions *keizerscoring.Options `json:"scoringOptions,omitempty"`
}

Options holds configurable settings for Keizer pairing. All fields are pointers to distinguish "not set" (nil = use default) from "explicitly set."

func ParseOptions

func ParseOptions(m map[string]any) Options

ParseOptions converts a map[string]any (from Firestore/JSON) into typed Options. Unrecognized keys are ignored.

func (Options) WithDefaults

func (o Options) WithDefaults() Options

WithDefaults returns a copy of Options with all nil fields filled in with system defaults.

type Pairer

type Pairer struct {
	// contains filtered or unexported fields
}

Pairer implements the chesspairing.Pairer interface for Keizer pairing.

func New

func New(opts Options) *Pairer

New creates a new Keizer pairer with the given options.

func NewFromMap

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

NewFromMap creates a new Keizer pairer from a map[string]any config.

func (*Pairer) Pair

Pair generates pairings for the next round using the Keizer method.

Jump to

Keyboard shortcuts

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