| 08-22-2003, 09:28 AM | #1 |
Ok, I've been using random integers for a while now, but I just picked up on the fact that they aren't perfectly random, as in, they follow a random set of integers everytime it plays. I know there's something called a seed that's involved, I assume that's the name given to the set of random integers? Essentially my questions are... 1. Am I right? Does it follow a set? 2. Is this set thingy linked to something called a Seed? 3. How do I fix this problem so that it's always perfectly random? Thanks in advance. |
| 08-22-2003, 09:30 AM | #2 |
As far as I know they are random UNLESS you are using the "Test Map" button, in which case they will not be random, but be the same numbers in the same order every time. |
| 08-22-2003, 09:37 AM | #3 |
BOY am I glad I asked my programming teacher a long time ago how random numbers worked. HOW does something that works on pure precision calculation come up with a "random" number? Random numbers in any computer system works like such: First it makes a call to the seed, to get your number. The seed is an integer of any size. Then it goes through a complicated process to turn the seed into a very very large somewhat random number. Then it simply 'mods' that number down to the size you want it. A seed of 1 will always produce the same random number though. However, what most programs are seeded with is something called Ctime. Its the time in processes since the computer was turned on, or something close to that. SO every time you call random, it uses a slightly different seed, and therefore gets an entirely different random number. Generally the only time you will have a problem with a random number not being random is when you do "test map" and you have the "used fixed random seed" checked under AI, i think. I dont know of any other way to use a fixed seed in WC3. However, no computers random numbers are really random. As is practical for your(and most) maps, im sure they are random enough. But they aren't really random, and with enough work, they are predictable. The only way I've ever heard of to get a truly random number is to use a random number table, but computers can't do that because everything they do is calculated. Jared. |
| 08-22-2003, 10:04 AM | #4 |
AllPainful you're perfectly correct. Although it's beyond me why the default setting for whether it uses a preset seed or not is ticked under preferences in the World Editor. Thankyou as well for the lesson Jared, it was highly informative. Although I knew already the method of generating a random number but not the reasons behind the 'Seed' concept. Might I add, that I heard that it wasn't a counter started at the systems bootup, but actually a complicated maths equation that substitutes values from the computer's current time. It's possible that when they said time though they didn't mean the time of day(which would include date and year, which is what I thought they meant) but instead they referred to your method. Also, I hear now they're replacing that original system with new hardware that records the noise of the surrounding the processor. Generating a purely random value. Thankyou again guys, might I suggest that people untick the 'Preset Seed' checkbox for future use? |
