bug-gnubg
[Top][All Lists]

## Re: [Bug-gnubg] Rotating rolls in rollout

 From: Jim Segrave Subject: Re: [Bug-gnubg] Rotating rolls in rollout Date: Fri, 4 Oct 2002 17:53:37 +0200 User-agent: Mutt/1.4i

On Fri 04 Oct 2002 (15:19 +0200), address@hidden wrote:
>
>
> --On 04  Oct 2002  13:44 +0200 Jim Segrave <address@hidden> wrote:
>
> >On Fri 04 Oct 2002 (13:23 +0200), Nis Jorgensen wrote:
>
> >>Perhaps something like this (pseudocode)
> >>
> >>RollUsed(TrialNumber,Rollnumber) =
> >>    Sum for k = 0 to (Rollnumber - 1)
> >>            of
> >>    ((Trialnumber div (36^k)) mod 36)
> >>            mod 36
> >
> >What happens to the results if you do something simple minded like:
> >
> >create an array of rolls with
> >1296 elements. Initialise with 1111 1112 1113 .. 6664 6665 6666
> >
> >Use the seed to randomise the array - for example, generate two
> >random nos. i and j in the range  0..1295 and swap array[i] with
> >array[j]. Repeat at least 648 times.
>
> That is not a good randomization strategy. You should do
>
> For i = 0 to 1295
>  create random j between i and 1295
>  swap array[i] and array[j]
> Next
>
> Then by a simple proof by induction, the array is as random as your random
> numbers.

I suspect both methods will produce similar levels of randomisation. I
can't see that there is an inherent advantage of one over the
other. Do you have reason to think differently? I'm not trying to be
defensive, I'm just curious.

> This does not, however, provide the maximum stratification if the number of
> trials is not a multiple of 1296. Thus I would prefer to put a little more
> effort into creating the array of rolls. My best idea so far is to cycle
> the first roll through the same sequence of 36 rolls, and cycling the
> second roll through the same sequence, but 'sliding' the sequence before
> each sequence of 36. Something like (still pseudocode:
>
> Create array36 containing 11,12,...,66
> Randomize Rolls36 as described before
> Create empty array of 1296
>
> for i = 0 to 35
> for j = 0 to 35
> array[i*36+j] = (array36[j], array36[i+j mod 36])

If the desired result is that for every 36 rollouts, every initial
roll is present with the probability of that roll, this is a better
way to do it. But I wonder if it's worth randomising the
initial roll in that case. Does it gain you anything?

> >Then use this array sequentially (and circularly, dropping initial
> >doubles when rolling out initial positions) to supply the first two
> >rolls. This gives you a pseudo-random but repeatable set of roll
> >pairs and the processor cost is not very high - filling the array and
> >randomising it is relatively cheap, after that, during the rollouts
> >you don't have to keep track of what you've used.
>
> I am not sure about "dropping the initial doubles" during the rollout. I
> think rather we should make an array of 30*36 for that case.

Again, I don't think that makes much if any difference. I would think
it's whichever makes the programming the simplest - if it's easier to
have a single fixed size array and a test to drop doubles or code to
keep track of which list is in use. I suspect that there's very little
to choose from between the two methods.

--