Created
September 26, 2014 09:28
-
-
Save rangercyh/8abff917b1f58839968a to your computer and use it in GitHub Desktop.
linear congruence generate random number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local IA = 3877 | |
local IB = 29573 | |
local g_seed = 42 | |
function setseed(seed) | |
g_seed = seed | |
end | |
function getrandom(max) | |
max = max or 100 | |
g_seed = g_seed * IA + IB | |
return g_seed % max | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment