HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Math - Random Integer

03-27-2004, 10:44 PM#1
Reaprojects
I use this function in one of my triggers, but I'm not sure if it works correctly.

I have a region array set up with 31 items. I create unit blah blah in Center of Region ( RegionArray(Math - Random Integer between 1 and 31)).

However, the unit is always created in the same region. I didn't test it for successive creations yet. I will do that once I get my partner at hand to test it with me.

Is the function bugged?
03-27-2004, 10:58 PM#2
Transcendence
I don't really understand buut you might want to try something like using If, Then, Elses if it isn't working properly. Integer Variable

Set Region= Random Integer between 1 and 31
If Region=1 then create unit at center of blah

Just a suggestion if it isnt working now.
03-27-2004, 11:27 PM#3
KofA_Maps
It works for me. I did it to create random creeps from a trigger.
03-27-2004, 11:33 PM#4
AIAndy
Did you use Test Map and is the random seed set to a fixed value ?
03-28-2004, 05:33 AM#5
zotax
Warcrafts random number generator is notoriously dodgy, using larger numbers helps though. eg instead of 1-4 do like 1-40000
03-28-2004, 10:23 AM#6
KofA_Maps
I have a peice of code that will make it truely randomized. Ill get it tomorrow. Too tired right now.
03-28-2004, 12:40 PM#7
Reaprojects
Quote:
Originally Posted by AIAndy
Did you use Test Map and is the random seed set to a fixed value ?

I guess that's what was causing this. I just did a test online with my partner and it works flawlessly. Sorry for any inconvenience. :/
03-29-2004, 03:21 AM#8
zotax
Id be interested in that script kofa...
03-29-2004, 12:34 PM#9
Cubasis
Eh, there is no way to make the randomization action "more" randomized. The random number generator in WC3 is completely sufficient at creating random numbers. The only thing that might be messing up is if you testmap the map with "Use Fixed Random Seeds". I mean, you are playing a game from a company that also released Diablo...where whole worlds were created using random numbers...

Also, if you know how RNG's work, they can't ever become "truly" randomized... Simply for the fact that there is always logic behind it. It works basicly that you start with this seed (which is just a integer value). Then when you ask for a random number, it does all sorts of crazy stuff with this seed to create a seemingly random value (and I think you can count on blizzard to have appropriately effective algorithm for this, considering their past experience), So 0 may become like 3213098, while 1 becomes f.ex. 5... which they then update the seed with (so the seed is now this new number). Then they simply use another algorithm to change this 0-4294967296 value into what you asked for.

So if you always f.ex. start with the seed as "0", then you'll always get the same random numbers in a row... That's bascily what that TestMap "setting" is about, as often when you're testing something, you don't want different results to confuse your test. But normally when you play the map, WC3 finds a different seed each time (f.ex. by taking the current seconds passed since the start of the year or sumtin).

Also, Cinematic Mode "automatically" sets the random seed to "0". The official reason for this is to avoid different things to happen each time you watch the cinematic - making the cinematic possibly buggy for some unlucky watcher.

Cubasis