Defining mathematical unit balance metrics

Discussion in 'Balance Discussions' started by godde, February 6, 2014.

  1. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    I'm not sure how I want to set it up. It were BulletMagnets idea. Mm... And why isn't HP included? ... Mm... I should get some sleep.
  2. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    Had a quick look at it, and yeah - you'll have to have some sort of normalisation between variables. I don't know what that's going to be at the moment, or if a sensible one exists.

    I made the suggestion with one thing in mind; getting a measurement for PEWPEWabilty that factored-in kiting. Naturally, something with lots of DPS, long range, and is fast is going to be hilariously strong. Anything like that should score very highly, and stand out to everyone. It doesn't necessarily mean it's OP, because it may be both expensive and weak.

    On the topic of comparing mobile and static units, don't calculate it with zeroes. Skip them like they never existed.

    Code:
        def geomean2(numbers):
            product = 1
            count = 0
            for n in numbers:
                if n <> 0:
                    product *= n
                    count += 1
            return product ** (1.0 / count)
    Maybe compare against a commander?
  3. stormingkiwi

    stormingkiwi Post Master General

    Messages:
    3,266
    Likes Received:
    1,355
    The problem with PA is health, damage and refire rate are absolutely secondary to speed and range, and metal cost is not important at all. Cost to run fabrication is the more important factor, as is deployment time.
  4. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    Hm... could be sort of useful although I still think it is better to compare kiting ability on a unit versus unit basis.

    It seems rather arbitrary. Thing is that you if you skip it, it is the same thing as multiplying it with 1.
    So a unit without any DPS, Range or Speed would get a value of 1.
    A really weak unit that actually have some of those stats would rate lower than 1 or if you divided the unit stats with, say... 100, would also rate lower than the default 1.

    Eventually I will.

    Edit:Updated the database. 0 value for geometric mean defaults to 1. For now...
    Last edited: February 7, 2014
  5. bobucles

    bobucles Post Master General

    Messages:
    3,388
    Likes Received:
    558
    Welcome to RTS design 102. Each type of attribute excels in a certain situation and can be exploited in different ways. It is impossible to know the true value of a particular attribute because it changes against everything else in the game, and it changes second by second as the field changes. You can only figure out where an attribute is biased to be super effective and where it isn't. Sometimes this can only be discovered through play testing, but most of the time a bias is pretty simple to figure out.

    If that sounds like Pokemon, congrats! It kind of is, except instead of elements you have behaviors/abilities.
    vyolin and liltbrockie like this.
  6. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    If it is simple to figure out then it is also simple to define as a metric. You can then calculate the balance between the units based on this metric and this should be a reasonably accurate model for the unit interactions that occurs under a specific set of circumstances.

    What do you mean by "refire rate"? Is that like reload time or as I like to call it, alpha damage or burst damage?
    Metal cost is important. Metal cost determines how many units you can get in a set amount of time.
    Cost to run fabrication is what I like to call, Infrastructure cost which is (fabber or factory metal cost + energy requirement cost).
    Also what do you mean by deployment time?
    Is that variable on how long it takes for the unit to reach the front?
  7. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    The main reason to skip things is to decrease the size of len(numbers) because not doing so decreases the final score.

    Of course, that itself may be a good thing - a tank that has identical stats to a turret should score higher. It does have the added advantage of being mobile.


    I'd hazard a guess that deployment time is the sum of construction time and roll-off time. Time taken to reach the battle is important, but can't be factored into any equation because it's determined solely by player action (ie. where did you build your factory, and where did your enemy attack).
  8. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    Oh. I see. You reduce the factor of the root. Problem is that it also is sensitive to the unit of measurement. An important goal when you define a balance metric is that the unit relationships that is calculated by the metric should remain the same between the units regardless of the unit of measurement.
    Lets say you have a unit with 9 DPS, 3 Range and 1 Speed.
    The geometric mean for that equals to 3. The cube-root of 27 = 9*3*1
    An immobile unit with 3 DPS and 3 Range also get a geometric mean of 3 if you disregard the Speed variable as you will only do the square-root of 9.
    3 DPS * 3 Range.
    Also if you change the unit of measurement for speed you get a different relationship.
    Lets say we count speed in decimeters per second instead of meters per second.
    First unit: 9 DPS, 3 Range, 1*10 Speed. Geometric mean = 6,46
    Second unit: 3 DPS, 3 Range, 0*10 Speed. Geometric mean = 3.
    The relationship have changed.


    Although you could compare it between different units if you include the distance to the "deployment location" although that is variable on the player actions yes.
    BulletMagnet likes this.
  9. bobucles

    bobucles Post Master General

    Messages:
    3,388
    Likes Received:
    558
    What the hell are you doing with range?

    The important factor that changes with range is time spent shooting, which also depends entirely on the speed and agility of everyone involved. A tank charging a turret is different from two tanks charging, which is different from one bot kiting a tank, which is different from mid range artillery, which is different from long range artillery.

    The purpose of range is to maximize outgoing damage, while minimizing the risk against incoming damage. It also dramatically alters synergy in group battles. Range is both as both an offensive and defensive trait, and its exact value is not so easily pinned down.
    No. It isn't. It's really not. If that were the case, great RTS games would be made by machines and not people.

    Specific advantages may be easy to identify and are okay to ballpark(granted this means having GOOD balance metrics to begin with), but the actual value of any one thing depends on everything else in the game. Uber is opting to ignore and remove these interactions by placing hard targeting restrictions or using such outlandish metrics that one unit is guaranteed to beat the other with brute force. While some hard counters aren't a bad thing, this low level philosophy is extremely damaging to the tactical aspects of the game.
  10. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    If you are refering to geometric mean of Range, DPS and Speed I don't know. I'm not convinced it is a good balance metric.

    This is why you have to do it on a unit versus unit basis. Determining if a unit can kite another unit is simple. Calculating how many tanks that you need to get in range and destroy a turret is also pretty straightforward

    I agree.

    Give me an example of something that is easy to figure out but hard to define.
    Also I think that just like balance varies depending on the map, you could play the same map with different balance. It is then up to the players to figure out which units and strategies that are the best just like they have to figure if they should focus on vehicle, bot, sea or air production.

    I think that defining and using mathematical balance metrics is a good supplement to understanding the balance of the game. After all, the game is nothing but math.
    Last edited: February 9, 2014
  11. mabdeno

    mabdeno Active Member

    Messages:
    138
    Likes Received:
    67
    Would a better way of doing this show two metrics for two different levels of statistics.

    You could have DPS+Health/cost and then Range+Speed/Cost and have the units listed as *name* metric1/metric2 this would give a general overview of each unit.

    Factors like turret speed and acceleration wouldnt affect the numbers for a general overview as those statistics tend to be very situational on the battlefield.
  12. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    Been having a think about metrics for dps and health. Thought of one giant, glaring, problem with my equation.

    Suppose we double the health of everything, and double the damage of every weapon. We can all see that those changes amount to nothing; everything behaves exactly the same.

    But the scores using my geometric mean go up. Potentially by a bloody lot. Balance hasn't actually changed, so scores really shouldn't either.



    DPS/average-health might be more applicable. Or DPS per something, where that something goes up when you increase the health of units.
  13. stormingkiwi

    stormingkiwi Post Master General

    Messages:
    3,266
    Likes Received:
    1,355
    I have absolutely no idea what you mean by alpha or burst. I had a brain fail, and I meant rate of fire.

    Metal cost is not important. A Leveller costs 450 metal and a Pounder 150. Both take 10 seconds to build, so in 40 seconds you can expect to have 4 of both, assuming you have also added roll-off time.

    For the same metal *cost* however, you can expect to have 4 Levellers and 12 Pounders.

    Unless your economy is running at 50% efficiency. In which case, halve the numbers.

    To figure out how many units you can get in a set amount of time, you need to
    1. Take unit metal cost
    2. Divide it by the Fabrication Metal Consumption of the factory and any assisting fabbers.
    3. Divide it by your build efficiency.
    4. Add the roll-off time for the factory onto that number
    5. Divide the set amount of time by that number.
    For a unit from a given unassisted factory, the result of step 1 and step 2 is constant, and can just be a given single value (build time), and step 4 is always constant. The unit metal cost is quite irrelevant - it only makes sense when you consider fabrication metal consumption, and fabrication metal consumption only makes sense after you consider your metal income and your build efficiency.

    Basically the information contained in "metal cost" is much easier to understand as a constant.

    I had another fail - deployment time was me thinking about build time for a building. Once again, that depends on how much build power you put on it. Metal cost is more relevant for buildings because, unlike units, the fabrication metal consumption is "more constant"
  14. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    When I use a metric I use it for a purpose and try to map it into an ingame situation or relation.
    Nullimus is trying to do an overall cost/benefit analysis where he compares all units against each other. It might work as a general overview but it doesn't say much about the interaction between the units and I don't think it will be that useful for understanding the game or the game balance.
    If you want to have an overview of a unit you need first and foremost to understand its' role(s) and I'd say that it can't really be expressed in just a single number. You have to use different metrics for different purposes to define roles. Of course you can combine 2 or more metrics to create a new metric for which it might reflect a broader or in the opposite, more narrow unit interrelationship.

    I'm thinking about how to use turret speed, turn rate and acceleration in the later, unit versus unit match-ups. I think I'm gonna try to define some relationship as "Reaction time".
    Lets say I chase your unit. My unit have the same speed as your unit but have much slower turn rate. My unit will be able to keep up with your unit. However, if you decide to turn as you meet up with some re-enforcement for example, my units "Reaction time" might be too slow for it to turn in time to retreat and your unit(s) will come in range of my unit.
    If the difference in "Reaction time" is too big, even if my unit have the potential to kite your units because it is faster and have longer range, my unit might be unable to effectively kite your units as you can just turn around when I chase you and close the distance before my units can start retreating.
  15. Clopse

    Clopse Post Master General

    Messages:
    2,535
    Likes Received:
    2,865
    I think it's so hard to balance or try evaluate each unit like this. Simple math/ common sense / situational awareness and picking what units suit you the best are all player traits.

    Of course known what has the quicker turn rate and speed help but if you are terrible at micro moves like kiting, bombing key targets or flanking then the super formulae one could make will have no benefit.

    There are just too many variables to take into consideration. Simple ones like will 4 dox kill an air turret? No, therefore they don't make cost against Air turrets. But 8 has a good chance of killing 2. Is making 60 t2 bombers better than making a nuke. Yes but can you trust yourself to scout the whole enemy base every 3 minutes and make it through his defense. No.
  16. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    DPS * health is a useful metric. I've been thinking about calling it Strength or Power but I think I reserve Strength only for "Strength / 1 metal cost".
    If you disregard the individual projectile damage and view damage as a completely continuous and instant process you can make some pretty broad generalisations for 1v1 unit match-ups.
    If the Power of the units are the same they will always kill each other in 1v1.
    Take a unit with 1 DPS and 10 Health versus a unit with 10 DPS and 1 Health. They will both have a Power value of 10 and will kill each other in 1 second. Unit with 5 DPS and 20 Health versus a unit with 10 DPS and 10 Health both have a Power value of 100 and will kill each other in 2 seconds.

    1v1
    When comparing units with different Power values you can do simple subtraction.
    Unit with 5 DPS and 60 Health(300 Power) versus a unit with 2.5 DPS and 20 Health(50 Power).
    300-50 = 250
    The 'heavier' unit will have 250/300 = 83,3% health left or simply 50 Health.
    This makes it easy to calculate how many units the heavier unit can defeat one by one.
    Heavy unit Power / light unit power
    300/50 = 6

    Light units versus 1 Heavy unit
    However if you want to calculate how many Light units it takes to destroy a Heavier unit it gets a little more tricky.
    You can calculate the cumulative strength of Light units like this:
    1 * 50 = 50
    2 * 50 + 1 * 50 = 150
    3 * 50 + 2 *50 + 1 * 50 = 300
    The first unit deals its' Power value once and is then killed.
    The second unit deals its' whole Power value once as the first unit is killed and then deals its Power value again before it is killed.
    The third unit deals its' Power value 2 times as the other units gets destroyed and once again before it is destroyed.
    So three units of Power 50 is required to destroy a unit of Power 300.

    Back to Strength per 1 metal cost. (DPS / cost) * (Health / Cost)
    This also works to determine which unit of 2 units that will win if they have the same cost.
    However, a heavy unit will beat its' cost against lighter units if they have the same Strength / metal cost.
    ____________Unit A________________ ____________Unit B___________
    (6 DPS / 6 Cost) * (6 Health / 6 Cost) = (1 DPS / 1 Cost)*(1 DPS / 1 Cost) = 1
    Unit Power = 6*6 = 36
    Required number of Unit A to defeat one Unit B: 8
    8*1 + 7*1 + 6*1 + 5*1 + 4*1 + 3*1 + 2*1 + 1*1 = 36
    Because of the gradual loss of Firepower, 8 of Unit B is required to defeat one Unit A.
    Even though they have the same Strength for cost, Unit A is 33% more effective because it has heavier weight.
    The advantage of Strength for cost maxes out at 50%. A very heavy unit could potentially beat twice its' cost against very light units. You could compensate for that by increasing the cost of the heavy unit twice. However if there is an even heavier unit and compensate for that one as well, that unit will actually lose against its' cost in very light units. Arguably heavier units shouldn't have higher Strength / 1 metal as they usually are more compact and doesn't suffer from splash damage in the same way as lighter units does.

    What about X number of units of Power A versus Y number of Power B?
    This is tricky to know as it is very specific to the situation ingame.
    If you are chasing the enemy and are just barely catching up, this is similar to sending units 1v1 against the enemy. It heavily favors heavy units.
    If both the light and heavy units have similar footprint and range, the efficiency it is likely to be somewhere between going in 1v1 and having several light units attacking 1 heavy unit.
    The best case scenario for light units is if they concentrate their fire on 1 heavy unit at a time. In battles between large numbers of units, this can almost negate the advantage of weight. Lanchesters square law applies here however it rarely applies in PA as units die off too fast and units are usually fighting on the edges of their ranges.
    If I understand Lanchesters' square law correctly, β would be (DPS * Health) for unit B while α is (DPS * Health) for unit A.
    dA/dt = -βB
    dB/dt = -αA


    Note that this doesn't take overkill, splash damage, formations and such into consideration.
    Last edited: February 20, 2014
  17. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    Alpha damage is how much damage the first projectile(s) does as they are fired before the unit have to reload, simply how much damage the weapon(s) does. Changing alpha damage while keeping DPS the same changes unit interrelationships as it can be the difference between one-shooting or two-shooting an enemy unit. It is also relevant for amount of overkill.
    Burst damage is if the unit fires bursts of projectiles or bombs and then reloads. Bombers could be said to use burst damage as they drop all their loaded bombs and then have to reload slowly.
    Anyone know where I can find how fast bombers reload/rearm?

    I do view "metal cost" as a constant. Energy consumption or energy cost per unit is variable on the fabber or factory.

    I have added "Infrastructure/1 cost production" to units built by factories(except orbital). It shows how much metal you have to pay to get 1 metal production of that type of unit. It takes Roll-off time into account. I plan on showing optimal assisted infrastructure/1 cost production which calculates it with the most efficient fabbers and most efficient number of fabbers assisting.
  18. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    Experience and skill trumps theoretical knowledge.

    I'd say that am more or less consciously aware of these metrics that I am trying to implement. I think that intuition is basically an unconscious body of knowledge that surfaces as opinions and behaviours.
    Your intuition might be right, but do you know why your intuition is right?

    By analysing your decision-making you can surface and examine knowledge rationally.
    You might discover why your intuition is right and further amplify successful behaviour.
    You might also discover discrepancies that despite your feelings, stands in the way of your success.

    Now I can fairly easily say that Slammers are better than Doxes. Slammers are more than twice as costeffective(Strength per 1 metal: Slammer 0.4630, Dox 0.1975.), have the same speed while also having longer range. The higher infrastructure cost for Slammer production(245.5 versus 112.2) does not offset the military advantage and there is even potential to decrease that cost by assisting the Advanced Bot factory.
  19. Xagar

    Xagar Active Member

    Messages:
    321
    Likes Received:
    117
    In PADB the per shot value is "Weapon energy consumption" under Economy and the total ammo is "Energy consumption: x per shot (x per second)" under the Weapon.

    Right now I believe all weapons have reload rates equal to their fire rate.
  20. godde

    godde Well-Known Member

    Messages:
    1,425
    Likes Received:
    499
    Right. Thanks. I didn't notice.

    Edit:I think it says that Hornet stores 10 bombs and reloads 1 every second.

    bomber_adv_tool_weapon.json:
    Code:
    "ammo_source":"energy","rate_of_fire":10,"ammo_capacity":10000,"ammo_demand":1000,"ammo_per_shot":1000,
    Last edited: February 11, 2014

Share This Page