Table of Contents

RANDOMIZE

PET VIC-20 C64 C16 Plus/4 C128 X16 M65

The RANDOMIZE command seeds the pseudo-random generator with an initial value.

Syntax

RANDOMIZE <value>

The value given must be a LONG number and it will serve as a base for the random sequence.

Example

A typical use case is to seed the randomizer with the result of the TI function:

RANDOMIZE TI()
FOR i AS BYTE = 1 TO 10 : PRINT RND() : NEXT

Commander X16 Example

Since the TI() function is not implemented in the X16, we'll use the ENTROPY() function, that is part of the X16.BAS library:

INCLUDE "x16.bas"
RANDOMIZE ENTROPY()
FOR i AS BYTE = 1 TO 10 : PRINT RND() : NEXT

See also