Give every stage its own random stream derived from the invocation seed and stage id

Stages no longer share one RandomGenerator. StageContext.random() is the
running stage's own stream: java.util.Random seeded with
mix(mix(invocationSeed) ^ fnv1a64(utf8(stageId))), mix being the
SplitMix64 finalizer. Adding, removing or reordering modules, or how much
other stages draw, no longer changes a stage's draws. A block stage keeps
one stream across the blocks of its pass.

The host passes a long invocation seed to PlacementRunner.place and
ChunkRunner.generate instead of a RandomGenerator on the inputs;
InvocationContext loses random(), so stages cannot reach a shared stream.
ObjectGenerationContext keeps its own random() for geometry generators.
StageRandom documents the derivation, and a test pins it to values
computed from the specification.
This commit is contained in:
piexel committed 2026-10-05 21:34:19 +02:00
1 parent 4cb718f706
commit 307e488d1a
17 files changed
+293 -34

No files matched your search

@@ -1,14 +1,13 @@
package com.volmit.generation;
import com.volmit.resource.PackResources;
import java.util.random.RandomGenerator;
/** Host-owned invocation inputs. RNG and views must not be retained or used by detached tasks.
* The host derives streams from world seed, stable feature/occurrence identity and position;
* module discovery order must not affect them. Keeping legacy random behavior is adapter work.
/** Host-owned invocation inputs. Views must not be retained or used by detached tasks.
*
* <p>There is no shared random stream. A stage draws from {@link com.volmit.stage.StageContext#random()},
* a stream of its own, and an object generator from {@link com.volmit.object.ObjectGenerationContext#random()}.
*/
public interface InvocationContext {
long worldSeed();
PackResources resources();
RandomGenerator random();
}