Randomness and determinism
Rng
All randomness comes from the rng that setup and apply_action receive. Boardweaver seeds it with new secret bytes for every step, so no seat can predict a draw.
| Method | Answers |
|---|---|
rng.below(bound) |
a u32 from 0 to bound - 1. Panics when bound is 0. |
rng.roll(sides) |
a u32 from 1 to sides, like a die. Panics when sides is 0. |
rng.shuffle(&mut slice) |
shuffles a slice in place. |
rng.seed() |
a new Seed, for a bot's simulated step (Bots). |
To shuffle a space's pieces, call table.shuffle(space_id, rng). It also records the shuffle as a movement.
A step that draws from Rng ends the seat's decision, whatever its intent (Offers, intents and decisions). The seat cannot undo that decision (Changing the state). The board shows the result only after Boardweaver applies the step.
Determinism
The same state, action and seed must always give the same result. The client shows a draft step on the board before Boardweaver applies it. When the two results differ, the player sees the step change after taking it.
- Keep everything in the state. The game functions take no
self, and the build refusesstaticandthread_local(Builds, limits and errors). - Iterate in a fixed order. Use
BTreeMap,BTreeSetor aVec. The order of aHashMaporHashSetcan differ between two runs of the same game logic. - Draw only from the
rngyou receive. The game logic has no files and no real clock.