Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Calculate Ratio's?
Calculate Ratio's?
Feb 13 2010, 12:04 am
By: Oo.DaMeiN.oO  

Feb 13 2010, 12:04 am Oo.DaMeiN.oO Post #1



I have a map that I would like to constantly calculate a kill/death ratio.

What would be the best way of doing this with the lowest trigger count, but still 100% accurate?


The counter is setup like so:

+1 kill = 1 Death to Unit KillCounter
+1 Death = 1 Razings


With that being said I can keep track, but I don't know of a way to do a ratio to figure out between six players who has the best out of all.



None.

Feb 13 2010, 12:14 am Positively Post #2



Hmm. Maybe the "suffered most deaths" under actions will work when you alter the death count for a unit? Then the person who has the most, you can activate the trigger needed for them?



None.

Feb 13 2010, 12:29 am JaFF Post #3



I don't completely understand the setup, but here goes:

If you're using a deathcounter to store the kills and a ranzings score to store the deaths, you could apply binary countoffs to get an approximate ratio.



None.

Feb 13 2010, 12:34 am Gigins Post #4



I think he meant math, like Counter-strike and alike kill/death ration. Like if you have 10 kills and 5 deaths your ration is 10/5=2.



None.

Feb 13 2010, 1:23 am rockz Post #5

ᴄʜᴇᴇsᴇ ɪᴛ!

Easy solution: Add 1 for kills, subtract 1 for deaths. No k/d ratio, but scores the same way.

Hard solution: http://www.staredit.net/wiki/Counter_Arithmetic

You'll have to use division and subtraction a LOT. I'd recommend:

DC Kill -> actual kills
DC Kill 2 -> copy of kills to restore to
DC Death -> actual deaths
DC Death 2 -> copy of deaths to restore to
DC Copy -> needed for copying

First transfer everything into copies (basic, I shouldn't have to tell you how to do this if you're going to do it)

Subtract DC Kill and DC Death into DC Copy. Add 100 to DC Result.
Move DC Copy into DC Death.
I don't think you can "binarify" this part though. That means you'll probably need to copy these sets of triggers, say, 100 times for a 100/1 K/D ratio max.

If DC Death > DC Kill during this, or they both=0, you can stop.

Now, we need to find the tenths place.

Move DC Copy into DC Kill, with a multiple of 10 (ie 1 Copy= 10 Kill). Also add DC Copy back into DC Death.
Subtract DC Kill and DC Death into DC Copy. Add 10 to DC Result.
etc...

Now we need to find the hundredths place.
Move DC Copy into DC Kill, with a multiple of 10 (ie 1 Copy= 10 Kill). Also add DC Copy back into DC Death.
Subtract DC Kill and DC Death into DC Copy. Add 1 to DC Result.

Any remainder is insignificant, and we'll assume we round down. You can round to the nearest, but that's an extra trigger to an already bloated system.

Now you have 0 in DC Kill, Remainder in DC Death, another remainder in DC Copy, and the Ratio as a percentage in DC Result. If you want to display DC Result, display kills of unitid:228+DC Result.

Copy DC Kill 2 into DC Kill and DC Death 2 into DC Death.

Now walking through it, say you have 5 kills, 7 deaths. The fraction is .71.

DC Kill = 5
DC Death = 7
DC Kill 2 = 5
DC Death 2 = 7

Trigger set 1:
DC Kill = 0
DC Death = 2
DC Copy = 5
DC Death isn't 0, so don't add 100 and end trigger set 1.

Trigger set 2:
DC Kill = 50
DC Death = 7
->
DC Kill = 43
DC Death = 0
DC Copy = 7
DC Result = 10
...
DC Kill = 0
DC Death = 6
DC Copy = 1
DC Result = 70
DC Kill = 0 and DC Death doesn't, don't add 10 this time.

Trigger set 3:
DC Kill = 10
DC Death = 7
etc...
DC Kill = 0
DC Death = 4
DC Copy = 3
DC Result = 71.

