Small C library for chess engines that speak the Universal Chess Interface (UCI). It handles line parsing, command dispatch, option registration, a background search worker thread, and thread-safe stdout, not board representation or search.
Public API: src/uci.h (keep this path when vendoring; there is no separate include/ tree).
| File | Role |
|---|---|
src/uci.h |
Public types and function declarations |
src/internal.h |
Shared struct uci_engine and cross-file helpers (implementation only) |
src/core.c |
uci_create, uci_destroy, uci_userdata |
src/options.c |
Registered options, setoption values, uci_option_get_*, uci_debug_enabled |
src/worker.c |
Search worker thread, stop/quit flags, uci_wait_search |
src/output.c |
Locked stdout, uci_printf, uci_send_* |
src/dispatch.c |
uci_handle_line, uci_run |
src/parse.c |
uci_parse_go_line, uci_parse_position_line, uci_parse_setoption_line |
src/main.c |
Minimal example engine |
Requires a C11-capable compiler and POSIX threads (-pthread).
make # default: help
make all # static + shared libs, example `uci` binary
make test # parser unit tests
make cleanOutputs:
libuci.a— static librarylibuci.so— shared libraryuci— links the static library and runs the example insrc/main.c
Compile your own engine:
cc -Isrc myengine.c -L/path/to/libuci -luci -pthread -o myengine- Fill an
uci_callbacksstruct;on_searchis required (runs on the worker thread aftergo). - Optionally describe UCI options with
uci_option_descand pass them touci_create. - Either call
uci_runfor a stdin loop, or feed lines yourself withuci_handle_line(e.g. tests or embedding). - From the search thread, poll
uci_stop_requested, senduci_send_info/uci_send_bestmove, etc. uci_destroyshuts down the worker and frees state.
See src/main.c for a minimal runnable engine and docs/ for extra notes.