Skip to content

echecsjs/koya

Repository files navigation

Koya

npm Coverage License: MIT Spec

Koya is a TypeScript library implementing the Koya tiebreak system for round-robin chess tournaments, following the FIDE Tiebreak Regulations (section 9.2). Zero runtime dependencies.

Installation

npm install @echecs/koya

Quick Start

import { koya, tiebreak } from '@echecs/koya';
import type { Game, GameKind, Player, Result } from '@echecs/koya';

// games[n] = round n+1; Game has no `round` field
const games: Game[][] = [
  [{ black: 'B', result: 1, white: 'A' }], // round 1
  [{ black: 'C', result: 0.5, white: 'A' }], // round 2
  [{ black: 'A', result: 0, white: 'D' }], // round 3
  // Unplayed rounds use kind to classify the bye type
  [{ black: '', kind: 'half-bye', result: 0.5, white: 'A' }], // round 4
];

const score = koya('A', games);
// Returns points scored against opponents who achieved >= 50% of the maximum score

API

koya(player, games)

FIDE section 9.2 — Koya score. Returns the total points scored by player only in games played against opponents who achieved at least 50% of the maximum possible score in the tournament. Designed for round-robin (all-play-all) tournaments. Byes are excluded from both the threshold calculation and the score sum. Round is determined by array position: games[0] = round 1, games[1] = round 2, etc. The Game type has no round field. The optional kind?: GameKind field on Game identifies unplayed rounds; byes are excluded regardless of kind.

koya(player: string, games: Game[][]): number

tiebreak is an alias for koya exported under a generic name for use in tiebreak pipelines.

Exports

// Functions
export { koya, tiebreak } from '@echecs/koya';

// Types
export type { Game, GameKind, Player, Result } from '@echecs/koya';

Contributing

Contributions are welcome. Please open an issue at github.com/echecsjs/koya/issues.

About

Koya tiebreak system for round-robin chess tournaments following FIDE rules. Zero dependencies.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors