Im trying to recreate a ranking system similar to that of a racing game where a dialog tells you what "place" you're in, for example first, second, or third. Ive already simplified everything down to a comparison of a single value for each player, I just need to be able to determine the biggest value, and then the second biggest value, and so on until every player has been accounted for. So I have a set of numbers, representing player scores, that need to be compared. I need to be able to determine the player responsible for a given value, as well as its ranking among the others within the set, from biggest to smallest.
I looked up some sorting techniques and tried one that had me run 3 loops within each other, with the outer loops' number determining the boundaries of the inner loops. My issue is I dont have a grasp on what they are doing which makes it hard to work with them. I understand how a loop works, but Ive never had to run 3 within each other with variable bounds before.
for each integer x from 1 to the number of players in active players Set player x rank = 1 for each integer y from 1 to the number of players in active players If and player x score <= player y score x != y then modify Player x rank + 1 else end loop end loop
What these lines of code do, is for each player in the game, if the score of player x is less than the score of player y, he gets 1 added to his rank which at the beginning of each check is reset to 1 and then modified from there.
A loop within a loop is the same as an old-school clock. One hour ticks by on the big hand (outside loop) then the minute hand ticks 60 minutes (inside loop), then the big hand ticks to hour 2, and the little hand ticks 60 minutes again, and so on.
Im trying to recreate a ranking system similar to that of a racing game where a dialog tells you what "place" you're in, for example first, second, or third. Ive already simplified everything down to a comparison of a single value for each player, I just need to be able to determine the biggest value, and then the second biggest value, and so on until every player has been accounted for. So I have a set of numbers, representing player scores, that need to be compared. I need to be able to determine the player responsible for a given value, as well as its ranking among the others within the set, from biggest to smallest.
I looked up some sorting techniques and tried one that had me run 3 loops within each other, with the outer loops' number determining the boundaries of the inner loops. My issue is I dont have a grasp on what they are doing which makes it hard to work with them. I understand how a loop works, but Ive never had to run 3 within each other with variable bounds before.
you could also run a loop
for each integer x from 1 to the number of players in active players
Set player x rank = 1
for each integer y from 1 to the number of players in active players
If
and
player x score <= player y score
x != y
then modify Player x rank + 1
else
end loop
end loop
What these lines of code do, is for each player in the game, if the score of player x is less than the score of player y, he gets 1 added to his rank which at the beginning of each check is reset to 1 and then modified from there.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
A loop within a loop is the same as an old-school clock. One hour ticks by on the big hand (outside loop) then the minute hand ticks 60 minutes (inside loop), then the big hand ticks to hour 2, and the little hand ticks 60 minutes again, and so on.
Thanks for the help guys i figured it out.