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
- usage examples bellow
- the Lark-flavoured EBNF grammar definition of supported messages : uci.lark
- (only a subset of the UCI specification is supported)
- the code at ucilark.py
- some tests at test_ucilark.py.
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ucilark-0.3.tar.gz | 4.4 kB | Without provenance | Details for ucilark-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ucilark-0.3-py3-none-any.whl | Python 3 | none | any | Details for ucilark-0.3-py3-none-any.whl |
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
|
Security for ucilark 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.