Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
RandomSource.hpp File Reference

The engine's randomness, and the only place its seed lives. More...

#include <chrono>
#include <random>
#include <string_view>
#include "Types.hpp"
#include "Hash.hpp"
Include dependency graph for RandomSource.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  esengine::RandomSource

Namespaces

namespace  esengine

Functions

void esengine::setPendingRandomSeed (u32 seed)
bool esengine::takePendingRandomSeed (u32 &out)

Detailed Description

The engine's randomness, and the only place its seed lives.

Seeded from the clock, so a game nobody configured varies from run to run — which is what a player wants of particles. Reseeded on demand, so one run can be reproduced: a replay, a bug report, a pixel assertion about a frame.

A consumer takes a NAMED stream rather than sharing one generator. Sharing makes every subsystem's sequence depend on how many numbers its neighbours drew, so adding an emitter would change what the AI rolled and a seed would stop meaning anything. The name is folded into the root instead, so streams are independent of each other and stable as the engine grows.

Definition in file RandomSource.hpp.