EasyManua.ls Logo

Radio Shack TRS-80 - Page 106

Radio Shack TRS-80
236 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Random
numbers
are
unpredictable;
properly
functioning computers are
not. So
how do we
get
random
numbers out of
our Computer? We
don't:
we get
pseudo-random
numbers. Each
time
you
use the RND
function, the
Computer
uses an
internal
"seed
number" to
produce
the
desired
random number.
This is
neither the time nor
the place to get
technical, so we'll give
the
following tip without
further
explanation
:
When
you're running game
programs using RND, it's a good
idea to set the
seed
to an un-
predictable
value. This
will
ensure that you don't
get the same
pseudo-random number
sequence each time you
turn
on the Computer and
play the game.
Put
the following
lines at
the beginning
of
your program
where they
will
be executed
only once:
1
IN.
"ENTER A NUMBER
BETWEEN 1 AND
100"
;N
2 F.
1=1
TO N
J=RND(
32767
)
N. I
functions
-
Learned in Chapter
19
. Miscellaneous
-
RND(0) for
random numbers
greater
than
and
less than 1
Random
vs. Pseudo-
random
Seed
numbers
RND(N) for random
numbers
from 1 to N
104

Other manuals for Radio Shack TRS-80

Related product manuals