Rand() is not Randomizing...

BlitzMax Forums/BlitzMax Beginners Area/Rand() is not Randomizing...

There's probably a really simple solution to this that I just haven't found yet, but when I use the Rand() (or Rnd()) command, it gives me the same result. Every time. I even shut down and restarted my computer, still the same result. And its one out of about 10,000. Any help?

Thanks

Try adding SeedRnd MilliSecs () to the start of your program.

KryzBlu, Have a look at the SeedRnd() command.

*EDIT* And BlitzSupport takes the gold! :)

:D
Thanks! That worked

it would be better to use the mersenne twist method rather then the inbuilt blitz rand(aka blitz rand sucks)

In what way is the blitz rand not good enough for 99.999% of users needs?

> In what way is the blitz rand not good enough for 99.999% of users needs?

Well have a try yourself.

Do:

local moo = rand(0,1)


In my experience 0 is often chosen about 60-75% of the time instead of it being 50/50 with 1. Dunno why. Otherdays it's totally different.

But often you have to do extra stuff like this:-

local moo = rand(0,9)

Select moo 
Case 0,2,4,6,8
default
end select


or

local arse:float = rnd(0,1.9999999999)

moo = int(arse)


to make things a bit more random.

How many samples are you taking? It will average out over an infinite timeline. Or maybe it won't.

See, it's random.

Anybody got a BlitzMax mersenne twist function that they could post here? I left my math degree and kanji charts in my other brain.

er do a search for "mersenne" in these max forums, there is a module

Interestingly, the only way to evenly distribute Rand(0,1) over any number of samples would require it to return the opposite of the previous sample. Which isn't random at all.