Tiny BASIC

Interpreter and Compiler Project

Random Number Generator

Download: random.bas
Size 0kb, downloads 163.

Here's a simple random number generator. If you want X to be a random number between, say, 1 and 6, you would call it like this:

GOSUB 200
LET X=1+R-R/6*6

To set the seed, simply set R to a number between 0 and 6546 before calling the subroutine. You may need to ask the user of your program to "think of a number" to get one. Alternatively, you can set your own seed for procedural world generation.

Comments

New Comment

Yes No