Package-level declarations

Types

Link copied to clipboard
class ArenaTournament(val eloCalculator: EloCalculator = EloCalculator()) : Tournament

An arena style tournament.

Link copied to clipboard
class EcoInfo

A container class representing the information about a chess opening based on the Encyclopedia of Chess Openings (ECO). It is immutable.

Link copied to clipboard
open class EloCalculator(var impactFactor: Double = 32.0, var rangeFactor: Double = 400.0, var logisticBase: Double = 10.0)

Calculates and updates player ratings based on the Elo rating system. This class uses a logistic distribution to predict the outcome of a match between two players and adjusts their ratings based on the difference between the actual and expected results.

Link copied to clipboard

Class for manipulating games. It allows starting a game from a configurable initial position and with various configuration options, such as the game type (match or analysis), and how to apply the three-fold repetition and 50-move rules.

Link copied to clipboard
interface Match

Represents a single match or pairing within a tournament. This interface tracks the two participants (White and Black) and the final outcome of their game.

Link copied to clipboard
open class Move

Represents a single player's move on the board. It does not store information about the origin position, as its primary purpose is move representation. Its string representation is the full algebraic notation of the move as used in the UCI protocol (e.g., "e2e4", "a7a8q"). It is immutable.

Link copied to clipboard

Exception thrown when inconsistencies occur in functionalities related to move validation or generation logic.

Link copied to clipboard

This enum represents the types of move notation supported by this library. This enum is used as an argument in functions related to move validation and generation logic.

Link copied to clipboard

Represents the final or current result of a tournament match. Each outcome defines the points awarded to both the white and black players, as well as a standard string representation used for display.

Link copied to clipboard
enum Piece : Enum<Piece>

This class represents the chess pieces on the board. Each piece has a corresponding side (color).

Link copied to clipboard
class Player(val name: String, val initialElo: Int) : Comparable<Player>

Represents a participant in a tournament, tracking their score, opponents, and eligibility.

Link copied to clipboard
class Position

Class to represent a position on the chessboard. It is immutable.

Link copied to clipboard
open class RatedMatch(val white: Player, val black: Player, val eloCalculator: EloCalculator) : Match

Represents a standard competitive match between two Players. This class handles the automation of score accumulation, Elo rating updates, and opponent tracking once an outcome is reached.

Link copied to clipboard

Represents a score in a tournament. This class uses an internal integer value to represent scores in increments of 0.5. For example, a value of 1 represents a score of 0.5, and 2 represents 1.0.

Link copied to clipboard
enum Side : Enum<Side>

This enum represents the two sides (colors) in a chess game: White or Black.

Link copied to clipboard
enum Square : Enum<Square>

This enum represents the squares on the chessboard. The order is set such that when calling ordinal, the integer 0 corresponds to A1, 1 corresponds to B1, and so on, following the file-major order (A1, B1, C1... H1, A2, B2... H8), with 63 corresponding to H8.

Link copied to clipboard
class SwissTournament(val eloCalculator: EloCalculator = EloCalculator()) : Tournament

A swiss style tournament.

Link copied to clipboard
interface Tiebreaker

Internal contract for defining tournament tie-breaking strategies. Implementing classes must define how to calculate a specific score for a player. The interface automatically handles the creation of a descending Comparator based on that score.

Link copied to clipboard
interface Tournament

Contract for tournament management.

Link copied to clipboard
class Tuple<T1, T2>

Auxiliary generic class to represent a pair of related, heterogeneous elements. It is immutable.

Properties

Link copied to clipboard

A list of tuples, where each tuple represents a legal move from this position and the resulting new position (Tuple). This list effectively defines the legal branches of the game tree from the current position.

Link copied to clipboard

True if the position is a forced draw. This is true if the position results in a stalemate or lackOfMaterial. False otherwise.

Link copied to clipboard

Returns a bitboard representing the occupancy of all enemy pieces.

Link copied to clipboard

The square exposed to an en passant capture, if one exists. Returns null if no en passant capture is possible in the current position.

Link copied to clipboard

Returns a bitboard representing the occupancy of all friendly pieces.

Link copied to clipboard

True if the game state is concluded (terminal position), either due to a forced draw or checkmate. False otherwise.

Link copied to clipboard

The side (Side.WHITE or Side.BLACK) whose turn it is to move.

Functions

Link copied to clipboard
fun analysisGame(idSupplier: () -> Any? = { null }): Game

