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
With a shuffle bag, you can ‘fill the bag’ with the distribution you want and then randomly pull values our till the bag is empty, re-fill, reshuffle repeat.
This produces a guaranteed distribution matching your needs over any span equal to the fill size.
Another pure Lua approach would be to port Bob Jenkins’s ISAAC to Lua 5.1. Dirk Laurie ported it (from C) to 5.3 some time back. By the looks of it that would mostly entail moving the operators (>>, ~, &) to their bit.* counterparts (negative shifts to lshift , positive ones to rshift or maybe arshift , ~ to bxor , & to band ). It seems to have pretty respectable properties.
With a shuffle bag, you can ‘fill the bag’ with the distribution you want and then randomly pull values our till the bag is empty, re-fill, reshuffle repeat.
This produces a guaranteed distribution matching your needs over any span equal to the fill size.
Another pure Lua approach would be to port Bob Jenkins’s ISAAC to Lua 5.1. Dirk Laurie ported it (from C) to 5.3 some time back. By the looks of it that would mostly entail moving the operators (>>, ~, &) to their bit.* counterparts (negative shifts to lshift , positive ones to rshift or maybe arshift , ~ to bxor , & to band ). It seems to have pretty respectable properties.