Skip to content

SceneRandomSource

Defined in: SceneRandomSource.ts:22

Creates the RNG each scene reads through RandomKey, and owns the seed those RNGs start from. The engine owns one, reachable as engine.sceneRandom or through SceneRandomSourceKey.

A scene’s RNG starts from the first seed that is set, in this order: the seed passed to setSeed, the default seed a test harness installs (DebugPlugin’s deterministicSeed), then a fresh non-deterministic seed. globalRandom is a separate generator and none of these seeds reach it.

new SceneRandomSource(scenes): SceneRandomSource

Defined in: SceneRandomSource.ts:26

SceneManager

SceneRandomSource

clearSeed(): void

Defined in: SceneRandomSource.ts:55

Undo setSeed. Scenes on the stack keep their current sequence. Scenes that enter later start from the default seed when a test harness installed one, otherwise from a fresh seed.

void


createSceneRandom(): RandomService

Defined in: SceneRandomSource.ts:32

Create a scene RNG from the current seed policy. The engine calls this as each scene enters and registers the result under RandomKey.

RandomService


setDefaultSeed(seed): void

Defined in: SceneRandomSource.ts:64

Internal

DebugPlugin installs its deterministicSeed through this hook and clears it with undefined. A seed set with setSeed takes precedence.

number | undefined

void


setSeed(seed): void

Defined in: SceneRandomSource.ts:44

Reseed the RNG of every scene on the stack, and start every scene that enters later from the same seed. The seed goes through normalizeSeed, so -1 and 0xffffffff produce the same sequence, as do 1.9 and 1. Throws for NaN or an infinite seed.

number

void

Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/core.md.