Ok. This is a collateral to all the combat 'weirdness' everyone experienced. I want to dismiss a myth about computers and random numbers (ok, you will have to dust up your math a little=):
A Random Number Generator DOESN'T exist. Period. There is no known way for classical computer to generate truly random numbers. There is no equivalent to throwing some dice for a computer, because modern computer is based on logic, it is impossible for him to generate random number on the spot. Everytime you hear someone saying they got a hardware, or a software random generator is usually just trying to sell a product. EVERYTHING is based on variables and functions. You can use variables that seems more or less random, but, it still is possible to regenerate the same numbers doing the exact same steps.
The question now is, what does it actually do? And why is it called random number generator?
First, it is NOT called a random number generator. It is called a Pseudo-Random Number Generator(PRNG). The emphasive is on the Pseudo part. So, how does that work? Here we go =)
A PRNG algorithm is based on 2 things. A formula/function, that generates pseudo-random number, and a Seed. The formula is usually a linear congruential generator (LCG) or a non-linear congruential generator (NLCG). What is a LCG? It's a formula, that, given an input, will generator a LIST of pseudo-random numbers. The input is the seed. Here's the formula for a standard LCG, it is based on recurence to generate a list :
Xn+1=(Xn*b+a) mod max
where X0=seed, X1/X2/X3/X4/.../Xn/Xn+1 are the pseudo-random numbers, a and b are multipliers used by the function where 0 <= a and c < max, and max=the maximum number generated(and the longuest possible cycle, see below).
For example, lets take a = 2 and b = 11, seed = 127 and max 1024.
X1 = (127 * 11 + 2) mod 1024
X1 = 1399 mod 1024
X1 = 375
So, the first number in the list is 375. That means that, the first time you request a random number, it returns 375, and you usually do some operations to make it between X and Y to be used by your program, more often than not, between 0 and 99 or 1 and 100.
X2 = (375 * 11 + 2) mod 1024
X2 = 4127 mod 1024
X2 = 31
So, the second number in the list is 31. And it goes on like that.
Now, lets take the seed 49.
X1 = (49 * 11 + 1) mod 1024
X1 = 541 mod 1024
X1 = 541
X2 = (541 * 11 + 1) mod 1024
X2 = 5953 mod 1024
X2 = 833
...
As you can see, there it NOTHING random there. Given then exact seed, you can easely determine the EXACT numbers that will be generated. Furthermore, generating 2 PRN lists with the same seed always yields the same exact list, as you can see so well with the save/load quirks of Civ3, where, even if you reload, the same thing will happen, given the same order. This is because the seed is saved with the rest of the game.
So, why is that formula used? Well, LCG is NOT the best alrgorithm, but it's the most commun and 'easiest' one to implement. Also, statistically, it is viable and is 'correct' , if n is big enough (max <= n), where n is the number of generated numbers. So, how can you avoid having the same list over and over? Well, you usually use values that changes for the seed. The most commun one is the time, in miliseconds, since January 1970. Unless you generate your lists at the same exact milisecond, it will most likely be different. Or, you can keep a variable that keeps track of the mouse movement to really make it so it is even harder to predict. You can use the noise from your CPU fan as a seed, or any other thing like that, but it STILL is Pseudo-Random, even if the seed seems 'random'. Also, I will refrain from going to deep in math, but I want to point out that the 'mod' operator has a cycle that goes from 0 to N(non-inclusive), where N is the number after the 'mod'. That means that, even different seed can generate the same exact list. The smaller the cycle and 'max', the easier it is to generate the same list again.
So, why all this? To tell you that, NO, the combat is NOT broken, nor is the PRNG. Maybe, maybe the game relies too much on PRN and 'luck', it is up to you to decide for yourself on that. However, all the weirdness you see is based on the PRNG. That's why sometimes you have a warrior defeating a mech inf, or a stroke of bad OR good luck(I haven't seen anyone screaming for blood when they got a lucky stroke=).
Also, just to prove how 'sucky' PRNG is, have you ever used the 'random' function on a 5 CD disk changer? Or used the 'shuffle' function of programs like Winamp? If so, you probably already realised how sucky it is. For example, I just listened to music with the random function on my 5 CD changer. Here are the result :
(disk/song)
3/1
3/4
4/5
3/2
5/1
3/1
3/6
4/7
4/2
4/8
4/5
4/8
3/1
5/2
3/2
As you can see, i got 5!!! songs from the same disk IN A ROW, I got 2 and 3 times the same song in the list, and NEVER got any song from disk 1 or 2!! This is the 'randomness' Civ3 (and nearly all software programs) uses, so no wonder it yields the results you are all experiencing in combat.
This is just to clear the Myth about PRNG =)
I might be wrong on some account, but I think the gist of it remains true.
A Random Number Generator DOESN'T exist. Period. There is no known way for classical computer to generate truly random numbers. There is no equivalent to throwing some dice for a computer, because modern computer is based on logic, it is impossible for him to generate random number on the spot. Everytime you hear someone saying they got a hardware, or a software random generator is usually just trying to sell a product. EVERYTHING is based on variables and functions. You can use variables that seems more or less random, but, it still is possible to regenerate the same numbers doing the exact same steps.
The question now is, what does it actually do? And why is it called random number generator?
First, it is NOT called a random number generator. It is called a Pseudo-Random Number Generator(PRNG). The emphasive is on the Pseudo part. So, how does that work? Here we go =)
A PRNG algorithm is based on 2 things. A formula/function, that generates pseudo-random number, and a Seed. The formula is usually a linear congruential generator (LCG) or a non-linear congruential generator (NLCG). What is a LCG? It's a formula, that, given an input, will generator a LIST of pseudo-random numbers. The input is the seed. Here's the formula for a standard LCG, it is based on recurence to generate a list :
Xn+1=(Xn*b+a) mod max
where X0=seed, X1/X2/X3/X4/.../Xn/Xn+1 are the pseudo-random numbers, a and b are multipliers used by the function where 0 <= a and c < max, and max=the maximum number generated(and the longuest possible cycle, see below).
For example, lets take a = 2 and b = 11, seed = 127 and max 1024.
X1 = (127 * 11 + 2) mod 1024
X1 = 1399 mod 1024
X1 = 375
So, the first number in the list is 375. That means that, the first time you request a random number, it returns 375, and you usually do some operations to make it between X and Y to be used by your program, more often than not, between 0 and 99 or 1 and 100.
X2 = (375 * 11 + 2) mod 1024
X2 = 4127 mod 1024
X2 = 31
So, the second number in the list is 31. And it goes on like that.
Now, lets take the seed 49.
X1 = (49 * 11 + 1) mod 1024
X1 = 541 mod 1024
X1 = 541
X2 = (541 * 11 + 1) mod 1024
X2 = 5953 mod 1024
X2 = 833
...
As you can see, there it NOTHING random there. Given then exact seed, you can easely determine the EXACT numbers that will be generated. Furthermore, generating 2 PRN lists with the same seed always yields the same exact list, as you can see so well with the save/load quirks of Civ3, where, even if you reload, the same thing will happen, given the same order. This is because the seed is saved with the rest of the game.
So, why is that formula used? Well, LCG is NOT the best alrgorithm, but it's the most commun and 'easiest' one to implement. Also, statistically, it is viable and is 'correct' , if n is big enough (max <= n), where n is the number of generated numbers. So, how can you avoid having the same list over and over? Well, you usually use values that changes for the seed. The most commun one is the time, in miliseconds, since January 1970. Unless you generate your lists at the same exact milisecond, it will most likely be different. Or, you can keep a variable that keeps track of the mouse movement to really make it so it is even harder to predict. You can use the noise from your CPU fan as a seed, or any other thing like that, but it STILL is Pseudo-Random, even if the seed seems 'random'. Also, I will refrain from going to deep in math, but I want to point out that the 'mod' operator has a cycle that goes from 0 to N(non-inclusive), where N is the number after the 'mod'. That means that, even different seed can generate the same exact list. The smaller the cycle and 'max', the easier it is to generate the same list again.
So, why all this? To tell you that, NO, the combat is NOT broken, nor is the PRNG. Maybe, maybe the game relies too much on PRN and 'luck', it is up to you to decide for yourself on that. However, all the weirdness you see is based on the PRNG. That's why sometimes you have a warrior defeating a mech inf, or a stroke of bad OR good luck(I haven't seen anyone screaming for blood when they got a lucky stroke=).
Also, just to prove how 'sucky' PRNG is, have you ever used the 'random' function on a 5 CD disk changer? Or used the 'shuffle' function of programs like Winamp? If so, you probably already realised how sucky it is. For example, I just listened to music with the random function on my 5 CD changer. Here are the result :
(disk/song)
3/1
3/4
4/5
3/2
5/1
3/1
3/6
4/7
4/2
4/8
4/5
4/8
3/1
5/2
3/2
As you can see, i got 5!!! songs from the same disk IN A ROW, I got 2 and 3 times the same song in the list, and NEVER got any song from disk 1 or 2!! This is the 'randomness' Civ3 (and nearly all software programs) uses, so no wonder it yields the results you are all experiencing in combat.
This is just to clear the Myth about PRNG =)
I might be wrong on some account, but I think the gist of it remains true.
Comment