Documentation
¶
Overview ¶
Package varma implements the Varma Tables pre-processing number assignment scheme for round-robin chess tournaments (FIDE C.05 Annex 2).
Varma Tables assign pairing numbers to players so that players from the same federation (country) are spread across the tournament schedule, avoiding same-federation clashes in early rounds.
The scheme covers tournaments of 2-24 players. For 2-8 players the tables are trivial (sequential assignment). For 9-24 players, FIDE provides specific group assignments (A, B, C, D) that achieve optimal federation separation in the Berger table rotation.
Usage: call Groups(n) to get the 4 group assignments for n players, then call Assign(players) to assign pairing numbers based on federation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assign ¶
func Assign(players []chesspairing.PlayerEntry) ([]chesspairing.PlayerEntry, error)
Assign assigns pairing numbers to players using the Varma Tables scheme (FIDE C.05 Annex 2). Players from the same federation are spread across the 4 Varma groups to avoid same-federation clashes in early rounds.
The returned slice is ordered by pairing number (index 0 = pairing number 1). Only active players are included. Inactive players are excluded from the result.
Algorithm:
- Filter to active players only.
- Get the Varma group table for the active player count.
- Group players by federation, sorted by federation size descending, then alphabetically by federation code.
- For each federation (largest first), pick the first Varma group (A→D) with enough available slots. If no single group has enough, spill across groups (largest-available first).
- Within each federation, assign players to slots in alphabetical order by DisplayName.
Returns an error if the active player count is < 2 or > 24.
Types ¶
type Group ¶
type Group struct {
Label byte // 'A', 'B', 'C', or 'D'
Numbers []int // pairing number slots, 1-based, sorted ascending
}
Group represents one of the four Varma groups (A, B, C, D). Numbers are the pairing number slots available in this group, sorted in ascending order.
func Groups ¶
Groups returns the four Varma group assignments for n players.
For 2-8 players, all numbers are placed in group A (trivial — no federation separation benefit with fewer than 9 players).
For 9-24 players, the FIDE C.05 Annex 2 lookup tables are used. Odd counts use the next-even table with the highest number removed (that number would be the bye dummy in round-robin).
Returns an error for n < 2 or n > 24.