Namespace Scylla.Core.Util.Random
Classes
AliasTable
Walker's Alias Method implementation for O(1) weighted random selection.
CryptoRandomSource
An IRandomSource adapter that wraps RandomNumberGenerator to provide cryptographically strong non-deterministic random values.
MersenneTwister
A Mersenne Twister (MT19937) random number generator. Provides very high quality randomness with an enormous period, suitable for scientific simulations and tooling.
PickHistory
Tracks the pick history for a ProbabilityList<T>, retaining the most recent pick events up to a fixed capacity.
PoissonDiskSampler
A static utility class for generating uniformly distributed 2D points using Poisson disk sampling. Produces sets of points in which every pair of points is separated by at least a specified minimum distance, resulting in a natural, clump-free distribution that is visually superior to pure random placement.
ProbabilityEntry<T>
A serializable entry that pairs an item of type T with a
probability weight and a set of optional control flags used by
ProbabilityList<T>.
ProbabilityList<T>
A generic, serializable container for weighted random selection with first-class support for probability influence, repeat prevention, pick history, and item depletion.
ProbabilityNormalizer
Provides a static utility method for normalizing a collection of ProbabilityEntry<T> objects so that the enabled entries' probabilities collectively sum to 1.0.
RandomExtensions
Extension methods for IRandomSource implementations that provide convenient instance-style access to all major random operations without needing to call RandomUtil statically.
RandomID
Provides static utility methods for generating random identifiers of various formats. Covers 32-bit and 64-bit numeric IDs, hexadecimal strings, URL-safe Base64 strings, alphanumeric strings, and RFC 4122 version 4 GUIDs.
RandomSeeder
Provides static seeding and bit-manipulation utilities used internally by all RNG algorithm implementations in the Scylla random subsystem.
RandomText
Provides static utility methods for generating random text content at various levels of granularity: individual characters, words, sentences, paragraphs, and multi-sentence blocks of approximate target length.
RandomUtil
Provides deterministic and non-deterministic random utilities for Unity and general C# usage. Serves as the main facade for random number generation in Scylla, offering factory methods for all supported RNG algorithms and a comprehensive suite of utility methods that operate uniformly over any IRandomSource implementation.
SystemRandomSource
An IRandomSource adapter that wraps an instance of Random, allowing it to participate in the Scylla random subsystem alongside the native algorithm structs.
UnityRandomSource
An IRandomSource adapter that delegates random number generation to Unity's built-in global RNG (UnityEngine.Random), allowing Unity's random state to participate in the Scylla random subsystem.
Structs
DiceRoll
Represents an immutable dice roll configuration using standard RPG notation (e.g., "2d6+5").
Encapsulates the number of dice, face count, and flat modifier that define a roll expression,
and provides methods to execute that roll against any IRandomSource.
MersenneTwisterState
Represents the complete serializable internal state of a MersenneTwister (MT19937) random number generator. Capturing this struct and passing it back to SetState(MersenneTwisterState) fully restores the generator to the exact point it was when the snapshot was taken, enabling deterministic save/load and replay.
PCG32
A PCG32 random number generator (Permuted Congruential Generator). Provides excellent statistical quality with a compact 128-bit state and native support for multiple independent, non-overlapping streams via a configurable increment.
PCG32State
Represents the complete serializable internal state of a PCG32 (Permuted Congruential Generator) random number generator. Capturing this struct and passing it back to SetState(PCG32State) fully restores the generator to the exact point it was when the snapshot was taken, enabling deterministic save/load and replay.
PickRecord
Records a single pick event produced by a ProbabilityList<T>.
RandomUtil.DeterministicRNG
A fast, seedable, replayable deterministic RNG suitable for gameplay simulation. This is a thin backwards-compatible wrapper around Xoshiro256StarStar using SplitMix64 seeding.
RandomUtil.DeterministicRNGState
Represents the internal state of a deterministic random number generator (RNG). This struct provides the serialized state of the RNG to enable state saving, restoration, and deterministic replay.
SplitMix64RNG
A SplitMix64 random number generator. Extremely fast with minimal 64-bit state, best suited for quick seeding, hash-like randomness, and procedural pipelines.
SplitMix64State
Represents the complete serializable internal state of a SplitMix64RNG random number generator. Capturing this struct and passing it back to SetState(SplitMix64State) fully restores the generator to the exact point it was when the snapshot was taken, enabling deterministic save/load and replay.
Xoroshiro128Plus
A lightweight, fast RNG using the xoroshiro128+ algorithm. Ideal for memory-constrained scenarios or when many independent RNG streams are needed.
Xoroshiro128State
Represents the complete serializable internal state of a Xoroshiro128Plus random number generator. Capturing this struct and passing it back to SetState(Xoroshiro128State) fully restores the generator to the exact point it was when the snapshot was taken, enabling deterministic save/load and replay.
Xoshiro256StarStar
A fast, seedable, replayable RNG suitable for deterministic gameplay simulation. Implements the xoshiro256** algorithm with SplitMix64 seeding. This is the default and recommended algorithm for most gameplay scenarios in Scylla.
Xoshiro256State
Represents the complete serializable internal state of a Xoshiro256StarStar random number generator. Capturing this struct and passing it back to SetState(Xoshiro256State) fully restores the generator to the exact point it was when the snapshot was taken, enabling deterministic save/load and replay.
Interfaces
IProbabilityInfluence
Provides a dynamic influence value that modifies the effective selection probability of an entry in a ProbabilityList<T> at pick time.
IRandomSource
Minimal random source contract used by RandomUtil helpers and extensions. All RNG algorithms and adapters implement this interface to provide a unified abstraction for generating random values, allowing callers to swap algorithms without changing downstream code.
Enums
RandomAlgorithm
Identifies the pseudo-random number generation algorithm to use when creating a generator via RandomUtil.
RepeatPreventionMode
Specifies how ProbabilityList<T> handles repeated consecutive selections of the same entry.
SelectionStrategy
Specifies the algorithm used by ProbabilityList<T> to sample entries according to their weighted probabilities.
Delegates
PoissonDiskSampler.BoundChecker
A delegate that determines whether a given 2D point falls within the sampling region. Used by Sample(IRandomSource, Vector2, BoundChecker, float, int) to support arbitrary convex and concave boundary shapes.