GENERATING
RANDOM
NUMBERS
Random
numbers are generated
on
the PET using
an
algorithm
on
a
starting number,
or
seed, to begin a sequence of numbers. The
sa
me
seed al-
ways gives the same sequence of numbers.
When the PET
is
powered
up,
the initial seed
is
always the same
so
that
the random number sequence
is
Iikewise always the same. The display below
shows a typical first five numbers that will appear
on
referencing the RANDOM
function RND(arg) after power-up.
III
COMMODORE
BASIC
III
7167
BYTES
FREE
READY.
FOR
1=1
TO
5:?
RND(l):NEXT
RUN
.880969862
.355265655
.659512252
.803285178
.546991144
READY.
Vou can have the same sequence generated each time (this
is
very
helpful
in
debugging situations) by starting from the same seed,
or
you
can
program the PET to generate random numbers from different sequences by
giving different seeds.
291