RND()

Syntax:

rnd!() | rnd() | rnd%()

The RND() function returns a pseudo-random number. Depending on the requested type, the return value can be:

Example:

print "we'll flip a coin"
if rnd() < 0 then print "heads" else print "tails"

The pseudo-random number generator is seeded with the software jiffy clock value on program startup.

Note for VICE users: if you run your program using autorun, the jiffy value will be the same every time you run your program and therefore random sequences will always be the same, too. You can improve this a little bit by setting the AutostartDelayRandom option. The best option however is to manually load your program, just like a user would on a real machine.