Seedable Random Number Generator
111,591 Views
-
SeedableRandom<public> := module: LeftShift(Value : int, Shift : int)<transacts><decides>:int= var Output : int = 0 for (Index := 0..(31 - Shift)): Shifted := RightShift[Value, Index] Bit := Mod[Shifted, 2] if (Bit = 1): set Output += Floor[Pow(2.0, (Index + Shift) * 1.0)] return Output RightShift(Value : int, Shift : int)<transacts><decides>:int= return Floor[(Value * 1.0) / (Pow(2.0, Shift * 1.0))] XOR(A : int, B : int)<transacts><decides>:int= var Output : int = 0 var ShiftedA : int = A var ShiftedB : int = B for (Index := 0..63, ShiftedA <> 0 or ShiftedB <> 0): BitA := Mod[ShiftedA, 2] BitB := Mod[ShiftedB, 2] if ((BitA = 1 and BitB = 0) or (BitA = 0 and BitB = 1)): set Output = Output + LeftShift[1, Index]
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.