If it sounds ridiculously difficult, well, it is. If you want to go out further, just copy trigger sets 2 and 3 into more decimal places, and add numbers accordingly to the result DC in each of the trigger sets (1000 in 1, 100 in 2, 10 in 3, 1 in 4). Note the most you need in Trigger sets after 1 is 10 copies.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Feb 13 2010, 1:28 am Gigins Post #6



I think whatever effect you're trying to achieve, this is not worth it. Do this only if it's significant to the map itself.



None.

Feb 15 2010, 1:31 pm Oo.DaMeiN.oO Post #7



Well, its not really significant its just that I would like to be able to do it effectively.

I'll explain a little better.

You can get points three ways:

+1 Point for a kill against an opposing player.
+5 Points for 5 consecutive kills on an opposing player.
+15 Points for the return of a flag against the opposing team.

And then -1 Point for a death via the opposing team.


So at the end of the game, I want to display who has the most kills/least deaths. But if I do just a simple trigger of "Player has the most deaths of x unit(Killcount) and Player has the least razings" then it would ONLY run if said player gets both correctly, but there still might be a player who actually has a better score by getting really low deaths and only a decent amount of kills.



None.

Feb 15 2010, 6:03 pm ImagoDeo Post #8



Just use a custom scoreboard. Whenever the player accomplishes the three things mentioned above that add points, add points to 'custom'. Whenever he or she dies, subtract one from custom. You can also keep track of the deaths and kills in separate death counts and display them at the end of the game.

To display deaths in a leaderboard, use the kills leaderboard and display kills of IDx+228, where x is the unit ID of the deaths you want to display. Then you can display most/least deaths and most/least kills based on the death counts.



None.

Feb 15 2010, 9:16 pm rockz Post #9

ᴄʜᴇᴇsᴇ ɪᴛ!

Quote from rockz
Easy solution: Add 1 for kills, subtract 1 for deaths. No k/d ratio, but scores the same way.
seriously.
The triggers aren't exact (you'll need to use kills to cash), but:

Current player kills 1 unit
Add 1 to DC Kills
Add 1 to DC Score
Add 1 to DC Killcount

Current Player suffers 1 death
Add 1 to DC Deaths
Add -1 from DC Score
Set DC Killcount to 0

Current player captures flag
Add 15 to DC Score

Current player suffered 5 deaths of DC Killcount
Add 5 to DC Score
Set DC Killcount to 0

If you want it to be cumulative (ie 5 at 5, 10 at 10, 15 at 15) then you can just use a binary countoff to get every kill from "DC killcount" into "DC Score" at 5 intervals. There will have to be a max at some point in time.

Show DC Score at the end on the leaderboard. It will correctly show negative numbers as well. If you don't want to include flag returns/bonus kills in the individual score, then don't.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Feb 15 2010, 10:07 pm Decency Post #10



Quote
Show DC Score at the end on the leaderboard. It will correctly show negative numbers as well.
It's rare but common enough that it's a problem, sometimes players die more than they flag/bonus. Say my score is 21K 37D 0 Bonus 1 Flag. My true score is negative 1, I don't see how this would show it unless the scoreboard itself can handle negative numbers, which I've never seen before. The only solutions that have been used before are initializing to a set value before the game starts that's too high to sub-zero, or counting "negatives" in a separate death counter.

Damein were you actually intending to do a ratio, ie: a fraction, or did you just want the difference, ie: kills minus deaths...?



None.

Feb 15 2010, 10:50 pm stickynote Post #11



Here's how to kill/death ratio, it's deceptively simple. My solution: let the players do the math themselves. :omfg:
Create a drone for the player when they get a kill. Create (or give) a hatchery to the player when they die. Then, their zerg population will represent kills/death. Of course, you can't use zerg then, unless you only have zerg heroes, who don't use up any control.



None.

Feb 15 2010, 11:05 pm rockz Post #12

ᴄʜᴇᴇsᴇ ɪᴛ!

Quote from name:FaZ-
Damein were you actually intending to do a ratio, ie: a fraction, or did you just want the difference, ie: kills minus deaths...?
He wants to show the MVP at the end of the game.

