[Coco] Is the RND command really generating a random number?

Glen Hewlett glen.hewlett at sympatico.ca
Thu May 18 21:05:25 EDT 2017


Hi Rietveld,

It’s all documented in the unravelled series, the Random function on computers has always been interesting to me, from memory the CoCo uses the value of a 5 byte floating point number.  I think it takes the middle bytes of that long value and uses it to generate the RND number then the floating point # is recalculated next time RND is called.

On that note, the Pac Man game actually gets the value of a byte in the ROM and uses that as part of next seed value for the random #.  So to make a Pac Man game work exactly the same as the arcade machine (use the same patterns) you need to have a copy of the that actual Pac Man ROM.  Sorry - I’m all about Pac Man these days...

Remember to use A=RND(-TIMER) at the beginning of your program to generate a different random seed each time the computer is turned on.

Cheers,
Glen
 
> On May 18, 2017, at 8:48 PM, Rietveld Rietveld <rietveldh at hotmail.com> wrote:
> 
> I would be interested in knowing the logic behind the RND(x) command
> 
> Sent from my BlackBerry 10 smartphone.
>  Original Message
> From: Dave Philipsen
> Sent: Thursday, May 18, 2017 8:44 PM
> To: CoCoList for Color Computer Enthusiasts
> Reply To: CoCoList for Color Computer Enthusiasts
> Subject: Re: [Coco] Is the RND command really generating a random number?
> 
> 
> Very few things in the computer world are truly random.  A better term
> might be 'pseudo-random'.  Think about it.  In theory if you turn on two
> identical CoCos at the same time and ask for a random number at the same
> time they should both provide the same random number.  So, in reality,
> it's not random.
> 
> Dave
> 
> On 5/18/2017 7:39 PM, Rietveld Rietveld wrote:
>> I used the RND command to generate a random game play option in the cocoflash, but it doesn't seem to be very random. Some titles come up more than the laws of probability would suggest is possible.   instead I am now using a small math equation that uses a PEEK of the clock value.   This has resulted in a far more random looking selection
>> 
>> Sent from my BlackBerry 10 smartphone.
>> 
> 
> 
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco



More information about the Coco mailing list