Skip to content

KDesp73/libuci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libuci

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).

Layout

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

Build

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 clean

Outputs:

  • libuci.a — static library
  • libuci.so — shared library
  • uci — links the static library and runs the example in src/main.c

Compile your own engine:

cc -Isrc myengine.c -L/path/to/libuci -luci -pthread -o myengine

Usage sketch

  1. Fill an uci_callbacks struct; on_search is required (runs on the worker thread after go).
  2. Optionally describe UCI options with uci_option_desc and pass them to uci_create.
  3. Either call uci_run for a stdin loop, or feed lines yourself with uci_handle_line (e.g. tests or embedding).
  4. From the search thread, poll uci_stop_requested, send uci_send_info / uci_send_bestmove, etc.
  5. uci_destroy shuts down the worker and frees state.

See src/main.c for a minimal runnable engine and docs/ for extra notes.

About

Small engine-agnostic UCI C library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors