mirror of
https://github.com/veden/Rampant.git
synced 2024-12-26 20:54:12 +02:00
FACTO-130: Fixed the xor random number generator period being cut in half
This commit is contained in:
parent
d1cc7e10bb
commit
81ea0f65a7
@ -5,6 +5,8 @@ Version: 3.1.0
|
||||
- Migration and siege groups now try to avoid chunks with existing enemy structures
|
||||
Tweaks:
|
||||
- Runtime number generator just uses the map seed now
|
||||
Bugfixes:
|
||||
- Fixed the period of the xor number generator being cut in half
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 3.0.3
|
||||
|
@ -73,14 +73,13 @@ function mathUtils.xorRandom(state)
|
||||
local lshift = bit32.lshift
|
||||
local rshift = bit32.rshift
|
||||
|
||||
state = state + 21594771
|
||||
local seed = state + 32685453
|
||||
|
||||
return function()
|
||||
state = xor(state, lshift(state, 13))
|
||||
state = xor(state, rshift(state, 17))
|
||||
state = xor(state, lshift(state, 5))
|
||||
state = state % 2147483647
|
||||
return state * 4.65661287525e-10
|
||||
seed = xor(seed, lshift(seed, 13))
|
||||
seed = xor(seed, rshift(seed, 17))
|
||||
seed = xor(seed, lshift(seed, 5))
|
||||
return seed * 2.32830643654e-10 -- 2.32830643654e-10 = 1 / 2^32, 2.32830643708e-10 = 1 / ((2^32)-1)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user