Commodore PET User Manual page 307

Table of Contents

Advertisement

The-l to-l00 display program shown earlier. which displayed five numbers
in the range 0 to 1 for each seed. can be changed so that the random numbers
returned by RND will be put into a a selected range. The program below is the
same as the previous one except that line 40 is changed to put the random num-
bers into the range 1 to 6; the loop at line 30 has a Ta index of lOto print the first
ten numbers of each series.
10 FOR 1=-1 Ta -100 STEP -1
20 X=RND<I):PRINT 1
30 FOR
~T=l
TO 10
40 PRINT INT<6*RND(1)+1)
50 NEXT J:PRINT:FOR K=0 TO 1000:NEXT K
60 NEXT 1
F~UN
-1
5
.-.
,;.>
5
1
4
5
6
1
1
4
--2
2
1
4
3
1
2
5
4
-,
""
-3
2
6
6
6
6
6
5
1
5
As in the original program. the sequence for -1 will always be the same. the
sequence for -2 will always be the same, etc. Ta adjust this program to start at a
random seed. change
1
in line 20 to -TI (or. for the new ROMs. -RND(O) may be
used).
The program below shows the use of-TI to generate a random seed.lt is the
same genre of program as before. but it has been modified to calculate numbers
294

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents