• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Random Integer Generator

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564

  • Init
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set i = 1
      • Trigger - Run Random Intergers <gen> (ignoring conditions)
  • Random Intergers
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Equal to 1
        • Then - Actions
          • Set itaken[1] = (Random integer number between 1 and 16)
          • Set i = (i + 1)
        • Else - Actions
      • Set ir = (Random integer number between 1 and 16)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Greater than 16
        • Then - Actions
          • Trigger - Run Trigger Success Check <gen> (ignoring conditions)
        • Else - Actions
          • For each (Integer A) from 1 to (i - 1), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ir Equal to itaken[(Integer A)]
                • Then - Actions
                  • Trigger - Run (This trigger) (ignoring conditions)
                  • Skip remaining actions
                • Else - Actions
                  • Set itaken[i] = ir
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Integer A) Equal to (i - 1)
                    • Then - Actions
                      • Set i = (i + 1)
                      • Trigger - Run (This trigger) (ignoring conditions)
                    • Else - Actions


This is a random integer generator and this is different from the GUI function Random Integer between A and B as this function has a percent chance of generating a number more than one but my system takes a set of integer and put them in a random order without repeating it twice. Its made in GUI because when I made it I wasn't good at JASS.

Also, you are free to check for any bugs it might contain.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
Trigger - Run Trigger Success Check <gen> (ignoring conditions)

You forgot to post that trigger...

Anyway, this makes no sense at all. As far as I can tell all you do is loop random integers multiple times resulting in horriably unefficent random number generation for between 1 and 16.

Really I see no real point for such a horriably unefficent system.

May I remind you that the rules of random numbers state that the same number can occur infinatly in a row, but it becomes an infinatly low chance. Also the actual random number generator in WC3 is as accurate as PCs are capable of, so there is no way your system is better.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Ok, may be I named it wrong but the point is not to use the same integer generated before.

Also, I thought of this when I wanted to make a clue in my make about making 16 foot switch arranged 4x4 and you have to press them in a certain order but I want that order is different each time you start a new game, if I will use loops to trigger those foot switchs system, the loop provides no random number so I will set an integer array to the list of the generated integers; I think that explains why I don't need to repeat an integer twice. And as for Trigger Check Success this is just a trigger for me to check that the integers won't repeat.

And also thanks for your opinions.
 
Last edited:
Status
Not open for further replies.
Top