Expand description
Shuyi Engine’s core: the seeded RNG, timers in steps or turns
(timer), ease curves and tweens drawn from the time alone, in
integers (ease: Ease, Tween, Lerp), the simulation traits (turns, TurnRules, and fixed
steps in time, tick: TickSim, its input, its records and their
replay), a toy one for the engine’s tests (toy, with
the toy feature) and the tactics kit (a square grid, paths over it, the tiles each piece can
strike and the danger at a tile (threat), turns and their history,
and bots that play a game to its end, among them a rollout bot that
plans on copies of the game: Determinize, Evaluate, Order,
Unordered, Playout, Rollout, RolloutSettings,
RolloutSearch and Horizon, a turn planner that plans its
side’s whole turn on them: TurnPlan, PlanSettings and
PlanSearch, the few candidates such a bot tries first, in ranked
groups (ranked_order, Ranked) and for grid games
(TacticsOrder, OrderHooks), a playtest runner that checks how often each of
several bots succeeds, bots::playtest, and an autobalance search
whose Knobs change a stage until each lands in its band:
autobalance, autobalance_by, BalanceSettings, Balanced
and Stop), a hash of a state that replays compare, the stamp of
what made a record or a save (made), the version every save
names, and what text and stories need below the assets:
character ids and the {token} splitter.
Pure and deterministic: no I/O, no clock, no platform. A game’s rules crate sits on it and keeps its own rules, turn loop and data (game ADR-0063 §2, §6).
Re-exports§
pub use bots::BalanceSettings;pub use bots::Balanced;pub use bots::Bot;pub use bots::Determinize;pub use bots::Evaluate;pub use bots::Horizon;pub use bots::Knob;pub use bots::Order;pub use bots::PlanSearch;pub use bots::PlanSettings;pub use bots::PlayError;pub use bots::Playout;pub use bots::RandomBot;pub use bots::Ranked;pub use bots::Report;pub use bots::Rollout;pub use bots::RolloutSearch;pub use bots::RolloutSettings;pub use bots::Sides;pub use bots::Stop;pub use bots::TurnPlan;pub use bots::Unordered;pub use bots::autobalance;pub use bots::autobalance_by;pub use bots::play;pub use bots::play_observed;pub use bots::ranked_order;pub use character::CharacterId;pub use ease::Ease;pub use ease::Easing;pub use ease::Family;pub use ease::Lerp;pub use ease::Tween;pub use grid::Dir;pub use grid::Grid;pub use grid::GridSizeError;pub use grid::Pos;pub use grid::TerrainId;pub use grid::TileSet;pub use hash::HashError;pub use hash::StateHash;pub use hash::state_hash;pub use history::History;pub use history::NoSuchPoint;pub use history::Replayed;pub use made::ContentHash;pub use made::Made;pub use path::Reach;pub use path::flow_field;pub use path::reachable;pub use rng::RandomSource;pub use rng::ScriptedRng;pub use rng::SimRng;pub use save::SaveFormat;pub use save::SaveHeader;pub use text::Part;pub use text::split_tokens;pub use threat::Danger;pub use threat::GoalDistance;pub use threat::OrderHooks;pub use threat::Ranges;pub use threat::Strike;pub use threat::TacticsOrder;pub use threat::Threat;pub use threat::Threats;pub use threat::strike_area;pub use threat::strike_area_from;pub use tick::ActionId;pub use tick::SeatInput;pub use tick::TickInput;pub use tick::TickRecord;pub use tick::TickSim;pub use timer::Countdown;pub use timer::Every;pub use timer::STEPS_PER_SECOND;pub use timer::ms_from_steps;pub use timer::steps_from_ms;pub use turn::TurnRules;
Modules§
- bots
- Playtest bots over any
TurnRulesgame: 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 (overdeterminize): 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). - character
- Who a game’s characters are, by id: who speaks in a dialogue scene, who a piece on the board is.
- ease
- Ease curves and tweens, in integers, drawn from the time alone.
- grid
- Grid geometry: positions, the four directions, a rectangular grid and sets of its tiles, and the terrain a tile is.
- hash
- A hash of a game’s state, the same on every platform and every run: what a replay compares step by step to find where two runs part, and what two machines playing one game can exchange to find a desync.
- history
- A game’s history: the state it started in and every command applied
since. Its rules are deterministic (
TurnRules), so any earlier point is rebuilt by replaying, which is what replays, rewinds and saving a game in progress need. What a rewind costs, if anything, is the game’s. - made
- What made a record or a save: the engine’s version, the game’s word
for its build, and a fingerprint of the content it ran on (
Made). A record played back by another build can play differently without a bug in either; its stamp tells that apart from a desync. - path
- Paths over a square grid: where a walker can go on a budget and the
cheapest path there (
reachable), and how far every tile is from a set of goals (flow_field). The game says what a tile costs with a cost function; the rules of who may stand where stay the game’s. - rng
- Seeded random numbers for a deterministic simulation.
- save
- Save versions (game ADR-0039): every save names the version of its format
that wrote it, and a build reads only its own version. A save of another
version is refused, never migrated.
SaveHeaderreads the version of any save, even one whose other fields no longer parse, so the refusal can say “another version” rather than “damaged”. What a save holds, and where it is kept, are the game’s. - text
{token}text: a game’s text names what is filled in when it is shown between braces (Hello, {name}.).split_tokenscuts such text into its plain parts and its tokens; what a token stands for is the game’s.- threat
- Threat areas over a square grid: the tiles a piece can strike next
turn (
strike_area,strike_area_from), which threats reach a tile and whether it is safe (Threats), how much danger a tile stands in by the game’s own forecast (Threats::danger), and how far a piece would walk from a tile to the nearest of some goals (GoalDistance). It is the danger zone a player reads: a bot that plays like a person keeps out of it, a roguelike draws a monster’s reach as an overlay, a tower-defense game shows a tower’s coverage. On them,TacticsOrderlists the few commands a planning bot tries first: every piece’s best strike, then each piece’s step towards the goals and its step to safety, and the end of the turn always kept (OrderHooks,Kind). - tick
- Rules that step in time (ADR-0003 §2): a game whose rules run 60 fixed
steps a second implements
TickSim. Each step takes aTickInput, what each seat’s player pressed, held and released in it, and a run is its seed and its inputs, aTickRecord, whichreplayplays again, giving the state’s hash after each step. - timer
- Timers a game’s rules set and forget, counted in steps or turns:
Countdown, which fires once and is the cooldown too, andEvery, which repeats. With them, the step rate (STEPS_PER_SECOND) and the two conversions a length in milliseconds goes through (steps_from_ms,ms_from_steps). - turn
- The rules of a turn-based game as the engine’s generic code sees them:
a state that takes commands and answers with what happened. The game
keeps its own turn loop, phases and rules, and implements
TurnRulesfor its state;History(replay, rewind, saving a game in progress) is written against it.