Post has been edited 1 time(s), last time on Feb 15 2010, 11:11 pm by rockz.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Feb 16 2010, 5:52 am Decency Post #13



That's already been done, he's already done it himself. I'm curious whether he actually wanted to try to get the "ratio" like he said, or not.

And rockz, you didn't answer my question above. =o



None.

Feb 16 2010, 7:50 am JaFF Post #14



Quote from name:FaZ-
That's already been done, he's already done it himself. I'm curious whether he actually wanted to try to get the "ratio" like he said, or not.

And rockz, you didn't answer my question above. =o
A ratio of two numbers is one divided by the other. Otherwise this topic wouldn't exist (or go this far), because subtracting is easy.



None.

Feb 16 2010, 8:36 am rockz Post #15

ᴄʜᴇᴇsᴇ ɪᴛ!

Well I told him how to calculate the ratio, but it's obviously too much. I know I didn't answer your question, but I answered both of the possible answers he could have given.

So damein, who is the MVP of this game?
Player 1: 300 kills, 200 deaths
Player 2: 10 kills, 5 deaths

If player 1, use my second method posted (the easy solution).
If player 2, use my first method (the ridiculously hard solution).

Player 1 is obviously the MVP in my book, but Player 2 has the highest k:d ratio.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Feb 16 2010, 1:09 pm Oo.DaMeiN.oO Post #16



Yes FaZ-, I would rather implement a true ratio system instead of just displaying kills/deaths.

And rockz, to me that is obviously P1 as well, but I can put it more realistic.

Player 1: 52 kills, 38 deaths
Player 2: 35 kills, 18 deaths

Now would this be simply a matter of subtraction where P1 would come out the MVP still? Even though he had such high deaths.

Or is it something that I am missing, I apologize, I am one of the worst mathematician's in the world. :/



None.

Feb 16 2010, 5:57 pm CecilSunkure Post #17



Well, the thing is, using these two links:

http://www.staredit.net/wiki/Binary_Countoffs
http://www.staredit.net/wiki/Counter_Arithmetic

You can calculate ratios. Although, assuming the scores of your map are going to stay relatively low, these methods will only give you rather bad approximations of ratios, because data manipulation in SC sucks. So you have to be a little tricky. What is division? Division is finding out how many times a number fits into another number. How can you do this with only addition//subtraction? Well, you use subtraction.

How many times does 2 fit into 10? Iterate 10 - 2 and count how many times this happens until the result = 0. Why until it hits 0? Well if the result is zero, then the numbers are divisible into an integer. During this iteration, you subtracted 2 from 10 5 times, for a ratio of 5 k:d.

Now, what if the ratio is a little more complicated, to where the quotient is not 0? That means you end up with an uglier ratio, something like 2.24 instead of just 2. So now, lets apply the same process to a more complex example. Lets say the kills sit at 2, and the deaths at 5. Here is the process:

5 - 2 = 3
3 != 0 --> Repeat and +1 to iteration count (subtracted once so far)
3 - 2 = 1
1 != 0 --> Repeat and +1 to iteration count (subtracted twice so far)
1 - 2 = -1

Now here we have a problem, because things start getting very complicated since data manipulation in SC sucks, and we can't really have negative deaths of something. So what you have to do, is detect when you are going to end up with a negative number during an iteration, and stop before this happens. To do this, you add in a step before you start your subtraction. This step will allow you to know in advance, when an iteration (subtraction) will result in a negative number (well actually result in a 0 deaths within triggers).

Say we have our ratio of 10:3. The beginning step will be to create a copy of the deaths. Using this copy of deaths, we can make sure that we don't subtract our kills from the deaths, if the deaths are less than the kills. Here will be our new process:

copy = 3
10 - 3 = 7
7 != 0 and 7 > 3(copy) --> repeat and +1 iteration
7 - 3 = 4
4 != 0 and 4 > 3(copy) --> repeat and +1 iteration
4 - 3 = 1
1 != 0 but 1 < 3(copy) --> +1 iteration, do not repeat

