Struct 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.
Inherited Members
Namespace: Scylla.Core.Util.Random
Assembly: ScyllaCore.dll
Syntax
[Serializable]
public struct MersenneTwisterState
Remarks
MT19937 uses a state array of 624 32-bit words. Serializing this struct is significantly larger (~2.5 KB) than the other RNG state types, which have at most 256 bits of state. Prefer Xoshiro256State or PCG32State in scenarios where save-state size matters.
When MTI equals 624 the state array has been fully consumed and the next call to NextUInt32() will trigger a twist operation to regenerate all 624 words.
Fields
MT
The 624-element 32-bit state array of the MT19937 generator. The twist recurrence is applied to regenerate this array in-place each time the index MTI reaches 624.
Declaration
public uint[] MT
Field Value
| Type | Description |
|---|---|
| uint[] |
MTI
The current read index into the MT state array. Valid values are
in the range [0, 624]; a value of 624 indicates that all pre-generated
words have been consumed and the next draw will trigger a twist regeneration.
Declaration
public int MTI
Field Value
| Type | Description |
|---|---|
| int |