Skip to main content

UCI parser and encoder library in python

Project description

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

Project details


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.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ucilark-0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file ucilark-0.3.tar.gz.

File metadata

  • Download URL: ucilark-0.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for ucilark-0.3.tar.gz
Algorithm Hash digest
SHA256 02306c16bb42617e3e56bdec28e931d32fbcb11217692dbafe6acf329599e4f2
MD5 5763788a9ed18bd7e70df49b85cba9e1
BLAKE2b-256 98eacf41374185225d582111ce016005096b8d22022c819afd4c8872b038bb58

See more details on using hashes here.

File details

Details for the file ucilark-0.3-py3-none-any.whl.

File metadata

  • Download URL: ucilark-0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for ucilark-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 de44ed0b08d40ff0b0bf3de46b19fb2a0426548d2498e98c7057888cca695547
MD5 16efbf7fd999667d4d6097907de2576c
BLAKE2b-256 6e48172646052a5dfac99fab90293525164533560d487d4a898adf9237f443d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page