RANDOMIZE

BASin

RANDOMIZE

Command/Statement

RANDOMIZE is used in conjunction with RND to produce sequences of numbers that are either random or predictable.

How to use RANDOMIZE

RANDOMIZE is used either to form a statement in a program or as a command. It is optionally followed by a numeric value, for example

RANDOMIZE 1

10 RANDOMIZE

The value following RANDOMIZE is rounded to the nearest integer if necessary and may then range from 0 to 65535. A value greater than 0 sets the system variable SEED to this value, following which RND always generates the same sequence of numbers. The actual sequence depends on the value of RANDOMIZE.

If RANDOMIZE is followed by 0 or no value, then SEED is given the value of another system variable called FRAMES, which counts the frames displayed since the BASIC was last reset. As FRAMES changes 50 times a second, the sequence of numbers generated by RND following RANDOMIZE or RANDOMIZE 0 is highly random.

If RANDOMIZE is not used, RND generates the same sequence of numbers from reset and after NEW.

Format

  • RANDOMIZE [int-num-expr]

See also

Chapter 11.