PDA

View Full Version : Rng



HoloGnome
June 6th, 2014, 16:07
What Random Number Generator is FG using? Lua? C? What type?

Moon Wizard
June 6th, 2014, 16:58
Both the C++ and Lua RNG are using the built-in libraries seeded by time in milliseconds. The 3D dice are actually a physics simulation based on user input.

JPG

HoloGnome
June 6th, 2014, 17:28
For dice rolling are you using math.random() in Lua?

Moon Wizard
June 6th, 2014, 19:36
Only when it can't be represented by a physical die. (i.e. 1d5)

JPG

HoloGnome
June 6th, 2014, 20:31
OK - just curious. I have been looking at alternate Lua pseudo-random number generators and comparing them math.random(). One caveat I noticed is that if you are going to use Lua's math.random(), make sure you throw away some values first with calls to math.random() during initialization (before actually making a call you expect to be pseudo-random). Even with unique os.time() seeds, math.random() starts off the same.

So far, I don't think I have found anything conclusively better than lua across 1M iteration tests. The frequency distribution of all them tends to be similarly sigmoidal, but I'm still looking. I have tried Mersenne Twister (similar to what is in 5.2), multiply-with-carry, plus a couple of others. I would still like to try Tausworthe. I have to convert the algorithm to Lua-ese.

Hitcher
September 3rd, 2015, 11:19
Hi,

I am a bit necromancing this thread as I have not found any other more recent version of this problem.

Does someone of you know how you could enable a different kind of random number generator? I just made a test of ~ 100.000 d20 rolls - and the results don't look that appealing.

10859

I will let the tool run for a night to get a more stable data basis then just 100.000, but this seems to validate that the extremes are in a slight favour.

Value Items
1 4874
2 4937
3 4592
4 4783
5 5004
6 4869
7 4848
8 4689
9 4868
10 4606
11 4714
12 4618
13 4951
14 4981
15 4615
16 4671
17 4675
18 4802
19 5065
20 4968
n= 96130


And another run with some more data
10861
Value Items percent
1 7477 5,13%
2 7477 5,13%
3 7006 4,81%
4 7264 4,99%
5 7668 5,27%
6 7423 5,10%
7 7196 4,94%
8 7277 5,00%
9 7360 5,05%
10 7002 4,81%
11 7136 4,90%
12 7192 4,94%
13 7359 5,05%
14 7366 5,06%
15 6989 4,80%
16 7112 4,88%
17 7094 4,87%
18 7343 5,04%
19 7467 5,13%
20 7417 5,09%
n= 145625

damned
September 3rd, 2015, 13:23
to me those variations seem to be within a reasonable tolerance level?
if the numbers were to come out all at 5% it could just as likely suggest that it is not random.... :)

Hitcher
September 3rd, 2015, 13:40
Yeah ... I let myself be fooled by the graphic.

It's just that on the last two gaming sessions there had been a quite sum of 1's and 20's - quite in a very distinctive pattern. Because of this I started this whole "data gathering".

But it's very near 5% at all ... Will give it a last look after it ran through the night - but I guess my players just had a quite bunch of bad luck yesterday and the evening before :-)

damned
September 3rd, 2015, 13:48
If you think about it another way.... you have 5 players and 5 monsters - you probably have at least 10 and maybe as many as 20 rolls (when you include saves) in one round. That means your odds of having at least one critical (success or failure) per round are pretty good... but they are the ones that stand out...