i have uncertain number of integers from 2 to 12, and i need to compare them all to know witch value is highest, witch one second, third, etc... i tried to use iteration, but it didnt work, looks like i just dont know method to do it :(
I would set the "uncertain number" to = all YourSetVar[12]'s. Then have a switch.. not sure if you can have >= or > etc. in a switch. On the chance that you cant, I would then just make a bunch of if then elses. If YourSetVar[2] is > YourSetVar[3]... and the same for <. It would beneficial if there was a way to grab highest or lowest values and I guess that's what youre hoping for.
I would set the "uncertain number" to = all YourSetVar[12]'s. Then have a switch.. not sure if you can have >= or > etc. in a switch. On the chance that you cant, I would then just make a bunch of if then elses. If YourSetVar[2] is > YourSetVar[3]... and the same for <. It would beneficial if there was a way to grab highest or lowest values and I guess that's what youre hoping for.
If you are confused on the math behind sorting a set of numbers, you can google "array sort algorithm" and get lots of good information about different ways to sort stuff.
If you are confused on how to implement such an algorithm in the sc2 editor, there is actually a templete by blizzard. In the trigger editor, click view and make sure "Show Libraries" is check. Then open Built-In>Template>Algorithms to see some example actions that sort an array of scores. You can also just search your question on this website to find other threads about this.
not sure if im doing is right, i didnt try it yet, if im doing this right to find witch value is highest u just check its numeration in player group from 1 to 12
SetUp-LeaderboardOptions:ActionReturnType:(None)ParametersGrammarText:SetUp-Leaderboard()HintText:(None)CustomScriptCodeLocalVariablesIteration1=0<Integer>Iteration2=0<Integer>ATEAMTOTALSCORE=(((((SCOR.SR.SCOREPOINTS[(Player1fromTEAM.SR.TEAMA)] + SCOR. SR.SCORE POINTS[(Player2fromTEAM.SR.TEAMA)]) + SCOR. SR.SCORE POINTS[(Player3fromTEAM.SR.TEAMA)]) + SCOR. SR.SCORE POINTS[(Player4fromTEAM.SR.TEAMA)]) + SCOR. SR.SCORE POINTS[(Player5fromTEAM.SR.TEAMA)]) + SCOR. SR.SCORE POINTS[(Player6fromTEAM.SR.TEAMA)]) <Integer>
B TEAM TOTAL SCORE = (((((SCOR. SR.SCORE POINTS[(Player1fromTEAM.SR.TEAMB)] + SCOR. SR.SCORE POINTS[(Player2fromTEAM.SR.TEAMB)]) + SCOR. SR.SCORE POINTS[(Player3fromTEAM.SR.TEAMB)]) + SCOR. SR.SCORE POINTS[(Player4fromTEAM.SR.TEAMB)]) + SCOR. SR.SCORE POINTS[(Player5fromTEAM.SR.TEAMB)]) + SCOR. SR.SCORE POINTS[(Player6fromTEAM.SR.TEAMB)]) <Integer>
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of players in TEAM. SR.TEAM A+B) > 0
Then
------- BOTH TEAMS
Player Group - Reset SCOR. SR.BOTH TEAMS to have no players
General - For each integer Iteration 1 from 1 to (Number of players in TEAM. SR.TEAM A+B) with increment 1, do (Actions)
Actions
Variable - Set SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMA+B)] = True
General - For each integer Iteration 2 from 1 to (Number of players in TEAM. SR.TEAM A+B) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Iteration 1 != Iteration 2
Then
General - If (Conditions) then do (Actions) else do (Actions)
If
SCOR. SR.SCORE POINTS[(PlayerIteration1fromTEAM.SR.TEAMA+B)] >= SCOR. SR.SCORE POINTS[(PlayerIteration2fromTEAM.SR.TEAMA+B)]
Then
Else
Variable - Set SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMA+B)] = False
General - Break
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMA+B)] == True
Then
Player Group - Add player (Player Iteration 1 from TEAM. SR.TEAM A+B) to SCOR. SR.BOTH TEAMS
Else
------- TWO TEAMS
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of players in TEAM. SR.TEAM B) > 0
Then
------- TEAM A
Player Group - Reset SCOR. SR.TOP TEAM to have no players
Player Group - Reset SCOR. SR.BOTTOM TEAM to have no players
General - For each integer Iteration 1 from 1 to (Number of players in TEAM. SR.TEAM A) with increment 1, do (Actions)
Actions
Variable - Set SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMA)] = True
General - For each integer Iteration 2 from 1 to (Number of players in TEAM. SR.TEAM A) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Iteration 1 != Iteration 2
Then
General - If (Conditions) then do (Actions) else do (Actions)
If
SCOR. SR.SCORE POINTS[(PlayerIteration1fromTEAM.SR.TEAMA)] >= SCOR. SR.SCORE POINTS[(PlayerIteration2fromTEAM.SR.TEAMA)]
Then
Else
Variable - Set SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMA)] = False
General - Break
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMA)] == True
Then
General - If (Conditions) then do (Actions) else do (Actions)
If
A TEAM TOTAL SCORE >= B TEAM TOTAL SCORE
Then
Player Group - Add player (Player Iteration 1 from TEAM. SR.TEAM A) to SCOR. SR.TOP TEAM
Else
Player Group - Add player (Player Iteration 1 from TEAM. SR.TEAM A) to SCOR. SR.BOTTOM TEAM
Else
------- TEAM B
General - For each integer Iteration 1 from 1 to (Number of players in TEAM. SR.TEAM B) with increment 1, do (Actions)
Actions
Variable - Set SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMB)] = True
General - For each integer Iteration 2 from 1 to (Number of players in TEAM. SR.TEAM B) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
Iteration 1 != Iteration 2
Then
General - If (Conditions) then do (Actions) else do (Actions)
If
SCOR. SR.SCORE POINTS[(PlayerIteration1fromTEAM.SR.TEAMB)] >= SCOR. SR.SCORE POINTS[(PlayerIteration2fromTEAM.SR.TEAMB)]
Then
Else
Variable - Set SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMB)] = False
General - Break
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
SCOR. SR.BEST OF REST[(PlayerIteration1fromTEAM.SR.TEAMB)] == True
Then
General - If (Conditions) then do (Actions) else do (Actions)
If
B TEAM TOTAL SCORE > A TEAM TOTAL SCORE
Then
Player Group - Add player (Player Iteration 1 from TEAM. SR.TEAM B) to SCOR. SR.TOP TEAM
Else
Player Group - Add player (Player Iteration 1 from TEAM. SR.TEAM B) to SCOR. SR.BOTTOM TEAM
Else
Else
Else
If you are confused on the math behind sorting a set of numbers, you can google "array sort algorithm" and get lots of good information about different ways to sort stuff.
If you are confused on how to implement such an algorithm in the sc2 editor, there is actually a templete by blizzard. In the trigger editor, click view and make sure "Show Libraries" is check. Then open Built-In>Template>Algorithms to see some example actions that sort an array of scores. You can also just search your question on this website to find other threads about this.
i checked algorithms and looks like mine informatics knowlage is too low, cuz i dont understand how its working at all :/
I don't think he wants to sort his array as each element probably corresponds with each player, I think this is something like what he wants
Varhighest=0highplace=0Pickeachintegerfrom0to12Ifscore[pickedinteger]>highestSethighplace=pickedintegerSethighest=score[pickedinteger]EndifEndpickDisplay"the highest score is player ",highestplace," with ",highest
Some psuedo-code there, but it tells him who has the highest score and what it is.
I don't think he wants to sort his array as each element probably corresponds with each player, I think this is something like what he wants
Varhighest=0highplace=0Pickeachintegerfrom0to12Ifscore[pickedinteger]>highestSethighplace=pickedintegerSethighest=score[pickedinteger]EndifEndpickDisplay"the highest score is player ",highestplace," with ",highest
Some psuedo-code there, but it tells him who has the highest score and what it is.
i tried find highest to add it to player group be4 others and then find hiest of them and then add that player, i thought i can use group like list where i pick player with higest score and add players one by one to this group, but by some reason player groups dont work like i thought or maybe i do something wrong.
Player groups inherently sort players from 0-15 as they are added to their group.
It sound like what you want is a record containing both a score and that players number. You then sort the struct based on the scores, moving the player number with it.
for loop [index] from 1-12
if "Score[index] >/= Rank[0][2]
Set Rank[0][1]=[index]
Set Rank[0][2]=Score[index]
For loop[index2] from 12-1 (Not sure if you can run a loop backwards setting it to -1 intervals)
Set Rank[index2][1]=Rank[index2-1][1]
Set Rank[index2][2]=Rank[index2-1][2]
Its 2:30 AM and I may not be thinking clearly on this one, but this is the theory (Someone fix it if im wrong)
Run a loop from 1-12 for each player.
Rank[0][2] will hold the value of the highest scoring player currently, a standard for which to compare the current value.
When a new high score is achieved, rank[0][1] records the players index, and rank[0][2] holds their score.
then a second loop is run, which "bumps" every value down 1 notch. Rank[1][1] becomes Rank[0][1], which is your new high score; while the old [1][1] turns to [2][1]
*Be sure to wipe values on ranks between running though.
I listen to all u guys said and made this function, i used method from Algorithm folder ZMilla told me to check and mixed with GlornII array method, but i used 2 different variables instead of 1 with double arrays. Function is working fine, ill upload video right now, but im not sure if it has bugs or not and i hope it wont cause laggs on bnet.
SetUpLeaderboardOptions:ActionReturnType:(None)ParametersGrammarText:SetUpLeaderboard()HintText:(None)CustomScriptCodeLocalVariablesIteration=0<Integer>ArrayIndex=0<Integer>SwapInteger=0<Integer>ActionsGeneral-ForeachintegerIterationfrom1to(NumberofplayersinTEAM.SR.TEAMA+B)withincrement1,do(Actions)ActionsVariable-SetSCOR.SR.LEADERBOARDGROUP[Iteration] = (Player Iteration from TEAM. SR.TEAM A+B)
General - If (Conditions) then do (Actions) else do (Actions)
If
(Number of players in TEAM. SR.TEAM A+B) == 1
Then
Else
General - For each integer Iteration from 1 to (Number of players in TEAM. SR.TEAM A+B) with increment 1, do (Actions)
Actions
General - For each integer ArrayIndex from 1 to (Number of players in TEAM. SR.TEAM A+B) with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
SCOR. SR.SCORE POINTS[SCOR.SR.LEADERBOARDGROUP[Iteration]] > SCOR. SR.SCORE POINTS[SCOR.SR.LEADERBOARDGROUP[ArrayIndex]]
Then
Variable - Set SwapInteger = SCOR. SR.LEADERBOARD GROUP[ArrayIndex]
Variable - Set SCOR. SR.LEADERBOARD GROUP[ArrayIndex] = SCOR. SR.LEADERBOARD GROUP[Iteration]
Variable - Set SCOR. SR.LEADERBOARD GROUP[Iteration] = SwapInteger
Else
i have uncertain number of integers from 2 to 12, and i need to compare them all to know witch value is highest, witch one second, third, etc... i tried to use iteration, but it didnt work, looks like i just dont know method to do it :(
I would set the "uncertain number" to = all YourSetVar[12]'s. Then have a switch.. not sure if you can have >= or > etc. in a switch. On the chance that you cant, I would then just make a bunch of if then elses. If YourSetVar[2] is > YourSetVar[3]... and the same for <. It would beneficial if there was a way to grab highest or lowest values and I guess that's what youre hoping for.
"You either are doing it, or you are not": Me
Team Genesis: Founder/Leader
Skype: Grasso2012 or Add me in-game 558
Free Model Developing Program: http://www.autodesk.com/education/free-software/maya
i still dont understand how to do it ;(
If you are confused on the math behind sorting a set of numbers, you can google "array sort algorithm" and get lots of good information about different ways to sort stuff.
If you are confused on how to implement such an algorithm in the sc2 editor, there is actually a templete by blizzard. In the trigger editor, click view and make sure "Show Libraries" is check. Then open Built-In>Template>Algorithms to see some example actions that sort an array of scores. You can also just search your question on this website to find other threads about this.
not sure if im doing is right, i didnt try it yet, if im doing this right to find witch value is highest u just check its numeration in player group from 1 to 12
i checked algorithms and looks like mine informatics knowlage is too low, cuz i dont understand how its working at all :/
and my function is not wokring also.
@DarcZaFire: Go
@ZMilla93: Go
I don't think he wants to sort his array as each element probably corresponds with each player, I think this is something like what he wants
Some psuedo-code there, but it tells him who has the highest score and what it is.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
i tried find highest to add it to player group be4 others and then find hiest of them and then add that player, i thought i can use group like list where i pick player with higest score and add players one by one to this group, but by some reason player groups dont work like i thought or maybe i do something wrong.
doublepost
@uroboros1987: Go
Player groups inherently sort players from 0-15 as they are added to their group.
It sound like what you want is a record containing both a score and that players number. You then sort the struct based on the scores, moving the player number with it.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
for loop [index] from 1-12
if "Score[index] >/= Rank[0][2]
Set Rank[0][1]=[index]
Set Rank[0][2]=Score[index]
For loop[index2] from 12-1 (Not sure if you can run a loop backwards setting it to -1 intervals)
Set Rank[index2][1]=Rank[index2-1][1]
Set Rank[index2][2]=Rank[index2-1][2]
Its 2:30 AM and I may not be thinking clearly on this one, but this is the theory (Someone fix it if im wrong)
Run a loop from 1-12 for each player.
Rank[0][2] will hold the value of the highest scoring player currently, a standard for which to compare the current value.
When a new high score is achieved, rank[0][1] records the players index, and rank[0][2] holds their score.
then a second loop is run, which "bumps" every value down 1 notch. Rank[1][1] becomes Rank[0][1], which is your new high score; while the old [1][1] turns to [2][1]
*Be sure to wipe values on ranks between running though.
Skype: [email protected] Current Project: Custom Hero Arena! US: battlenet:://starcraft/map/1/263274 EU: battlenet:://starcraft/map/2/186418
I listen to all u guys said and made this function, i used method from Algorithm folder ZMilla told me to check and mixed with GlornII array method, but i used 2 different variables instead of 1 with double arrays. Function is working fine, ill upload video right now, but im not sure if it has bugs or not and i hope it wont cause laggs on bnet.