Search Shortcut cmd + k | ctrl + k
aixchess

Efficiently query large chess game collections

Maintainer(s): thomas-daniels

Installing and Loading

INSTALL aixchess FROM community;
LOAD aixchess;

Example

-- Count en passant moves played in Lichess games from January 2013

WITH lichess_2013_01 AS (
    FROM 'hf://datasets/thomasd1/aix-lichess-database/low_compression/aix_lichess_2013-01_low.parquet'
),
en_passant_move_count AS (
    SELECT
        SUM(
            move_details(movedata).filter(lambda m: m.is_en_passant).length()
        ) AS nb_ep_moves 
    FROM lichess_2013_01
)

FROM en_passant_move_count;

-- Result: 3496

About aixchess

Aix enables efficient storage and querying of large chess game collections. A game's moves are encoded in a binary representation, and this extension provides scalar functions to decode and query these games directly within DuckDB.

See the GitHub repository or blog post for more details.

Added Functions

function_name function_type description comment examples
board_at_position scalar Returns the board at a given position as a struct. NULL NULL
clocks_to_move_times scalar Transform clocks (of one player) into move times, given the clock times and increment. NULL NULL
eval_to_centipawns scalar Returns eval if it is a centipawn evaluation, NULL if mate. NULL NULL
eval_to_mate scalar Returns moves to mate if eval is mate, NULL if centipawn evaluation. NULL NULL
fen_at_position scalar Returns the FEN at a given position. NULL NULL
matches_subfen scalar Returns true if any position matches a given sub-FEN. NULL NULL
move_details scalar Returns a list of details for all moves in the game. NULL NULL
move_details_at scalar Returns the details of a given move in the game. NULL NULL
moved_pieces scalar Returns the moved pieces in order as a string. NULL NULL
moved_pieces_list scalar Returns the moved pieces in order as a list. NULL NULL
piece_counts_at_position scalar Returns the piece counts at a given position. NULL NULL
pieces_at_position scalar Returns the squares where the pieces are at a given position. NULL NULL
recompress scalar Recompresses a game at a given compression level. NULL NULL
scoutfish_query scalar Returns true if a game matches a Scoutfish query. NULL NULL
scoutfish_query_plies scalar Returns the list of plies matching a Scoutfish query. NULL NULL
time_control_lichess scalar Returns the Lichess time control name for given initial time and increment. NULL NULL
to_pgn scalar Represents the game as a PGN string. NULL NULL
to_uci scalar Represents the game as a UCI string. NULL NULL
winning_chances_lichess scalar Converts an evaluation to winning chances using the Lichess formula. NULL NULL
list_eval_to_centipawns macro Apply eval_to_centipawns to all items in a list. NULL NULL
list_eval_to_mate macro Apply eval_to_mate to all items in a list. NULL NULL
list_winning_chances_lichess macro Apply winning_chances_lichess to all items in a list. NULL NULL
is_valid_movedata scalar NULL NULL NULL
clocks_to_move_times__check_nulls scalar NULL NULL NULL
matches_fen scalar NULL NULL NULL
move_details_ext scalar NULL NULL NULL
move_details_ext_at scalar NULL NULL NULL

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

This extension does not add any settings.