Creates a new Game instance configured for analysis. Uses Game.GameMode.ANALYSIS with Game.ThreeRepetitionsMode.AWARE and Game.FiftyMovesRuleMode.AWARE, making the game fully mutable.

Link copied to clipboard

Determines if Black has insufficient material to win the game. Returns true if the current pieces for Black cannot potentially lead to a checkmate.

Link copied to clipboard
fun customGame(gameMode: Game.GameMode, threeRepetitionsMode: Game.ThreeRepetitionsMode, fiftyMovesRuleMode: Game.FiftyMovesRuleMode, initialFen: String? = null, initialTags: Map<String, String>? = null, idSupplier: () -> Any? = { null }): Game

Creates a new Game instance with fully customizable parameters. Allows setting the game mode, rule enforcement, initial FEN, and PGN tags.

Link copied to clipboard

Deletes all moves that preceded the provided node in the main line. The node (and its position) becomes the new effective start of the game, creating a new RootNode.

Link copied to clipboard

Deletes all moves (the main line continuation and any variations) that follow the provided node. The node provided remains in the game.

Link copied to clipboard

Deletes the provided node and all subsequent moves/variations in its subtree. The move represented by the node is effectively removed from the game.

Link copied to clipboard

Creates a new Position identical to the current one, but with the active side toggled.

Link copied to clipboard

Returns true if the evaluated Move is legal in the current position, and false otherwise.

fun Position.isLegal(move: String, notation: Notation = Notation.UCI): Boolean

Returns true if the move specified in the given notation is legal in the current position. If no notation is specified, Notation.UCI is assumed.

Link copied to clipboard

Retrieves the new Position that results from executing the provided legal Move. Throws a MoveException if the provided move is not legal in the current position.

fun Position.move(move: String, notation: Notation = Notation.UCI): Position

Retrieves the new Position that results from executing the move specified in the given notation. Throws a MoveException if the move is not legal. If no notation is provided, Notation.UCI is assumed.

Link copied to clipboard
fun moveOf(move: String): Move

Creates a Move object from its UCI notation string (e.g., "e7e8q").

fun moveOf(origin: Square, target: Square): Move

Creates a Move object from the origin square and target square Square enum constants.

fun moveOf(origin: Int, target: Int): Move

Creates a Move object from the specified origin and target squares (using Int as the squares types).

fun moveOf(origin: Square, target: Square, promotionPiece: Piece): Move

Creates a Move object from the origin square, target square, and the promotion piece, using Square and Piece enum constants.

fun moveOf(origin: Int, target: Int, promotionPiece: Int): Move

Creates a Move object from the specified origin and target squares (using Int as the squares types) and the promotion piece.

Link copied to clipboard
fun parseGames(pgnInput: String, idSupplier: () -> Any? = { null }): List<Game>

Parses a string containing one or more games in Portable Game Notation (PGN) format. Games are returned in Game.GameMode.ANALYSIS mode, making them mutable for subsequent use.

Link copied to clipboard

Returns the standard starting Position (the startpos FEN).

Factory function to create a Position object from a FEN string. Throws an exception if the FEN string is invalid or leads to an illegal position.

Link copied to clipboard
fun scoreOf(score: String): Score

Parses a string representation of a score into a Score. The input must be a string ending in either ".0" (for whole points) or ".5" (for half points).

Link copied to clipboard
fun strictMatch(idSupplier: () -> Any? = { null }): Game

Creates a new Game instance configured for strict competitive match play. Uses Game.GameMode.MATCH with strict enforcement for the three-fold repetition and 50-move rules.

Link copied to clipboard

Factory function that creates a composite Comparator for Players based on a prioritized list of tie-breaker criteria. The function chains the comparators in the order provided. If the first tie-breaker results in a tie, it moves to the second, and so on.

Link copied to clipboard

Factory function that maps a string identifier to a concrete Tiebreaker strategy.

Link copied to clipboard
fun tournament(type: String, eloCalculator: EloCalculator = EloCalculator(), comparator: Comparator<Player> = defaultTiebreakerComparator): Tournament

Factory function to create a Tournament instance based on the specified type.

Link copied to clipboard

Removes the last node in the main line, effectively undoing the last move, and returns the parent node. This function only operates on the primary variation (main line).

Link copied to clipboard
fun visibleSquares(piece: Piece, square: Square, position: Position): Long

Calculates a bitboard of all squares "visible" or attacked by a specific piece from a given square.

Link copied to clipboard

Determines if White has insufficient material to win the game. Returns true if the current pieces for White cannot potentially lead to a checkmate.