Skip to main content

Crate turnbase_cli

Crate turnbase_cli 

Source
Expand description

A generic command-line runner: give it any [turnbase::Game] and get a headless CLI, bot self-play, and interactive play, with no per-game plumbing.

Two tiers:

  • run needs only a Game whose State/Action/View are serde-serializable. It provides new/query/act (headless, file-backed via [turnbase_session::FileSession]), self-play (bots), and a text play. Actions on the command line are JSON, so it works for any game.
  • run_tui (the tui feature, on by default) additionally requires [turnbase_simulator::PrintableGame] and swaps the text play for the retroglyph dashboard. Everything else is identical.

A game’s main is then one line, e.g. turnbase_cli::run(TicTacToe) or turnbase_cli::run_tui(Coup::new(4)).

Structs§

PlayArgs
Arguments for the interactive play command, exposed so a game that passes its own play handler to run_with_play can read them.

Functions§

run
Runs the text/headless CLI for game: new, query, act, self-play, and a text play. Works for any game whose types are serde-serializable.
run_tui
Like run, but play opens the retroglyph dashboard instead of the text stepper. Requires the game to implement [PrintableGame].
run_with_play
Like run, but the game supplies its own interactive play handler (a bespoke UI, say) rather than the built-in text stepper.