Random Numbers
BlitzMax Forums/BlitzMax Beginners Area/Random Numbers
| ||
I'm trying to generate a simple random number, but I keep getting the same number over and over again. Here's the code I use: Global X:Int X = Rand(1,6) Print X Every time I run it X gets a value of 3. When I use Rand(1,50), I get a value of 21. I looked at several tutorials on-line and I think I'm following their examples correctly. Am I missing something? Thanks. |
| ||
You need to seed the random number generator with the seedrnd() function. |
| ||
SeedRnd Millisecs() should do the trick. |
| ||
SeedRnd MilliSecs () Some time ago I quickly did a small Random Number Programm for my Visuals. It switches between 0 and 1 and displays them thru the X and Y Axis. Iīve added a Colortable so each Number changes randomly thru one of itīs predefined Colors. Kinda cheap Matrix like........ |