# [Coco] Tandy Color Computer 3 RND Function

Robert Gault robert.gault at att.net
Thu Mar 26 07:50:23 EDT 2020

```John,

Good information but it does not give a hint about the quality of the Coco RND function. That is to
say you want the probability of any number within the RND function to be equal. Not so easy to
record that information but there is another approach. :)

You can run the following on any Coco by selecting either PMODE or HSCREEN graphics.

10 R=RND(-TIMER)
20 WIDTH80:HSCREEN3: REM or PMODE4,1
30 R=RND(0):X=R*630:R=RND(0):Y=R*191: REM or 255 AND 191 for PMODE
40 HSET(X,Y) :REM  or PSET(X,Y)
50 GOTO 30

The above, with a perfect RND function, will eventually completely fill the screen with dots and,
during the filling, show no pattern. I've not let it run long enough on my Coco3 to fill the screen
but the dot density does not look completely uniform, just adequate.

Robert

Melanie and John Mark Mobley wrote:
> 10 MAX=0:MIN=1
> 20 FOR X=1 TO 1000
> 30 R=RND(0)
> 40 IF R>MAX THEN MAX=R
> 50 IF R<MIN THEN MIN=R
> 60 NEXT X
> 70 PRINT MIN,MAX
> 80 GOTO 20
>
> R is a number between 0 and 1 but never 0 or 1.
>
> After about 6 days this is what I found.
> R=9.38416633E-09 to 0.999999862.
>
> R=RND(-TIMER):REM RANDOMIZE THE PSEUDO NUMBER GENERATOR
> R=RND(-2):REM FIX THE PSEUDO NUMBER GENERATOR TO PATERN 2
> R=RND(-1.1):REM FIX THE PSEUDO NUMBER GENERATOR TO PATERN 1.1
> R=RND(-1):REM FIX THE PSEUDO NUMBER GENERATOR TO PATERN 1
> R=RND(0):REM R=0.000000001 TO 0.999999999
> R=RND(1):REM R=1
> R=RND(2):REM R=1 OR 2
> R=RND(3):REM R=1 TO 3
>
> John Mark Mobley
>
>
>
```