standings

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 standings composes a Scorer and a list of TieBreakers over a TournamentState into a presentation-ready standings table.

The Scorer interface is unchanged. Wins / draws / losses are derived directly from game results in standings.Build, not from the Scorer, because W/D/L is orthogonal to scoring rule: Keizer and standard scoring both produce wins, draws, and losses from the same game results, they just award different point values.

Two opinionated choices, both documented on Build:

  • Double-forfeit games count as 0 wins, 0 draws, 0 losses for both players. The game did not happen, matching what the standard scorer awards (0-0) and the documented forfeit semantics in the root package.

  • True ties on score and all tiebreaker values share the same rank, with the next distinct row's rank skipping accordingly (standard "1224" competition ranking). Unique-rank stamping for ties is not supported.

This package depends on chesspairing/tiebreaker via BuildByID for the convenience of resolving tiebreaker IDs through the registry. Build itself takes already-resolved []TieBreaker values and has no registry dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(
	ctx context.Context,
	state *cp.TournamentState,
	scorer cp.Scorer,
	tieBreakers []cp.TieBreaker,
) ([]cp.Standing, error)

Build composes a Scorer and a list of TieBreakers over a TournamentState and returns a presentation-ready standings table.

The output is sorted by score descending, then by tiebreaker values in the order tieBreakers was supplied, descending. Rows that tie on score and all tiebreaker values share the same rank; the next distinct row's rank skips accordingly (standard "1224" ranking). Within a shared rank, rows are stable-sorted by Scorer output order.

Wins / draws / losses are derived from state.Rounds[].Games:

  • Decisive (1-0 or 0-1): winner +1 win, loser +1 loss.
  • Draw: each +1 draw.
  • Single forfeit: forfeit-winner +1 win, forfeit-loser +1 loss. The game is "played" for standings purposes, reflecting what happened tournament-wise. (PlayedPairs treats the same game differently for pairing-history purposes — see the package comment in chesspairing.go for the cross-subsystem matrix.)
  • Double forfeit: 0 across the board for both players, including no increment to GamesPlayed. The game did not happen.
  • Bye games: not counted as wins, draws, or losses; their score contribution comes from the Scorer.
  • Pending games: skipped, contribute 0 to everything.

Build returns one Standing per entry in scorer.Score's output, in the order Score returned them (typically active players only).

func BuildByID

func BuildByID(
	ctx context.Context,
	state *cp.TournamentState,
	scorer cp.Scorer,
	tbIDs []string,
) ([]cp.Standing, error)

BuildByID is a convenience wrapper that resolves tiebreaker IDs through the chesspairing/tiebreaker registry before calling Build. Unknown IDs return an error rather than being silently skipped.

Types

This section is empty.

Jump to

Keyboard shortcuts

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