namespace Game.Blackjack; /// /// Mulberry32 PRNG — a fast, high-quality 32-bit random number generator. /// Seed is stored in the ECS GameState singleton. /// public static class Mulberry32 { /// /// Advances the state and returns a random float in [0, 1). /// public static float NextFloat(ref uint state) { state += 0x6D2B79F5u; uint z = state; z = (z ^ (z >> 15)) * (z | 1u); z ^= z + (z ^ (z >> 7)) * (z | 61u); return (z ^ (z >> 14)) / (float)uint.MaxValue; } /// /// Advances the state and returns a random integer in [min, max]. /// public static int NextInt(ref uint state, int min, int max) { return (int)(NextFloat(ref state) * (max - min + 1)) + min; } }