The handshake and the session after it move to uci::protocol: lines, commands and the time go in, lines to write and events come out, deadlines are named instead of waited for. The child process with its reader and supervisor threads is now one transport of it (process.rs, not built for WebAssembly). Behaviour on the computer and Android is unchanged; the fake engine tests pass as before, and the machine has its own tests. chess-import: the parallel passes (booster, position search, opening tallies) go through parallel::map, which runs a single worker on the calling thread; on WebAssembly there is one worker (std threads panic there). read_at and write_all_at have a portable form through the file cursor for targets other than Unix and Windows. The bench command is not built for WebAssembly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.6 KiB
Rust
36 lines
1.6 KiB
Rust
//! UCI engine supervisor.
|
|
//!
|
|
//! 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
|
|
//! processes, so there is no process transport there.
|
|
//!
|
|
//! 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;
|
|
mod events;
|
|
pub mod parse;
|
|
#[cfg(not(target_family = "wasm"))]
|
|
mod process;
|
|
// The machine is built where a transport drives it.
|
|
#[cfg(not(target_family = "wasm"))]
|
|
mod protocol;
|
|
mod types;
|
|
|
|
pub use error::EngineError;
|
|
pub use events::{EngineEvent, TerminationReason, Waker};
|
|
#[cfg(not(target_family = "wasm"))]
|
|
pub use process::{Engine, EngineConfig, EngineHandle};
|
|
pub use types::{
|
|
EngineInfo, EngineOption, EnginePosition, EngineScore, OptionKind, PositionBase, Score,
|
|
ScoreBound, SearchId, SearchInfo, SearchLimits, Side, Timeouts, WhiteEval, WhiteScore,
|
|
};
|