Angband Forums RNG under fire
 User Name Remember Me? Password
 Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 Thread Tools Display Modes
 June 27, 2016, 07:47 #1 brbrbr Adept   Join Date: Sep 2015 Posts: 104 RNG under fire Ok, I've put it to the test. Here is the "scientific" research of Angband RNG. I've compiled small C program using 4.0.5 code. The result is: https://www.dropbox.com/s/b2ylwtzekq...42.37.png?dl=0 It doesn't like 45-47 numbers and likes number 10, but difference between highest and lowest peaks is less than 0.45%. Seems to be fair.... Next time I will try it for longest sequence of numbers below 5% (common spell failure rate) ) Last edited by brbrbr; June 27, 2016 at 07:54.
June 27, 2016, 12:44   #2
PowerWyrm
Prophet

Join Date: Apr 2008
Posts: 2,731
Quote:
 Originally Posted by brbrbr Next time I will try it for longest sequence of numbers below 5% (common spell failure rate) )
Yesterday I've beaten my infamous spell failure record: I've failed a 1% fail spell four times in a row (was three times before). Hail the mighty RNG!
__________________

June 27, 2016, 15:08   #3
takkaria
Veteran

Join Date: Apr 2007
Posts: 1,946
Donated: \$40
Quote:
 Originally Posted by brbrbr Ok, I've put it to the test. Here is the "scientific" research of Angband RNG. I've compiled small C program using 4.0.5 code. The result is: https://www.dropbox.com/s/b2ylwtzekq...42.37.png?dl=0 It doesn't like 45-47 numbers and likes number 10, but difference between highest and lowest peaks is less than 0.45%. Seems to be fair.... Next time I will try it for longest sequence of numbers below 5% (common spell failure rate) )
What do the different coloured lines all mean?
__________________
takkaria whispers something about options. -more-

 June 27, 2016, 21:44 #4 Pete Mack Prophet   Join Date: Apr 2007 Location: Seattle, WA Posts: 5,661 Donated: \$40 mod 100 should be pretty uniform unless the 1 2 or 4 bit is messed up. Each of the bytes in the random number would be more likely to find a bug..but the first 4 bits are the likeliest to be broken. However, statistical streaks of the same value in a row are more interesting. Most RNGs break down here, and have a lower chance of long streaks in the same range. But again, doing it mod 100 will mask any such tendency. For that, you want to do it by division, not mod.
June 28, 2016, 00:16   #5
brbrbr

Join Date: Sep 2015
Posts: 104
Quote:
 What do the different coloured lines all mean?
There were 3 runs with 3 different seeds = different colors.

Quote:
 Originally Posted by Pete Mack For that, you want to do it by division, not mod.
Yeah, andgband code does it by division.

June 28, 2016, 01:44   #6
brbrbr

Join Date: Sep 2015
Posts: 104
RESULTS:
Longest streak of drawing below 5% was 5 in 10000000 tries

Now, we have to account for monter RNG calls too.
The way it works, you try to cast a spell (one call to RNG), then monster hit, breathe, hit (three more calls to RNG), then you try to cast again (another RNG)
So, I modified code to count sequence of every Xth call for RNG.

Here are more results for X=4:
Longest streak of drawing every 4th below 5% was 6 in 10000000 tries

Quote:
 Originally Posted by PowerWyrm Yesterday I've beaten my infamous spell failure record: I've failed a 1% fail spell four times in a row (was three times before). Hail the mighty RNG!
Longest streak of drawing every 4th below 1% was 4 in 10000000 tries
You are absolute winner, PowerWyrm )))))))

June 28, 2016, 02:15   #7
Pete Mack
Prophet

Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,661
Donated: \$40
The a priori odds for 5 in a row on a d20 is 3e-7, so in 1e7 tests,
5 in row is roughly the expected max run length. A stronger test is to find the distribution of all 20 buckets, and compare the run lengths to the corresponding poisson distribution. (Note that you need to use the expected run length of 1/(1-0.5).)

Quote:
 Originally Posted by brbrbr RESULTS: Longest streak of drawing below 5% was 5 in 10000000 tries Now, we have to account for monter RNG calls too. The way it works, you try to cast a spell (one call to RNG), then monster hit, breathe, hit (three more calls to RNG), then you try to cast again (another RNG) So, I modified code to count sequence of every Xth call for RNG. Here are more results for X=4: Longest streak of drawing every 4th below 5% was 6 in 10000000 tries Longest streak of drawing every 4th below 1% was 4 in 10000000 tries You are absolute winner, PowerWyrm )))))))

Last edited by Pete Mack; June 28, 2016 at 02:22.

June 28, 2016, 03:13   #8
brbrbr

Join Date: Sep 2015
Posts: 104
Quote:
 Originally Posted by Pete Mack The a priori odds for 5 in a row on a d20 is 3e-7, so in 1e7 tests, 5 in row is roughly the expected max run length. A stronger test is to find the distribution of all 20 buckets, and compare the run lengths to the corresponding poisson distribution. (Note that you need to use the expected run length of 1/(1-0.5).)
Huh!
Good to know it fits statistical expectation.
Other buckets are not that interesting, from Angband point of view

So I satisfied myself and do believe in RNG now. If anyone is still in doubt, send them to me ))

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Angband     AAR     Vanilla     Development     ToME     Sil     Variants     Competition The real world     Idle chatter     Oook! Obsolete     v4

 Similar Threads Thread Thread Starter Forum Replies Last Post brbrbr Vanilla 12 August 18, 2016 12:17 Ingwe Ingweron Vanilla 15 October 29, 2015 15:30 buzzkill Development 1 April 25, 2011 22:20 tprice AAR 2 February 21, 2011 14:15 Jungle_Boy AAR 0 June 14, 2010 17:59

All times are GMT +1. The time now is 18:53.

 Contact Us - Angband.oook.cz - Archive - Top