standard

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package standard implements standard chess scoring (1-½-0).

In standard scoring, each player receives a fixed number of points per result: 1 for a win, ½ for a draw, 0 for a loss. Byes, forfeits, and absences may have their own configurable point values.

This is the scoring system used by FIDE for Swiss and round-robin tournaments, and the system used internally by the Swiss pairer for scoregroup formation (even when the tournament's public standings use a different scoring system like Keizer).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// PointWin is the points awarded for a win.
	// Default: 1.0.
	PointWin *float64 `json:"pointWin,omitempty"`

	// PointDraw is the points awarded for a draw.
	// Default: 0.5.
	PointDraw *float64 `json:"pointDraw,omitempty"`

	// PointLoss is the points awarded for a loss.
	// Default: 0.0.
	PointLoss *float64 `json:"pointLoss,omitempty"`

	// PointBye is the points awarded for a bye.
	// Default: 1.0 (full point bye, FIDE default).
	PointBye *float64 `json:"pointBye,omitempty"`

	// PointForfeitWin is the points awarded for a forfeit win.
	// Default: 1.0.
	PointForfeitWin *float64 `json:"pointForfeitWin,omitempty"`

	// PointForfeitLoss is the points awarded for a forfeit loss.
	// Default: 0.0.
	PointForfeitLoss *float64 `json:"pointForfeitLoss,omitempty"`

	// PointAbsent is the points awarded when a player is absent
	// (neither plays nor receives a bye).
	// Default: 0.0.
	PointAbsent *float64 `json:"pointAbsent,omitempty"`
}

Options holds configurable settings for standard (1-½-0) scoring. All fields are pointers to distinguish "not set" (nil = use default) from "explicitly set to zero."

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. Type mismatches use defaults.

func (Options) WithDefaults

func (o Options) WithDefaults() Options

WithDefaults returns a copy of Options with all nil fields filled in with standard FIDE defaults (1-½-0).

type Scorer

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

Scorer implements the chesspairing.Scorer interface for standard scoring.

func New

func New(opts Options) *Scorer

New creates a new standard scorer with the given options.

func NewFromMap

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

NewFromMap creates a new standard scorer from a map[string]any config.

func (*Scorer) PointsForResult

func (s *Scorer) PointsForResult(result chesspairing.GameResult, rctx chesspairing.ResultContext) float64

PointsForResult returns the points awarded for a specific game result in standard scoring. For standard scoring, points are fixed regardless of opponent — the ResultContext is only used for bye/absent/forfeit flags.

func (*Scorer) Score

Score calculates standard scores for all active players.

Unlike Keizer scoring, standard scoring is simple: each result adds a fixed number of points. No iterative convergence is needed because points don't depend on rankings.

Jump to

Keyboard shortcuts

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