Migrates existing GDD and engine design notes from HacknPlan into a new Obsidian vault. This establishes a centralized, version-controlled knowledge base covering engine architecture, game constraints, design decisions, and open questions.
32 lines
1.1 KiB
Markdown
32 lines
1.1 KiB
Markdown
---
|
|
tags:
|
|
- engine
|
|
- rng
|
|
---
|
|
|
|
# Randomness
|
|
|
|
Goal: **the same seed gives the same run** (map, rewards, deck shuffles) on Linux and Windows. Combat does not need to replay exactly. See [[Game Constraints]].
|
|
|
|
## Rng
|
|
|
|
- Our own PCG32 (or xoshiro) generator, **plus our own range and float mapping**.
|
|
- **Never use `std::uniform_int_distribution` or `std::uniform_real_distribution`.** Their output is implementation-defined, so libstdc++ and MSVC produce different values from the same seed. Using them would silently break seed reproducibility across platforms.
|
|
|
|
## RngStreams
|
|
|
|
Independent named streams are derived from the run seed:
|
|
|
|
| Stream | Used for |
|
|
|---|---|
|
|
| `map` | run map generation |
|
|
| `shuffle` | deck shuffles, draws |
|
|
| `rewards` | card, relic and gold rewards |
|
|
| `events` | map events, shops |
|
|
| `combat` | crits, procs, random targets |
|
|
|
|
Because the streams are independent, extra combat randomness can't shift which rewards a seed gives.
|
|
|
|
- Stream states are saved with the run.
|
|
- Scripts get RNG only through bound stream accessors; the language's own random function is removed in the sandbox (see [[Scripting]]).
|