2026-10-30 14:19:21 +03:00
|
|
|
//! UCI engine supervisor.
|
2026-10-18 01:54:06 +03:00
|
|
|
//!
|
2026-10-30 14:19:21 +03:00
|
|
|
//! The protocol is a state machine without I/O ([`protocol`]); a transport drives
|
|
|
|
|
//! it. On a computer the engine is a child process started without a shell:
|
|
|
|
|
//! stdout and stderr are read by two dedicated threads, a supervisor thread
|
|
|
|
|
//! feeds the machine. The UI talks to it through the non-blocking
|
|
|
|
|
//! [`EngineHandle`] and polls [`EngineEvent`]s every frame; the [`Waker`]
|
|
|
|
|
//! callback is invoked after each new event. WebAssembly in a browser has no
|
uci: the engine as a Web Worker in a browser, on the same protocol machine; game-review: the process job is native
On WebAssembly the engine is a Web Worker: a line of UCI is one message each
way, the protocol machine is driven by the worker's messages and by timers set
for its deadlines; the handshake does not block (Engine::start_worker gives a
Starting, polled until readyok). EngineHandle has the same methods as the
process one, minus those that block or name a process. Option and search
checks are shared by both transports.
tests/worker.rs runs the worker transport against a fake engine in JavaScript
in headless Firefox (apps/web/check/uci-worker.mjs: wasm-bindgen-test-runner
serves, a WebDriver BiDi client reads the outcome): handshake, analysis and
stop, coalescing of rapid requests without mixing output, an engine hung on
stop, a crash, and every handshake failure. 5 of 5 pass.
game-review: the job in engine processes (run and its workers) moves to
job/engines.rs, built where there are processes. .cargo/config.toml: the
getrandom backend of WebAssembly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 14:29:12 +03:00
|
|
|
//! processes: there the engine is a Web Worker, its handle the same, its start
|
|
|
|
|
//! not blocking ([`Engine::start_worker`]).
|
2026-10-18 01:54:06 +03:00
|
|
|
//!
|
|
|
|
|
//! Search boundary: UCI has no request ids. A new `position`/`go` is written
|
|
|
|
|
//! only after the previous search ended with `bestmove` and a subsequent
|
|
|
|
|
//! `isready`/`readyok` round trip, so output of an old search can never be
|
|
|
|
|
//! attributed to a newer [`SearchId`]. Rapid requests are coalesced: only the
|
|
|
|
|
//! latest pending request is started, the others are reported as
|
|
|
|
|
//! [`EngineEvent::Superseded`]. No dependency on egui or chess-core:
|
|
|
|
|
//! positions are strings (FEN / UCI moves).
|
|
|
|
|
|
|
|
|
|
mod error;
|
2026-10-30 14:19:21 +03:00
|
|
|
mod events;
|
2026-10-18 01:54:06 +03:00
|
|
|
pub mod parse;
|
2026-10-30 14:19:21 +03:00
|
|
|
#[cfg(not(target_family = "wasm"))]
|
|
|
|
|
mod process;
|
|
|
|
|
mod protocol;
|
2026-10-18 01:54:06 +03:00
|
|
|
mod types;
|
uci: the engine as a Web Worker in a browser, on the same protocol machine; game-review: the process job is native
On WebAssembly the engine is a Web Worker: a line of UCI is one message each
way, the protocol machine is driven by the worker's messages and by timers set
for its deadlines; the handshake does not block (Engine::start_worker gives a
Starting, polled until readyok). EngineHandle has the same methods as the
process one, minus those that block or name a process. Option and search
checks are shared by both transports.
tests/worker.rs runs the worker transport against a fake engine in JavaScript
in headless Firefox (apps/web/check/uci-worker.mjs: wasm-bindgen-test-runner
serves, a WebDriver BiDi client reads the outcome): handshake, analysis and
stop, coalescing of rapid requests without mixing output, an engine hung on
stop, a crash, and every handshake failure. 5 of 5 pass.
game-review: the job in engine processes (run and its workers) moves to
job/engines.rs, built where there are processes. .cargo/config.toml: the
getrandom backend of WebAssembly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 14:29:12 +03:00
|
|
|
#[cfg(target_family = "wasm")]
|
|
|
|
|
mod worker;
|
2026-10-18 01:54:06 +03:00
|
|
|
|
|
|
|
|
pub use error::EngineError;
|
2026-10-30 14:19:21 +03:00
|
|
|
pub use events::{EngineEvent, TerminationReason, Waker};
|
|
|
|
|
#[cfg(not(target_family = "wasm"))]
|
|
|
|
|
pub use process::{Engine, EngineConfig, EngineHandle};
|
2026-10-18 01:54:06 +03:00
|
|
|
pub use types::{
|
|
|
|
|
EngineInfo, EngineOption, EnginePosition, EngineScore, OptionKind, PositionBase, Score,
|
|
|
|
|
ScoreBound, SearchId, SearchInfo, SearchLimits, Side, Timeouts, WhiteEval, WhiteScore,
|
|
|
|
|
};
|
2026-10-30 15:09:17 +03:00
|
|
|
#[cfg(target_family = "wasm")]
|
|
|
|
|
pub use worker::{Engine, EngineHandle, Starting, WorkerConfig};
|