vampirc-uci

Vampirc UCI is a Universal Chess Interface (UCI) protocol parser and serializer.
The UCI protocol is a way for a chess engine to communicate with a chessboard GUI, such as Cute Chess.
The Vampirc Project is a chess engine and chess library suite, written in Rust. It is named for the Slovenian grandmaster Vasja Pirc, and, I guess, vampires? I dunno.
Vampirc UCI uses the PEST parser to parse the UCI messages. If you want to build your own abstractions of the protocol, the corresponding PEG grammar is available here.
Installing the library
To use the crate, declare a dependency on it in your Cargo.toml file:
[]
= "0.8"
Then reference the vampirc_uci crate in your crate root:
extern crate vampirc_uci;
Usage
- Import either the
parse(..)method or theparse_strict(..)method. The difference between them is thatparse_strict(..)will return apest::error::Errorif any of the input is unrecognized or violates the rules of the PEG grammar, whereasparsewill simply ignore any such input. The latter is the approach recommended by the protocol specification.
use parse;
- Some other useful imports (for message representation):
use ;
- Parse some input:
let messages: MessageList = parse;
- Do something with the parsed messages:
for m in messages
- Outputting the messages
let message = Option;
println!; // Outputs "option name Selectivity type spin default 2 min 0 max 4"
API
The full API documentation is available at docs.rs.
New in 0.8.1
- Added
parse_with_unknown()method that instead of ignoring unknown messages (likeparse) or throwing an error (likeparse_strict) returns them as aUciMessage::Unknownvariant.
New in 0.8.0
- Support for parsing of the
infomessage, with the UciAttributeInfo enum representing all 17 types of messages described by the UCI documentation, as well as any other info message via the Any variant.
New in 0.7.5
- Support for parsing of the
optionmessage. - Proper support for
<empty>strings inoptionandsetoption.
vampirc-io
This crate goes together well with the vampirc-io crate, a library for non-blocking communication over standard input and output (which is how UCI communication is usually conducted), based on the Tokio IO framework.
Limitations and 1.0
The library is functionally complete – it supports the parsing and serialization to string of all the messages described by the UCI specification. Before the 1.0 version can be released, though, this library needs to be battle tested more, especially in the upcoming Vampirc chess engine.
Furthermore, as I am fairly new to Rust, I want to make sure the implementation of this protocol parser is Rust-idiomatic before releasing 1.0. For this reason, the API should not be considered completely stable until 1.0 is released.
Additionally, some performance testing would also not go amiss.
Supported engine-bound messages (100%)
ucidebugisreadyregisterpositionsetoptionucinewgamestopponderhitquitgo
Supported GUI-bound messages (100%)
iduciokreadyokbestmovecopyprotectionregistrationoptioninfo