UCI parser and encoder library in python
Project description
ucilark - UCI parser and encoder library in python
based on python lark parsing toolkit.
grammar definition : uci.lark
Installation
pip install ucilark
Usage example
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ucilark-0.1.tar.gz
(4.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ucilark-0.1-py3-none-any.whl
(4.8 kB
view details)
File details
Details for the file ucilark-0.1.tar.gz.
File metadata
- Download URL: ucilark-0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ded3b9f665fa36bb5c075d13f8e2c29538b91445e7bfb95f67530198054841a5
|
|
| MD5 |
d0e8f12fa9be47a5af56190b9a901b46
|
|
| BLAKE2b-256 |
5f36547b28599bd8a3efda68aca98dc950c87e85a585e9cce7805f008a4dac77
|
File details
Details for the file ucilark-0.1-py3-none-any.whl.
File metadata
- Download URL: ucilark-0.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95c61d49aa3b6ec2e7e96e63ee1e634a764dbfdde2aebf4094a104f43ca51d21
|
|
| MD5 |
9e2503351ff00bd91a2912e172ff05af
|
|
| BLAKE2b-256 |
45a9a31c8f9f7bc4c670bf55ec831ff271083380dc85f28d241cde0fdd79c5db
|