[Coco] Is the RND command really generating a random number?
Scott Wendt
malfunct at msn.com
Fri May 19 13:11:03 EDT 2017
RND was definitely one of the commands that you had to "fix" when translating between BASIC dialects.
________________________________
From: Coco <coco-bounces at maltedmedia.com> on behalf of Salvador Garcia via Coco <coco at maltedmedia.com>
Sent: Friday, May 19, 2017 10:01:14 AM
To: CoCoList for Color Computer Enthusiasts
Cc: Salvador Garcia
Subject: Re: [Coco] Is the RND command really generating a random number?
I've used rnd() in other dialects of BASIC and find their syntax incompatible. In some cases, the parameter is ignored. In other, there is a specific statement used to randomize the sequence. Still, the generation of random number is an interesting process. Salvador
From: Johann Klasek <johann+coco at klasek.at>
To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
Sent: Friday, May 19, 2017 10:51 AM
Subject: Re: [Coco] Is the RND command really generating a random number?
On Thu, May 18, 2017 at 09:05:25PM -0400, Glen Hewlett wrote:
[..]
> 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.
Nice reading:
http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=8&t=596
http://www.vavasour.ca/cfdm/issue27.htm#article20
Taken from the ECB's ROM code on a Dragon $9772 depending on the parameter
given
<0 ... seed with parameter
action: parameter * constant1 + constant2 -> RND storage, FAC
=0 ... next pseudorandom value
action: RND storage * constant1 + constant2-> RND storage, FAC
>0 ... next pseudorandom scaled from 1 to N
action: INT( INT(parameter) * ( RND storage * constant1 + constant2 -> RND storage ) + 1 ) -> FAC
Just to compare it to other MS BASIC implementations, especially CBM
BASIC: parameter >0 does no scaling, instead it mangles some hardware
dependend values (timer counter value, ...) into the result. This is not
good enough to get a stable and good distribution, only practical for
seeding the generator.
--
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