*.aargh!*

The random number generator in this scripting language is not random.. and how it works is driving me to drink!

I have had to write, rewrite and rewrite routines trying to get around this quirky behavior. I have had marginal success.

Quick example:

if I ask for 5 random numbers between a value of 1 to 10 what I

__should__get is something like this:

1,5,3,8,4 or 9,1,8,6,4

What I get get in Mount&Blade is along these lines:

1,1,1,8,8 or 4,4,3,3,3 or 8,8,8,9,9

Time and time again I see this behavior.. and I know what causes it...but I am at a bit of a loss as to how to get around it.

It appears that every time we initiate a call to create a random number, the random number generator is seeded with some sort of value (more than likely from the clock)...our processors are so fast that the routine is seeded with the same value two or three times before the clock can increment.

For those of you (and I hope it is very few of you), that do not know this little factoid: You can seed the randomization process with a number, then ask it for a a series of random numbers and that unique string will be duplicated every time without fail for that particular seed.

So.. if I seed a randomization process with a number ..say.. 2343242 and ask it for a number between 1 and 1 billion, it will give me the same answer every time when I seed it with that specific number. Only when I ask it a second time or third time without re-seeding the randomization process, or I seed the randomized process with a different value, will give me different values,

Now.. imagine that when we ask in Mount&Blade for a five number sequence between 1 and 100.. and it looks at the clock (a standard way to seed the randomization process), and gives us a set of random numbers. The processors are so fast that they seed the process each time with the same number several times before the clock changes..thus we get a string of like numbers... not random.

This is why we get these string of same numbers in a row.. you see this effect in battle when we spawn two or three troop types that look identical even though they can randomize out in very different equipment.

I am open to thoughts and suggestions..