Skip to main content

ucilark - UCI parser and encoder library in python

The Universal Chess Interface (UCI) is an open communication protocol that enables chess engines to communicate with user interfaces.

ucilark parses from a UCI line string to a UCI_msg object containing dicts, and can encode the other way around.

Parsing is based on python lark toolkit.

Overview

Installation

pip install ucilark

Usage examples

UCI message: position

from ucilark import UCI_msg

line = "position fen 1r1n1rk1/ppq2p2/2b2bp1/2pB3p/2P4P/4P3/PBQ2PP1/1R3RK1 w - - 0 1"
m = UCI_msg.parse(line)

print(m.cmd)
# "position"

print(m.args)
# {'fen': {'movefen': '1r1n1rk1/ppq2p2/2b2bp1/2pB3p/2P4P/4P3/PBQ2PP1/1R3RK1', 'active': 'w', 'castling': '-', 'enpassant': '-', 'halfmove_clock': 0, 'fullmove_clock': 1}}

assert m.encode() == line

UCI message: info

from ucilark import UCI_msg

line = "info depth 23 seldepth 33 multipv 2 score cp 0 nodes 3358561 nps 7547328 hashfull 13 tbhits 0 time 445 pv d7d5 e4e3 d5f3 e3f3 e7e6 f3e4 f7g6 e4d4 e6f5 f4h6 g6e8 d4d5 e8b5 h6e3 f5g4 d5c5 b5a6 e3d2 a6b7 d2h6 g4f3"
m = UCI_msg.parse(line)

print(m.cmd)
# "info"

print(m.args)
# {'depth': 23, 'seldepth': 33, 'multipv': 2, 'score': {'cp': '0'}, 'nodes': 3358561, 'nps': 7547328, 'hashfull': 13, 'tbhits': 0, 'time': 445, 'pv': ['d7d5', 'e4e3', 'd5f3', 'e3f3', 'e7e6', 'f3e4', 'f7g6', 'e4d4', 'e6f5', 'f4h6', 'g6e8', 'd4d5', 'e8b5', 'h6e3', 'f5g4', 'd5c5', 'b5a6', 'e3d2', 'a6b7', 'd2h6', 'g4f3']}

assert m.encode() == line

Metadata

Release files for ucilark 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ucilark 0.3
File Size Uploaded
ucilark-0.3.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ucilark 0.3
File Interpreter ABI Platform
ucilark-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / ucilark-0.3.tar.gz

Download URL ucilark-0.3.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
02306c16bb42617e3e56bdec28e931d32fbcb11217692dbafe6acf329599e4f2
BLAKE2b-256 checksum
How to use checksums
98eacf41374185225d582111ce016005096b8d22022c819afd4c8872b038bb58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / ucilark-0.3-py3-none-any.whl

Download URL ucilark-0.3-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de44ed0b08d40ff0b0bf3de46b19fb2a0426548d2498e98c7057888cca695547
BLAKE2b-256 checksum
How to use checksums
6e48172646052a5dfac99fab90293525164533560d487d4a898adf9237f443d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page