HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Random Numbers

03-11-2008, 11:48 PM#1
Fledermaus
Any reason my random numbers don't differ from game to game?

And yes, "Use fixed random seed" is not ticked.

I've tried multiple times in single player and a few on battle.net and the random numbers never differ.

If it helps, all the random numbers that I want to be random are set at map init.
03-12-2008, 12:36 AM#2
Salbrismind
Quote:
Originally Posted by Antiquities
Any reason my random numbers don't differ from game to game?

And yes, "Use fixed random seed" is not ticked.

I've tried multiple times in single player and a few on battle.net and the random numbers never differ.

If it helps, all the random numbers that I want to be random are set at map init.

I'm not sure if "Use fixed Random seed" is the thing i'm thinking of but there is some thing in the map editor you need to tick.

Other then that maybe you should post your code, you might have a made a mistake that you missed.
03-12-2008, 01:23 AM#3
Fledermaus
Trigger:
For each (Integer A) from 1 to 10, do (Actions)
Collapse Loop - Actions
Set TempInteger = (Random integer number between 1 and 3)
Set TempPoint = (Random point in Zone2[TempInteger])
Unit - Create 1 Makrura Prawn for Neutral Extra at TempPoint facing (Random angle) degrees
Unit Group - Add (Last created unit) to ZoneMobs[2]
Custom script: call RemoveLocation(udg_TempPoint)
Doing that for multiple units types. They always end up in the same place.
I'm also only using TempInteger because I thought that doing "Set TempPoint = (Random point in Zone2[Random integer number between 1 and 3])" might have been the problem.

And yes, what you're thinking of is "Use fixed random seed" but that only effects the TestMap.
03-12-2008, 01:47 AM#4
Pyrogasm
Odd... can you post the map?
03-12-2008, 02:00 AM#5
Rising_Dusk
You're jumping to conclusions, it's most definitely not the random numbers if it's happening on BNet. Include messages that display the random number generated and you'll see for yourself.

Make sure the regions you're referring to exist and are correctly defined for array indicies 1, 2, and 3. It's likely that if those are declared wrong, it would generate the behavior you've described.
03-12-2008, 02:11 AM#6
TheSecretArts
or you have the most amazing luck! If thats so, play the lottery!
But let's say that It's not your luck that's causing this...

"all the random numbers that I want to be random are set at map init."
^
|
-could that be the problem...

or maybe:
"Zone2[TempInteger])", are you sure that there are 3 defined rects in there?
03-12-2008, 02:31 AM#7
Fledermaus
I am 100% sure there are 3 defined rects for it (defined at map init too but the trigger is before this one). I had already tried displaying TempInteger and the co-ordinates of TempPoint and they were always the same.
03-12-2008, 02:50 AM#8
Rising_Dusk
Quote:
I had already tried displaying TempInteger and the co-ordinates of TempPoint and they were always the same.
Then post the map. I cannot replicate your error using code identical to yours and defined regions. If you're positive it has nothing to do with the random seed and that this is replicate-able in BNet, then there is likely something wrong with your WE or something.
03-12-2008, 03:03 AM#9
Salbrismind
Quote:
Originally Posted by TheSecretarts
or you have the most amazing luck! If thats so, play the lottery!
But let's say that It's not your luck that's causing this...

"all the random numbers that I want to be random are set at map init."
^
|
-could that be the problem...

or maybe:
"Zone2[TempInteger])", are you sure that there are 3 defined rects in there?

I bet he's just lucky XD.

Also, set random numbers at the intialization but the key, try doing it using the event "Time - Elapsed game time is 0.10 seconds".
03-12-2008, 06:14 AM#10
Fledermaus
Ok, so I've found that if I disable my main init trigger and then make another one with the Zone initialization in it everything works fine. I'm now going to try and figure out what part of that trigger is making it not work.



Trigger:
Map Init
Collapse Events
Map initialization
Conditions
Collapse Actions
Game - Set Lock resource trading to On
Visibility - Disable black mask
Visibility - Disable fog of war
Cinematic - Turn cinematic mode On for (All players)
Sound - Clear the music list
Sound - Stop music After fading
Environment - Set sky to Lordaeron Winter Sky
Environment - Set fog to style Linear, z-start 800.00, z-end 2500.00, density 0.50 and color (10.00%, 10.00%, 27.50%)
Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across Selection <gen>
Set SelectionVis = (Last created visibility modifier)
Set TempGroup = (Units in (Playable map area))
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Collapse For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Item - Remove (Item carried by (Picked unit) in slot (Integer A))
Custom script: call DestroyGroup(udg_TempGroup)
Collapse Item - Pick every item in (Playable map area) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Picked item) Not equal to No item
Collapse Then - Actions
Item - Remove (Picked item)
Else - Actions
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Player Group - Add (Player((Integer A))) to Humans
Set TempGroup = (Units owned by (Player((Integer A))))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in TempGroup) Not equal to 0
Collapse Then - Actions
Unit Group - Pick every unit in TempGroup and do (Unit - Remove (Picked unit) from the game)
Game - Display to Humans for 30.00 seconds the text: Invalid Unit Detect...
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Game - Display to Humans for 30.00 seconds the text: ((Name of (Player((Integer A)))) + ( - + (Name of (Picked unit))))
Trigger - Turn off Save Hero Dialog <gen>
Trigger - Turn off Kick <gen>
Else - Actions
Custom script: call DestroyGroup(udg_TempGroup)
Camera - Apply Cinamatic1 <gen> for (Player((Integer A))) over 0.00 seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of players in Humans) Equal to 1
Collapse Then - Actions
Game - Display to Humans for 30.00 seconds the text: Singleplayer Mode
Trigger - Turn off Save Hero Dialog <gen>
Trigger - Turn off Kick <gen>
Else - Actions
Wait 10.00 seconds
Set CinematicSkipped = False
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Camera - Apply Cinematic2 <gen> for (Player((Integer A))) over 17.00 seconds
Else - Actions
Game - Display to Humans for 15.00 seconds the text: It has been 4 month...
Wait 15.00 seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CinematicSkipped Equal to False
Collapse Then - Actions
Game - Display to Humans for 10.00 seconds the text: Champions from far ...
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Camera - Apply Cinematic3 <gen> for (Player((Integer A))) over 12.00 seconds
Wait 10.00 seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CinematicSkipped Equal to False
Collapse Then - Actions
Game - Display to Humans for 10.00 seconds the text: You have clambered ...
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Camera - Apply Cinematic4 <gen> for (Player((Integer A))) over 12.00 seconds
Hero - Make (Player((Integer A))) Heroes gain 200.00% experience from future kills
Wait 10.00 seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
CinematicSkipped Equal to False
Collapse Then - Actions
Trigger - Turn off Cinematic Skipped <gen>
Game - Display to (Player group((Triggering player))) the text: ...
Cinematic - Disable boundary tinting for (All players)
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Camera - Stop swaying/shaking the camera for (Player((Integer A)))
Camera - Apply Selection <gen> for (Player((Integer A))) over 0.00 seconds
Game - Set the time of day to 12.00
Game - Set time of day speed to 30.00% of the default speed
Environment - Set sky to Lordaeron Summer Sky
Environment - Set fog to style Linear, z-start 1200.00, z-end 2500.00, density 0.50 and color (70.00%, 70.00%, 77.50%)
Wait 5.00 seconds
Cinematic - Turn cinematic mode Off for (All players)
Visibility - Enable fog of war
Game - Display to Humans for 30.00 seconds the text: |cff8b00ffView the ...
Game - Display to Humans for 20.00 seconds the text: To choose your char...
Else - Actions
Else - Actions
Else - Actions
Custom script: call DestroyTrigger(GetTriggeringTrigger())


EDIT: yes, I know some of that trigger is useless, I got the map from someone else and have not got around to optimizing/removing all the useless code yet.
03-12-2008, 06:20 AM#11
Rising_Dusk
Quote:
then make another one with the Zone initialization in it
Well shit dude, I don't see any zone initialization in the trigger you posted at all. That could be the problem. :p
03-12-2008, 06:23 AM#12
Fledermaus
I removed them out of there when I was testing time delays like Salbrismind suggested but they came after the "Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across Selection <gen> ".
03-12-2008, 06:29 AM#13
Tide-Arc Ephemera
I sincerely apologize if I'm stealing the topic, but does (as an example) random number from 1 to 50 take as much or more memory than 1 to 5?

Also, what about 50 to 100 and 1000 to 1050?

Again, my apologies if this is stealing the topic.
03-12-2008, 06:45 AM#14
Strilanc
Quote:
Originally Posted by Tide-Arc Ephemera
I sincerely apologize if I'm stealing the topic, but does (as an example) random number from 1 to 50 take as much or more memory than 1 to 5?

Also, what about 50 to 100 and 1000 to 1050?

Again, my apologies if this is stealing the topic.

Numbers in JASS all use the same amount of space. The fact that the number "is random" doesn't change that.

http://en.wikipedia.org/wiki/Integer...ter_science%29
http://en.wikipedia.org/wiki/Pseudo_...mber_generator
03-12-2008, 06:47 AM#15
Fledermaus
Ok, so if I run Map Init (the trigger) at "Time - Elapsed game time is 0.01 seconds" rather than "Map initialization" while having my Zones initialized in a separate trigger at "Map initialization" then if my units are also created at "Map initialization" then they are indeed randomly placed.