# turnbase-match - Complete API Documentation > Turn-loop orchestration for the Turnbase engine: seat agents and a match stepper **Version:** 0.0.0 **Authors:** Matan Lurey **License:** MIT OR Apache-2.0 **Repository:** https://github.com/crates-lurey-io/turnbase **Keywords:** game-engine, turn-based, deterministic, gamedev, ai Generated: 2026-07-25 17:07:54 UTC Created by: [cargo-llms-txt](https://github.com/masinc/cargo-llms-txt) ## Table of Contents ### src/lib.rs - pub use simulator::{PlayerAgent, Simulator} ### src/simulator.rs - pub enum PlayerAgent - pub struct Simulator - impl Simulator - impl Simulator - impl Game for tests::CountToThree - impl Game for tests::RevealOnce --- ## README.md ### turnbase-match Turn-loop orchestration for the Turnbase engine: seat agents and a match stepper Part of the [turnbase](https://github.com/crates-lurey-io/turnbase) workspace. --- ## src/lib.rs ### simulator::{PlayerAgent, Simulator} ```rust pub use simulator::{PlayerAgent, Simulator}; ``` ## src/simulator.rs ### PlayerAgent ```rust pub enum PlayerAgent { Human, Ai(Box), } ``` Who is deciding a seat's moves. A seat with no entry in [`Simulator`]'s agent map behaves like [`Human`]: it blocks [`Simulator::step`] rather than panicking or being skipped, so a game can add players without wiring every seat up front. [`Human`]: PlayerAgent::Human ### Simulator ```rust pub struct Simulator { } ``` Coordinates one match: the rules (`G`), its current position, which agent controls each seat, and a running log of committed actions. Pure in-memory bookkeeping: [`Simulator::step`] and [`Simulator::select_human_action`] are the only ways the position changes, and both just forward to [`Game::apply`]. There is no terminal, socket, or timer here, so a simulator runs identically under `cargo test` and behind a rendering client. A chance node ([`PlayerId::CHANCE`] active) is not a seat any agent controls; [`Simulator::step`] resolves it automatically by sampling from `chance`, a generator seeded from the match seed but offset so it does not share a stream with the state's own generator. ### impl Simulator ```rust impl Simulator { pub fn new(game: G, seed: u64, agents: HashMap>) -> Self; pub fn game(&self) -> &G; pub fn state(&self) -> &G::State; pub fn log_history(&self) -> &[String]; pub fn awaiting_human(&self) -> Option; pub fn is_terminal(&self) -> bool; pub fn primary_human(&self) -> Option; } ``` ### impl Simulator ```rust impl Simulator { pub fn step(&mut self) -> Result; pub fn select_human_action(&mut self, player: PlayerId, action: G::Action) -> Result<(), Error>; } ``` ### impl Game for CountToThree ```rust impl Game for CountToThree { } ``` ### impl Game for RevealOnce ```rust impl Game for RevealOnce { } ```