bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] quasi-random dice for the Initial Position


From: Joern Thyssen
Subject: Re: [Bug-gnubg] quasi-random dice for the Initial Position
Date: Mon, 7 Jul 2003 10:34:11 +0000
User-agent: Mutt/1.4.1i

On Mon, Jul 07, 2003 at 11:45:19AM +0200, Jim Segrave wrote
> On Mon 07 Jul 2003 (07:28 +0000), Joern Thyssen wrote:
> > On Mon, Jul 07, 2003 at 08:50:39AM +0200, Jim Segrave wrote
> > [snip]
> > > 
> > > The dice sequence doesn't know how man trials it will be asked for, it
> > > simply generates sequences such that every 30/36 games you get all
> > > possible 1st rolls, every 1080/1296 games get every possible first 2
> > > rolls, every 38880/46656 games you get full sets of 3 rolls, etc.
> > 
> > Hmm, are you sure? 
> 
> I'm going by the comments and a skim of the code, so no, I'm not
> sure. But, if the code works correctly for non-initial positions and
> produces correct results for 1296 games, 46656 games, etc. then it
> would be true that deleting those sequences which begin with a double
> should preserve the correctness of 2nd rolls. I'm not vouching for the
> underlying code (I haven't actually read it in detail to see if that's
> what it does). But I do have a perl script for taking lists of rolls
> and checking the distributions for the first 3 rolls - I think I'll
> lift the code out of rollout.c and try running the output on my
> script.

Aha, I may have found the bug:

nSkip is local to the "if ( fInitial && !iTurn )" part of RolloutDice.
Shouldn't it be global inside RolloutDice and be used in the "else if (
fRotate && iTurn )" part as well:

  } else if( fRotate && iTurn < 128 ) {
      int i, /* the "generation" of the permutation */
          j, /* the number we're permuting */
          k; /* 36**i */
      
      for( i = 0, j = 0, k = 1; i < 6 && i <= iTurn; i++, k *= 36 )
          j = aaanPermutation[ i ][ iTurn ][ ( ( iGame + nSkip ) / k + j ) % 36 
];
                                                         ^^^^^

I've committed a fix. Please review!

With my fix the dice for a 1080 trial RAIP is now:

Roll 12 11 46 31 52 61 (iGame 943)
Roll 12 12 35 44 62 35 (iGame 253)
Roll 12 13 12 45 44 55 (iGame 433)
Roll 12 14 24 52 51 13 (iGame 1063)
Roll 12 15 25 53 23 56 (iGame 733)
Roll 12 16 41 33 41 24 (iGame 523)
Roll 12 21 15 66 26 23 (iGame 133)
Roll 12 22 23 14 33 52 (iGame 763)
Roll 12 23 22 55 65 62 (iGame 163)
Roll 12 24 32 63 12 25 (iGame 373)
Roll 12 25 31 42 14 33 (iGame 853)
Roll 12 26 14 32 34 15 (iGame 283)
Roll 12 31 63 64 42 51 (iGame 913)
Roll 12 32 13 46 11 46 (iGame 643)
Roll 12 33 44 24 66 54 (iGame 883)
Roll 12 34 43 41 13 41 (iGame 1003)
Roll 12 35 64 61 43 44 (iGame  43)
Roll 12 36 66 16 31 (iGame 223)
Roll 12 41 42 35 45 16 (iGame 1033)
Roll 12 42 56 21 54 34 (iGame 973)
Roll 12 43 45 23 53 43 (iGame 613)
Roll 12 44 65 56 24 45 (iGame 703)
Roll 12 45 61 54 35 53 (iGame 103)
Roll 12 46 21 22 15 31 (iGame 823)
Roll 12 51 54 26 25 32 (iGame 583)
Roll 12 52 26 13 21 36 (iGame 403)
Roll 12 53 62 11 36 26 (iGame  13)
Roll 12 54 16 34 56 42 (iGame 193)
Roll 12 55 34 12 55 66 (iGame 463)
Roll 12 56 55 62 16 63 (iGame 313)
Roll 12 61 52 15 64 22 (iGame 793)
Roll 12 62 53 36 32 64 (iGame 553)
Roll 12 63 11 43 46 21 (iGame  73)
Roll 12 64 51 51 63 12 (iGame 673)
Roll 12 65 36 65 61 65 (iGame 493)
Roll 12 66 33 25 22 14 (iGame 343)

Much better now!

Jørn 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]