I am developing a game that needs percentage.
The game needs percentage that is quiet Accurate. (Like WELL512 Algorithm.)
Also the percentage needs to be restricted by the players level and it’s quantity have to be restricted too.
Can anyone give me a Awesome algorithm or API That does stuff like it?
↓ I tried these sources. First one is just test for easy use math.random second one is for Monte-Carlo Calculation.
(For people try setting math.randomseed( os.time() ) … I tried it.)
function maybe(x) if 100 \* math.random() \< x then print(1) else print(0) end end
local A1, A2 = 727595, 798405 -- 5^17=D20\*A1+A2 local D20, D40 = 1048576, 1099511627776 -- 2^20, 2^40 local X1, X2 = 0, 1 function rand() local U = X2\*A2 local V = (X1\*A2 + X2\*A1) % D20 V = (V\*D20 + U) % D40 X1 = math.floor(V/D20) X2 = V - X1\*D20 return V/D40 end