Skip to main content

Module bots

Module bots 

Source
Expand description

Playtest bots over any TurnRules game: players made of code, the loop that lets them play a game to its end, a seeded random bot, two bots that plan on copies of the game (over determinize): one that weighs its next command alone (rollout) and one that plans its side’s whole turn, several commands deep (plan), the order of the few commands such a bot tries first (order), a playtest runner that lets several bots play a stage many times and checks how often each succeeds (playtest), and an autobalance search that changes the stage, never the bots, until each succeeds about as often as wanted (balance), and a score made of the game’s named counts times a persona’s weights, with personas as data (weigh).

A game’s own bots (a baseline, personas) implement Bot for its state, and its measures watch the loop through play_observed. Bots never rewind: the loop keeps no history. Like the rest of the core, a bot is pure: the same seed and the same states give the same commands.

Re-exports§

pub use balance::BalanceSettings;
pub use balance::Balanced;
pub use balance::Knob;
pub use balance::Stop;
pub use balance::autobalance;
pub use balance::autobalance_by;
pub use determinize::Determinize;
pub use determinize::Evaluate;
pub use order::Ranked;
pub use order::ranked_order;
pub use plan::PlanSearch;
pub use plan::PlanSettings;
pub use plan::TurnPlan;
pub use rollout::Horizon;
pub use rollout::Order;
pub use rollout::Playout;
pub use rollout::Rollout;
pub use rollout::RolloutSearch;
pub use rollout::RolloutSettings;
pub use rollout::Unordered;
pub use weigh::Persona;
pub use weigh::UnknownFeature;
pub use weigh::Weighted;
pub use weigh::Weights;

Modules§

balance
An autobalance search: the game’s Knobs change a stage a little at a time (one more enemy, a weaker trap, a later ambush), the playtest runner replays it with the bots, and the search stops when every rate check is inside its band. autobalance does it all and says what it changed, in the knobs’ own words. autobalance_by is the same search with the caller playing each setting (on threads of its own) and saying when to stop (a time limit).
determinize
What a bot that plans may look at: a copy of the game as its side knows it (Determinize), and how good a state is for a side (Evaluate).
order
A candidate order made of ranked groups: the few commands worth trying first, out of hundreds of legal ones.
plan
A turn planner over any Determinize game: a beam search over its own side’s commands.
playtest
A playtest runner: several named bots (Entrants) each play a stage K times from the same seeds, the game measures every try (Measure), and data-file Checks say per bot whether it succeeded about as often as the designer wants: ✓, ✗ too hard or ⚠ too easy.
rollout
A rollout bot over any Determinize game: flat Monte Carlo.
weigh
Weighted features: a bot’s score as the game’s named counts times weights from a file, and personas (how a bot thinks and what it cares about) as data.

Structs§

PlayError
A command the game refused during a play: a bug in a bot, never skipped. Build it with PlayError::new (ADR-0039).
RandomBot
A bot that picks one of TurnRules::legal_commands at random, from its own seeded RNG.
Report
How a play went.

Traits§

Bot
A player made of code. play asks it for every command of the sides it plays.
Sides
A game whose state says whose move it is and which turn it is, so a loop can ask the right bot for each command.

Functions§

play
Plays rules until the game ends or turn limit has passed, asking the bot of the side to move for each command. bots_by_side gives one bot per side; a side with no bot there is a mistake in the caller and panics.
play_observed
play, telling observe about every applied command: the game after it, the command and the events it gave. A game’s measures are built this way.