SecondBASIC Documentation v3

Home / Command Reference / Randomize


Description: Changes the <Seed> for the random number generator.


Randomize [<Seed>]

Part Description
<Seed> Optional. If omitted, the HV counter will be used instead.

Note: Changing the seed is essential for making sure that each number being coming out of the random number generator is unique. Having the same seed throughout the program will yield the same pattern of numbers coming out of the random number generator. Ignoring a value for seed will just substitute the video's HV counter for the seed. A good way to make use of getting pure random numbers is to place a Randomize statement right after a joypad routine has detected a key. The HV counter will be in a random state when the hardware is turned on, but emulation generally has a constant value.


    Dim VarSeed As Integer
    Randomize VarSeed