Now we have our first digit, which is the iteration sum, and is 3. You can repeat this process over using the 1 and the 3 resulting in a sum of 3. This is because the remainder of the first process, the 1, is a representation of the digit to the right of our first result.

Let me know if you see a problem with my logic, or whatever, or if you still don't understand. I honestly am unsure of how rockz's method really works, I just made this one up on the spot. rockz's method is probably less trigger-intensive, I would assume. I just wanted to explain the idea behind what is going on.

[Edit]Never mind. Mine is the same as his.

Post has been edited 1 time(s), last time on Feb 16 2010, 6:54 pm by Cervantes.



None.

Feb 16 2010, 6:38 pm rockz Post #18

ᴄʜᴇᴇsᴇ ɪᴛ!

Quote from Oo.DaMeiN.oO
Yes FaZ-, I would rather implement a true ratio system instead of just displaying kills/deaths.

And rockz, to me that is obviously P1 as well, but I can put it more realistic.

Player 1: 52 kills, 38 deaths
Player 2: 35 kills, 18 deaths

Now would this be simply a matter of subtraction where P1 would come out the MVP still? Even though he had such high deaths.

Or is it something that I am missing, I apologize, I am one of the worst mathematician's in the world. :/
No, that's not a good example at all. P2 is obviously the MVP. Not only did he net the team 17 points, he has a K:D ratio of 1.9:1. Player 1 only net 14 points and has a 1.4:1. My example shows you an extreme. Player 1 nets you 100 points with a 1.5:2 ratio. Player 2 nets you 5 points with a 2:1 ratio. You want to go by points, so you add/subtract.

The two ways I've posted are the way to do this. The first being ratio, the second being point. I suggest you give up on ratios, since it's too hard. What don't you understand about either method?

@cecil, we have the same method.

Post has been edited 1 time(s), last time on Feb 16 2010, 6:48 pm by rockz.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Feb 16 2010, 11:50 pm Decency Post #19



Quote from name:FaZ-
Quote from rockz
Show DC Score at the end on the leaderboard. It will correctly show negative numbers as well.
It's rare but common enough that it's a problem, sometimes players die more than they flag/bonus. Say my score is 21K 37D 0 Bonus 1 Flag. My true score is negative 1, I don't see how this would show it unless the scoreboard itself can handle negative numbers, which I've never seen before. The only solutions that have been used before are initializing to a set value before the game starts that's too high to sub-zero, or counting "negatives" in a separate death counter.

Lol my question to you, not to Damein. You said this will show negatives but I don't know how to go about doing that unless it's one of the ways I gave. What am I missing?



None.

Feb 17 2010, 1:23 am rockz Post #20

ᴄʜᴇᴇsᴇ ɪᴛ!

Add negative 1 rather than subtract 1. Sorry, you never actually asked a question, so I didn't know I was supposed to respond.

It doesn't treat them like negatives, but rather like a REALLY big number. To the end user that shouldn't matter. -1 is actually FFFFFFFF, or 4924967295.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[09:18 pm]
Ultraviolet -- 🔪🐈
[12:34 pm]
NudeRaider -- curiosity kills the cat!
[06:18 am]
Sylph-Of-Space -- No complaints here, i'm just curious!
[2024-5-18. : 11:05 pm]
Ultraviolet -- :wob:
[2024-5-18. : 3:55 pm]
Zoan -- :wob:
[2024-5-18. : 10:34 am]
NudeRaider -- SEN doesn't rely on spammers initiate its sleep cycle. It hat fully automated rest and clean-up phases. Please understand that this is necessary for the smooth operation of the site. Thank you.
[2024-5-18. : 3:45 am]
Sylph-Of-Space -- Does the shoutbox get disabled when there's spammers?
[2024-5-17. : 6:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[2024-5-17. : 5:41 am]
Ultraviolet -- 🤔 so inf is in you?
[2024-5-17. : 4:57 am]
O)FaRTy1billion[MM] -- my name is mud
Please log in to shout.


Members Online: Rawflesh0615