| 01-19-2008, 03:28 PM | #1 |
I've been wondering, how does GetRandomInt works, internally? It seems that I've been getting the same int for some random creep spawn in my map, they always spawn the same creep so I aimed my arrow at this function is the number generated really that random? |
| 01-19-2008, 03:30 PM | #2 |
Make sure you have File > Preferences > Test Map > Fixed Random Seed disabled. It really does return a random number in a real game though, but I'm not the one to explain its inner machinations. |
| 01-19-2008, 03:41 PM | #3 | |
Quote:
In its practical use, yes. In reality, not at all. Most random functions are pretty just a Pseudorandom number generator |
| 01-19-2008, 05:17 PM | #4 |
It uses a seed to choose a pre-created list of integers which it runs through in order, using modulus to get it in the required range. |
| 01-19-2008, 06:56 PM | #5 |
Using modulus is a terrible waste of entropy (throws away bits) and non uniform if things don't divide nicely (e.g. 0,1,2 mod 2 = 0,1,0 0 twice as likely). But mod is in fact probably how they do it. |
| 01-20-2008, 02:57 AM | #6 | |
Quote:
|
| 01-20-2008, 10:26 AM | #7 |
It could just be a bug in your code, you know. Or it could be that you are generating those units during cinematic mode. |
| 01-20-2008, 10:29 AM | #8 |
O_o generating units in cinematic mode can cause problem? |
| 01-20-2008, 10:33 AM | #9 |
Using randomInt in cinematic mode is likely to act like a test map with fixed seed since cinematic mode changes the seed. |
| 01-20-2008, 12:30 PM | #10 |
JASS:
// Use a fixed random seed, so that cinematics play consistently.
call SetRandomSeed(0)
imho anything what !=0 will gen random values. (everytime) |
| 01-20-2008, 12:40 PM | #11 | |
Quote:
File > Preferences > Test Map > Fixed Random Seed - false only means that seed will be given value of a current clock timer every time game starts so seed will be different every time = numbers will be different every time. |
| 01-20-2008, 12:47 PM | #12 | |
Quote:
oh f**k, guess i should have the cinematic mode of my own then... damn randomseed... |
| 01-20-2008, 01:12 PM | #13 |
you could just choose the random values before the cinematic mode... |
