Documentation
¶
Overview ¶
Package tiebreaker implements chess tournament tiebreakers.
Each tiebreaker implements the chesspairing.TieBreaker interface and computes a single numeric value per player. Tiebreakers are applied in order to resolve ties in the standings.
The tiebreaker registry provides lookup by ID and FIDE-recommended defaults per pairing system.
Index ¶
- func All() []string
- func Get(id string) (chesspairing.TieBreaker, error)
- func Register(id string, fn func() chesspairing.TieBreaker)
- type ARO
- type AvgOpponentBuchholz
- type AvgOpponentPTP
- type AvgOpponentTPR
- type BlackGames
- type BlackWins
- type Buchholz
- type DirectEncounter
- type ForeBuchholz
- type GamesPlayed
- type Koya
- type PairingNumber
- type PerformancePoints
- type PerformanceRating
- type PlayerRating
- type Progressive
- type RoundsPlayed
- type SonnebornBerger
- type StandardPoints
- type Win
- type Wins
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get(id string) (chesspairing.TieBreaker, error)
Get returns a tiebreaker by ID. Returns an error if the ID is unknown.
func Register ¶
func Register(id string, fn func() chesspairing.TieBreaker)
Register adds a tiebreaker constructor to the global registry. Must only be called during init().
Types ¶
type ARO ¶
type ARO struct{}
ARO computes the Average Rating of Opponents tiebreaker.
The value is the arithmetic mean of the ratings of all opponents the player has played against. Byes and absences are excluded (they have no opponent).
This tiebreaker rewards playing against a stronger field and is categorized as FIDE Category D.
func (*ARO) Compute ¶
func (a *ARO) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
type AvgOpponentBuchholz ¶
type AvgOpponentBuchholz struct{}
AvgOpponentBuchholz computes the Average of Opponents' Buchholz tiebreaker (FIDE Art. 8.2, AOB).
For each player, this first computes the full Buchholz of every opponent, then averages those values. Unplayed rounds use virtual opponent scores as in standard Buchholz.
FIDE Category C tiebreaker.
func (*AvgOpponentBuchholz) Compute ¶
func (a *AvgOpponentBuchholz) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*AvgOpponentBuchholz) ID ¶
func (a *AvgOpponentBuchholz) ID() string
func (*AvgOpponentBuchholz) Name ¶
func (a *AvgOpponentBuchholz) Name() string
type AvgOpponentPTP ¶
type AvgOpponentPTP struct{}
AvgOpponentPTP computes the average of opponents' Performance with Tournament Points (FIDE Art. 10.5, APPO).
For each player, this first computes PTP for every opponent, then averages those values. Result is rounded to the nearest whole number.
FIDE Category D tiebreaker.
func (*AvgOpponentPTP) Compute ¶
func (a *AvgOpponentPTP) Compute(ctx context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*AvgOpponentPTP) ID ¶
func (a *AvgOpponentPTP) ID() string
func (*AvgOpponentPTP) Name ¶
func (a *AvgOpponentPTP) Name() string
type AvgOpponentTPR ¶
type AvgOpponentTPR struct{}
AvgOpponentTPR computes the average of opponents' Tournament Performance Ratings (FIDE Art. 10.4, APRO).
For each player, this first computes TPR for every opponent, then averages those values. Result is rounded to the nearest whole number.
FIDE Category D tiebreaker.
func (*AvgOpponentTPR) Compute ¶
func (a *AvgOpponentTPR) Compute(ctx context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*AvgOpponentTPR) ID ¶
func (a *AvgOpponentTPR) ID() string
func (*AvgOpponentTPR) Name ¶
func (a *AvgOpponentTPR) Name() string
type BlackGames ¶
type BlackGames struct{}
BlackGames computes the number of games played over the board with the Black pieces (FIDE Art. 7.3, BPG).
Forfeit games are excluded — only games actually played count. A higher value indicates the player overcame the disadvantage of playing Black more frequently.
FIDE Category B tiebreaker.
func (*BlackGames) Compute ¶
func (bg *BlackGames) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*BlackGames) ID ¶
func (bg *BlackGames) ID() string
func (*BlackGames) Name ¶
func (bg *BlackGames) Name() string
type BlackWins ¶
type BlackWins struct{}
BlackWins computes the number of games won over the board with the Black pieces (FIDE Art. 7.4, BWG).
Only OTB wins count — forfeit wins are excluded.
FIDE Category B tiebreaker.
func (*BlackWins) Compute ¶
func (bw *BlackWins) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
type Buchholz ¶
type Buchholz struct {
// contains filtered or unexported fields
}
Buchholz computes the Buchholz tiebreaker: the sum of all opponents' scores. Variants drop the lowest, two lowest, or highest+lowest opponent scores.
For unplayed rounds (byes, absences), a virtual opponent score is used: the player's own current score (FIDE C.02 recommendation).
func (*Buchholz) Compute ¶
func (b *Buchholz) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
type DirectEncounter ¶
type DirectEncounter struct{}
DirectEncounter computes the direct encounter (head-to-head) tiebreaker.
For each group of tied players (same primary score), the direct encounter value is the score from games played ONLY against other members of the tied group. Games against non-tied players are ignored.
If a player is not tied with anyone, their direct encounter value is 0 (it doesn't matter since there's nothing to break).
func (*DirectEncounter) Compute ¶
func (de *DirectEncounter) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*DirectEncounter) ID ¶
func (de *DirectEncounter) ID() string
func (*DirectEncounter) Name ¶
func (de *DirectEncounter) Name() string
type ForeBuchholz ¶
type ForeBuchholz struct{}
ForeBuchholz computes the Fore Buchholz tiebreaker (FIDE Art. 8.3, FB).
This is Buchholz calculated as if all final-round games that have not yet been played ended in draws. If all games are complete, Fore Buchholz equals regular Buchholz.
The "final round" is the last round in state.Rounds. Any game in that round with ResultPending is treated as a draw for scoring purposes.
FIDE Category C tiebreaker.
func (*ForeBuchholz) Compute ¶
func (fb *ForeBuchholz) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*ForeBuchholz) ID ¶
func (fb *ForeBuchholz) ID() string
func (*ForeBuchholz) Name ¶
func (fb *ForeBuchholz) Name() string
type GamesPlayed ¶
type GamesPlayed struct{}
GamesPlayed computes the number of games actually played.
This is primarily useful for Keizer tournaments where players can miss rounds. A player who attended more evenings and played more games should rank higher than one with the same score but fewer games (suggesting they scored from absent penalties or byes).
Byes, absences, and forfeits do NOT count as games played.
func (*GamesPlayed) Compute ¶
func (gp *GamesPlayed) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*GamesPlayed) ID ¶
func (gp *GamesPlayed) ID() string
func (*GamesPlayed) Name ¶
func (gp *GamesPlayed) Name() string
type Koya ¶
type Koya struct{}
Koya computes the Koya system tiebreaker.
The Koya system counts the number of points scored against opponents who have 50% or more of the maximum possible score. In a round-robin, this is a useful tiebreaker because it rewards consistency against the stronger half of the field.
Implementation:
- Determine the "qualifying" threshold: half the number of rounds
- Find all opponents whose score >= threshold
- Sum the player's results against those opponents (1=win, 0.5=draw, 0=loss)
func (*Koya) Compute ¶
func (k *Koya) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
type PairingNumber ¶
type PairingNumber struct{}
PairingNumber computes the tournament pairing number tiebreaker (FIDE Art. 7.8, TPN).
The value is the negated 1-based index of the player in state.Players. Negation ensures that lower TPN (= higher seeding) produces a higher tiebreak value, consistent with all other tiebreakers where higher = better.
FIDE Category B tiebreaker.
func (*PairingNumber) Compute ¶
func (pn *PairingNumber) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*PairingNumber) ID ¶
func (pn *PairingNumber) ID() string
func (*PairingNumber) Name ¶
func (pn *PairingNumber) Name() string
type PerformancePoints ¶
type PerformancePoints struct{}
PerformancePoints computes the Performance with Tournament Points tiebreaker (FIDE Art. 10.3, PTP).
PTP is the lowest rating R such that the sum of expected scores (from the FIDE table) against all opponents is >= the player's actual score.
Special case: if score = 0, PTP = (lowest opponent rating) - 800. For players with no games, PTP = 0.
FIDE Category D tiebreaker.
func (*PerformancePoints) Compute ¶
func (pp *PerformancePoints) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*PerformancePoints) ID ¶
func (pp *PerformancePoints) ID() string
func (*PerformancePoints) Name ¶
func (pp *PerformancePoints) Name() string
type PerformanceRating ¶
type PerformanceRating struct{}
PerformanceRating computes the tournament performance rating (FIDE Art. 10.2, TPR).
TPR = ARO + dp(p), where:
- ARO is the average rating of opponents
- p = score / games (fractional score)
- dp(p) is the rating difference from the FIDE B.02 table
For players with no games, TPR = 0. Result is rounded to the nearest whole number (0.5 rounds up).
FIDE Category D tiebreaker.
func (*PerformanceRating) Compute ¶
func (tpr *PerformanceRating) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*PerformanceRating) ID ¶
func (tpr *PerformanceRating) ID() string
func (*PerformanceRating) Name ¶
func (tpr *PerformanceRating) Name() string
type PlayerRating ¶
type PlayerRating struct{}
PlayerRating computes the player's own rating tiebreaker (FIDE Art. 10.6, RTNG).
The value is the player's rating. Higher rating ranks higher.
FIDE Category D tiebreaker.
func (*PlayerRating) Compute ¶
func (pr *PlayerRating) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*PlayerRating) ID ¶
func (pr *PlayerRating) ID() string
func (*PlayerRating) Name ¶
func (pr *PlayerRating) Name() string
type Progressive ¶
type Progressive struct{}
Progressive computes the progressive score tiebreaker.
The progressive score (also called cumulative score) is the sum of cumulative round-by-round scores. A player who scores well in early rounds accumulates a higher progressive score than one who scores the same total but in later rounds.
Example: a player scoring 1, 0, 1, 1 has cumulative scores [1, 1, 2, 3] and progressive = 1 + 1 + 2 + 3 = 7.
func (*Progressive) Compute ¶
func (p *Progressive) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*Progressive) ID ¶
func (p *Progressive) ID() string
func (*Progressive) Name ¶
func (p *Progressive) Name() string
type RoundsPlayed ¶
type RoundsPlayed struct{}
RoundsPlayed computes the number of rounds effectively played (FIDE Art. 7.6, REP).
Unplayed rounds are subtracted from the total round count:
- Half-point bye (ByeHalf)
- Zero-point bye (ByeZero)
- Absent (ByeAbsent or not appearing in round at all)
- Forfeit loss
PAB (pairing-allocated bye) and forfeit wins count as played.
FIDE Category B tiebreaker.
func (*RoundsPlayed) Compute ¶
func (rp *RoundsPlayed) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*RoundsPlayed) ID ¶
func (rp *RoundsPlayed) ID() string
func (*RoundsPlayed) Name ¶
func (rp *RoundsPlayed) Name() string
type SonnebornBerger ¶
type SonnebornBerger struct{}
SonnebornBerger computes the Sonneborn-Berger (SB) tiebreaker.
For each game, the player gets:
- win: opponent's full score
- draw: half of opponent's score
- loss: 0
This rewards winning against strong opponents more than beating weak ones.
func (*SonnebornBerger) Compute ¶
func (sb *SonnebornBerger) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*SonnebornBerger) ID ¶
func (sb *SonnebornBerger) ID() string
func (*SonnebornBerger) Name ¶
func (sb *SonnebornBerger) Name() string
type StandardPoints ¶
type StandardPoints struct{}
StandardPoints computes the standard points tiebreaker (FIDE Art. 7.7, STD).
For each round, the player gets:
- 1 if they scored more points than their opponent
- 0.5 if they scored the same
- 0 if they scored fewer
For unplayed rounds (byes/absences), the awarded points are compared to 0.5 (the draw value): PAB(1.0)→1, half-bye(0.5)→0.5, zero-bye/absent(0)→0.
FIDE Category B tiebreaker.
func (*StandardPoints) Compute ¶
func (sp *StandardPoints) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
func (*StandardPoints) ID ¶
func (sp *StandardPoints) ID() string
func (*StandardPoints) Name ¶
func (sp *StandardPoints) Name() string
type Win ¶
type Win struct{}
Win computes the number of rounds where the participant obtained as many points as awarded for a win (FIDE Art. 7.1, WIN).
This includes OTB wins, forfeit wins, and full-point byes (PAB). Half-point byes and zero-point byes do not count.
FIDE Category B tiebreaker.
func (*Win) Compute ¶
func (w *Win) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
type Wins ¶
type Wins struct{}
Wins computes the number of games won over the board (FIDE Art. 7.2, WON).
Only actual game wins count — byes and forfeits are excluded. This counts decisive results where the player won at the board.
func (*Wins) Compute ¶
func (w *Wins) Compute(_ context.Context, state *chesspairing.TournamentState, scores []chesspairing.PlayerScore) ([]chesspairing.TieBreakValue, error)
Source Files
¶
- averageopponentbuchholz.go
- avgopponentptp.go
- avgopponenttpr.go
- blackgames.go
- blackwins.go
- buchholz.go
- directencounter.go
- forebuchholz.go
- gamesplayed.go
- koya.go
- pairingnumber.go
- performancepoints.go
- performancerating.go
- playerrating.go
- progressive.go
- rating.go
- ratingtable.go
- roundsplayed.go
- sonnebornberger.go
- standardpoints.go
- tiebreaker.go
- win.go
- wins.go