• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Compare Highest Value

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
Okay you see, I wanna compare values and debug the value on screen.
Currently, this is what I'm doing;
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • i1 Greater than i2
        • i1 Greater than i3
      • Then - Actions
        • Game - Display to (All players) the text: i1 is greatest
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • i2 Greater than i1
            • i2 Greater than i3
          • Then - Actions
            • Game - Display to (All players) the text: i2 is greatest
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • i3 Greater than i2
                • i3 Greater than i1
              • Then - Actions
                • Game - Display to (All players) the text: i3 is greatest
              • Else - Actions
You see, it's quite unefficient if I want to compare 12 values at once (for 12 players).

Any other algorithm you would like to present ? Come on, don't be shy ;p

NOTE: I know "what happens if i1 = i2 , i1 = i3 , vice-versa ?"
Don't jump into that yet (but if you want, that's good).

I just wanna compare X values at once and debug the biggest value (assume that all values are not the same).
 
Yes that's correct.

  • Set values
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set value[1] = (Random integer number between 1 and 10)
      • Set value[2] = (Random integer number between 1 and 10)
      • Set value[3] = (Random integer number between 1 and 10)
      • Set value[4] = (Random integer number between 1 and 10)
      • Set value[5] = (Random integer number between 1 and 10)
      • Set valueSize = 5
  • Sort
    • Events
      • Player - Player 1 (Red) types a chat message containing -sort as An exact match
    • Conditions
    • Actions
      • Set testValue = 0
      • Set testIndex = 0
      • For each (Integer A) from 1 to valueSize, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • value[(Integer A)] Greater than testValue
            • Then - Actions
              • Set testIndex = (Integer A)
              • Set testValue = value[(Integer A)]
            • Else - Actions
That's a simple trigger to find the highest value, and which number it is. NOTE: if two values are the same, it picks the first one.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Okay, we have solved the "which number is greatest" issue.
Right now, how do I display the value which is the greatest, and share the same value ?

I mean;
Value[1] = 5
Value[2] = 7
Value[3] = 2
Value[4] = 7

How do I display the values that are greatest and share the same value.

So the conditions are;
Greatest Value
Share Value

Which in this case, it shows Value[2] and Value[4].

Is there any new algorithm ?
 
Run another loop after the "find highest" loop, this time checking if each value is equal to the highest value.

  • For each (Integer A) from 1 to valueSize, do (Actions)
  • Loop - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • value[(Integer A)] Equal to testValue
  • Then - Actions
  • Game - Display value[integer a]
  • Game - Display integer a
  • Else - Actions
 
Status
Not open for further replies.
Top