Re: A82: Re: Random routine - human reaction times


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

Re: A82: Re: Random routine - human reaction times




The same logic would hold in the case of using a counter (as mentioned in
an earlier post) to generate the random seeds.
Besides, I never spoke about using r as the seed itself, but as an index
into a page of memory. There are numerous ways to combine 8bit registers
into 16bit addresses in order to extract a pseudo-random number from rom.
You'll note that in my original shuffling routine r is only accesed once
in the beginning as a seed.

-Jeremy

> 
> Take for example the flow of a program with just the statement "ld a,r" to
> gather a random number from.
> 
> Let us assume that we want to randomly access a routine 1 out of every 4
> times, such that the following code would suffice:
> 
> main:
>  <blah>
> 
>  ld a,r
>  and %11            ; the easiest way to generate a number from 1-4
> (actually 0-3)
>  jr nz,main
> 
>  <etc>
>  jr main
> 
> Let us assume that in an arbitrary sequence but specific number of
> statements, each time that the conditional jr nz is not met, the number of
> statements executed, and stored in r, ends with the last two bits being 1.
> This would mean that the number generated now is not random and therefore
> the program would execute as if there was no conditional statement.  This is
> why a random routine needs more than just register r to be considered
> random.
> 
> -harper
> 
> 



Follow-Ups: References: