• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[General] Random Numer

Status
Not open for further replies.
Level 3
Joined
Mar 29, 2014
Messages
23
Hello, I'm currently trying to create an event with a random outcome. This is how I tried to do it.

1. certain condition fires, resulting in variable being set to a random integer range 1-3

then to triggers

2. if integer reaches value =<2 do THIS

3. if integer reaches value 3 do THAT

The problem is, every time I test it, only event 1 fires.:vw_wtf: I also exchanged the events, changed the requirements to 1 and >=2 and reloaded the editor. But it seems, that the variable is always set to 1.

What am I doing wrong?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Random numbers aren't neccesarily random :) You can test 100 random numbers every time and they will most probably be the same (i forgot why tho). Thankfully it's just an issue with Map Editor, since real games will actually have more realistic random numbers.

Just fire the event several times untill you get the other numbers.

Since you don't know what's the real value of the variable, use a Game Text Action to display the value of the variable to All Players.
 
Level 6
Joined
May 20, 2014
Messages
228
> Random numbers aren't neccesarily random :) You can test 100 random numbers every time and they will most probably be the same (i forgot why tho). Thankfully it's just an issue with Map Editor, since real games will actually have more realistic random numbers.

They are actually random, but in map editor you have a option called 'Use Fixed Random Seed' on which will use more of an exact 'random' seed every time a random number is generated, which is in preferences, during map testing to help with random stuff in general. While that may be the issue, we don't know the triggers/code he uses so we will have to see.

Random is still random.
 
Level 3
Joined
Mar 29, 2014
Messages
23
Beyond, I listed the triggers I am using. First, I use this one (I excluded irrelevant messages etc.)

  • econdies
    • Ereignisse
      • Einheit - Lord Ecan 0276 <gen> Stirbt
    • Bedingungen
    • Aktionen
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Bedingungen
          • (Owner of Lord Ecan 0276 <gen>) Gleich Spieler 2 (Blau)
        • 'THEN'-Aktionen
        • 'ELSE'-Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Bedingungen
              • (Owner of (Killing unit)) Gleich Spieler 3 (Blaugrau)
            • 'THEN'-Aktionen
              • Spiel - Display to (All players) the text: The South has order...
            • 'ELSE'-Aktionen
              • Set ecandead = (Real((Random integer number between 1 and 3)))
Then, I use two other triggers:

  • econ2
    • Ereignisse
      • Spiel - ecandead becomes Kleiner gleich 2.00
    • Bedingungen
    • Aktionen
      • Spiel - Display to (All players) the text: Ecan, blablab.
  • ecan3
    • Ereignisse
      • Spiel - ecandead becomes Gleich 3.00
    • Bedingungen
    • Aktionen
      • Spiel - Display to (All players) the text: blablabgdgdghe
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
@Alpun, No no no, the issue is not in your trigger, there is a setting which makes the randomness not random.
Click "File" >> "Preferences" >> "Test Map"
There should be a checkbox saying "Use Fixed Random Seed", uncheck it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
Statisticly pseudo random numbers should be within the expected Gaussian distribution of outcomes. Even though they are imperfect (not truly random) they can be considered random for most purposes (security applications generally require different approaches).
 
Status
Not open for further replies.
Top