Now, I think a good estimate of the combat power of a group should start by counting the number of units, modified for combat points. So, does a unit-strength function exist?

I tried using the Battle Calculator to run some simulations, and very quickly found unexpected issues and complications.

For example, if you take 30 1-point units against 30 1-point units, you would expect the attacker and defender to win 50% of the time, with maybe 1 or 2 units left. Not so! OK, so let's do some simple calculations.

1 v 1: 5/36 A wins, 5/36 D wins, 1/36 draw, 25/36 no effect, thus 45% A wins, 45% D wins, 9% draw.

2 v 2: 8/36 A wins, 8/36 D wins, 4/36 draw, 16/36 no effect, thus 40% A wins, 40% D wins, 20% draw.

3 v 3: 9/36 A wins, 9/36 D wins, 9/36 draw, 9/36 no effect, thus 33% A wins, 33% D wins, 33% draw.

4 v 4: 8/36 A wins, 8/36 D wins, 16/36 draw, 4/36 no effect, thus 25% A wins, 25% D wins, 50% draw.

So the combat power has a big effect on the win/draw ratio, but, as the number of units involved goes up, the draw chance goes way down, because the probability of getting exactly the same number of hits on both sides is small. In all cases, the win/lose ratio is in balance.

Back to the 30 v 30 1s. The result after 2k tries is about 50% each win/lose, no draws. It has been established by the small-number trials that the defender gets no advantage for holding the territory. But it is also seen that 2k trials is simply not enough to get really good statistics. The surprising result is that the expected number of surviving units is about 2.5 for the attacker and defender. And that means that, whoever wins, they expect to win with 5 units! I guess that, whoever first gets a hit, that advantage propagates through the rest of the combat, so that, after many rounds, it winds up as quite a substantial gain.

So you can see that there are many factors that affect combat results: the number of units, the combat strength, the number of combat rounds, also the distribution of strengths. has any work been done on this issue?

]]>seek only a function that calculates the power of an army at balance, that is, when your army is as good as the enemy army

I don't quite understand what you are saying. My goal is to calculate army power, but I can only calculate if my opponents army is about equal to my army. Don't I need to be able to calculate army power in order to do affirm if the two armies balanced?

Also, the number of combat rounds would be a function of my power, enemy power, my HP, and enemy HP. So you should be able to build a function that just calls those four instead of adding a new variable.

As a teacher, I'm interested in seeing if something can be done, but I'm not optimistic to be honest.

]]>Funny also, this reminds me of when I was in highschool I drew a chart showing a man 6 feet tall who could jump 3 feet high and next to him was a man 12 feet tall who could jump 6 feet high and I drew a line straight from the 6 foot tall guys head directly to the 12 foot guys head and I said "a guy twice the height of another person will have twice that person's ability to jump" ... and my smarter friends told me my chart was impossible BECAUSE OF GRAVITY ...

so my point is math and physics can be peculiar and so I'm expecting some "unknown factor" to not allow Victorin_Pacific to achieve his objective but again I will wait for more responses!

]]>How many knives should you bring to a gunfight? Obviously, if your army has exactly the same characteristics as the enemy army, then they have the same combat power. But in general, having more weaker units can compensate for a deficit of stronger units, and vice-versa.

The old hands know that there is an Army Power Function 2*U+C that works quite well, where U is the number of hit points and C is the total combat strength. Of course, this must be an approximation, because the combat strength is applied in each combat round, while the hit points count only once, so there must be at least one more factor in the function. However, if the combat lasts 3 rounds or less, then you should be able to calculate the result exactly, while hardly any combat lasts longer than, say, 6 rounds. The function may be analytical (based on analysis) or empirical (based on observations), but it turns out that it is exactly equal to a good, simple analytical function, up to a scaling factor, provided that there are 6 rounds of combat.

Initial considerations indicate that we should look for an Army Power Function that has the form

P = P(U,C,N) ,

where U is the number of hit points, C is the total combat strength, and N is the number of rounds of combat. We try

P = U + N*(f*C/6) ,

noting that it takes a combat strength of 6 to inflict each hit point.

N = U'/(f*C/6), where U' is the number of units in the enemy army, and f is a factor to be determined.

It quickly becomes apparent that there are unexpected and undesirable features to this trial function. According to this function, the power of your army increases when attacking stronger armies, because the number of rounds of combat increases! Indeed, the power is equal to the total number of units in both armies! In general, the Army Power Function depends on the exact nature of the enemy army. Therefore, we abandon the attempt to find a general function that calculates the power of an army, and instead seek only a function that calculates the power of an army *at balance*, that is, when your army is *as good as* the enemy army. Having that, then we can add a couple of units or make a couple of units stronger, because it is known from experience that that increases the probability of winning a battle from 50% to about 95%. (That applies to Low Luck conditions.)

It should be clear that the factor f cannot be unity, because the total combat strength of an army drops each round, unless it is padded with 0-strength units. The rate at which the combat strength drops is nonlinear, because the rate at which the enemy army inflicts casualties decreases each round, unless it is padded.

In order to keep the solution simple but general, we linearize the problem by assuming that the combat strength of each army at balance drops linearly from its maximum value to zero. The expression f*C is equal to the average combat strength of the army, and for this linear decrease, it is equal to half the maximum strength. Thus f = 1/2.

The practical problem at hand is what we need to have in order to equal a specific army, i.e. how many knives do we need to bring to this gunfight. Thus in general, U' and C' will be known, and the average combat strength of your units C/U will be roughly known, so the problem reduces to determining U.

N = U'/(C/12) = U/(C'/12) , so

U/U' = C'/C = (U'*C'/U')/(U*C/U) , so

(U/U')^2 = (C'/U')/(C/U) , so

U/U' = SQRT(c'/c) ,

where c and c' are the average unit strengths of the respective armies.

Let's look at one example to see how this works. The enemy has 10x4. How many 1s do you need to equal this? U/U' = SQRT(4/1) = 2 . Bring 20 units for balance, and 2 more for the win. The power of these armies is P = U + U' = 30.

The number of combat rounds is N = 12x10/20 = 12x20/40 = 6. This is an approximation. Direct calculation shows that each army kills exactly 1/3 of the opposing army in the first combat round and 2/3 of that in the second combat round, for a total of 5/9 in the first 2 rounds. Thus 10 units are reduced to 4.4 in 2 rounds and 2 in 4 rounds and .9 in 6 rounds, so the true number of rounds is about 8.

The army power can also be expressed as P = U + 6xC/12 = (2*U + C)/2 , which is the same as the legacy function, except for the constant scaling factor. Although the legacy function is less accurate, it is easier to use, and does not involve fractions.

Let's see how well the legacy function predicts the number of units you need for balance. The legacy function has 2*U+C = 2*U'+C' , so U*(2+c) = U'*(2+c') , so U/U' = (2+c')/(2+c) . The reader can verify that, for the smallest quality mismatch c=c', U=U' for both functions. Also, for the largest likely mismatch c=1 and c'=4, U/U' = 2 for both functions. For some other cases such as c=1.5 and c'=3, the results are almost identical. Otherwise, the legacy function gives a slightly inaccurate result.

Even then, you really need to factor what units die, if one side is losing more power than the other (a, its a big deal. Occasionally on World War 2 Revised, Germany attacking Russia looks like an even fight, but its heavily German favored (Germany loses low value 1 attack units, while Russia is losing 2 defense units).

If you want another interesting case, look at TWW. Its not uncommon for a heavily fortified Russian city to have fewer hitpoints and lower defense than an attacking German army, but still win the battle 90 to 100% of the time., due to a combination of targeted attacks and 'Skewness'. Even without targeted attacks, less complex abilities such as units supporting each other or having two hitpoints make a big difference.

]]>Given all that, this is why the battle calc is very important and that we generally just use a strength estimate of 2*HP+power to give a very high level estimate of army strength as that is a fairly good yet simple formula.

The biggest issue with the A&A combat system tends to be that 1 or 2 additional units changes a battle from 50/50 to 95% win chance (especially true for LL). The ways to address this drawback is:

- Have more of a ranged suicide unit type map where armies are mostly firing units at each other rather than entire stack vs stack
- Have limited combat rounds so that you can only inflict so many casualties per turn to avoid the first round of battle deciding the fate of the entire stack of units. This allows more tactics around retreating, counterattacking, reinforcing, etc.

this thread is typically why I still read this forum though ... math, ai , strategy etc. etc! so interesting!

]]>About the topic: Not an expert on maths, but I don't think there's a way to calculate some sort of strength of an army without knowing the opponents, there are just too many factors involved.

Because of this the hard AI at least simply uses the BattleCalculator to determine whether or not it's a good idea to attack a certain territory.

Also the reason the AI is relatively CPU-Heavy.

There isn't a great mystery on how to predict battle outcomes, especially if you are doing low luck only. Probability trees do it, most battles don't see more than 4 or 5 rounds of combat so they aren't difficult to use.

A few extremely common battles have been done out with a probability tree on the axis and allies forums (dice and low luck).

]]>So let's call it the "stack power function" instead.

There is a practical purpose to this. Supposing you have some collection of units, and some territory to defend, and the bad guys could attack you with some other collection of units. How much do you need to put there to secure the territory? Or a similar question. Now, you could eyeball it and hope you are right. Or you could move a tentative stack there and then run the Battle Calculator with hypothetical enemy attack stacks, that would be all possible hypothetical attack stacks, unless you want to trust to luck. OK, that may be doable, but it could take a long time. But what if the hypothetical attack is going to happen 3 turns in the future, and it's your capitol, and the outcome of that future hypothetical battle will be used to decide your strategy for the next few turns? Pretty hard to use the Battle Calculator in such a situation, and remember, if you get it wrong, you're out of the game.

So what we seek is some sort of a "stack power function" that will give an approximate *but very good* estimate of whether your stack will beat the enemy stack. That's what I'm trying to do here. And I think I have something useful - stay tuned.

Now, before I get into more detailed calculations, I will show a graphical solution to the paradox A > B > C > A. In the context of the AAA combat system, we know that both number of hit points and combat power are essential in evaluating an army. Thus we are looking at 2-D vectors, and perhaps higher dimensionalities. Add 3 vectors together: you can easily form a triangle, and in fact, in the context of this problem, the evaluation A->B, B->C, C->A must form a triangle. However, it can be seen that if you add only the lengths of these vectors (i.e. attempting to express the values as scalars, you get no useful result.

Next, let me show a "stack power" function that can properly solve the paradox Alkexr posed in post 3 of this thread.

Stack A is 10x6. Stack B is 2x6 plus 27 padding. Stack C is 1x6 plus 55 padding. A beats B, B beats C, and C beats A.

Now, it may be obvious, but this is a clear example of the competition between combat power and hit points. Thus I propose a "stack power" function P = U + C, where U = Unit differential, C = combat strength differential. But wait, you say! You promised that you would consider Skewness as well. I won't do that yet, but I will introduce a new term R to express the relative Reduction in the combat strengths as the rounds progress. Let P = U + C - R. It is important, as you know, because if you bring a whole bunch of padding to your gunfight, the other guy can shoot and shoot, and have no effect on your combat strength. On the other hand, the unpadded stack suffers near-linear reduction in its combat power over time. For a linear decrease, the effective combat strength is just 1/2 of the maximum. But wait, you say! The combat strength acts over a number of combat rounds. Of course; my test function is actually P = U + N*(C - R)/6. N is the number of combat rounds; division by 6 is necessary because it takes 6 combat points to get a hit.

The calculations: Stack A has zero padding, and thus suffers a linear strength decrease. Stacks B and C suffer no decrease over time. In the BC combat, the relative strength reduction is zero. In the CA combat, stack C shoots at padding only, so the Reduction factor is applied to every combat round. The effective value of C is 5.5x6 (R = 27). In the AB combat, stack C shoots at padding for 4 rounds. The effective value of C is 7x6 (R = -18).

In the AB combat, there are 5 rounds. In the BC combat, it takes 27 rounds to hack through the padding, and there are 28 rounds. In the CA combat, there are 10 rounds. In each case, the winner has exactly one unit left.

P(A->B) = -19 + 5*(48 - 18)/6 = + 6

P(B->C) = -27 + 28*(6 - 0)/6 = + 1

P(C->A) = 46 + 10*(-54 + 27)/6 = + 1

You will note that all the U's sum to zero, all the C's sum to zero, and all the S's sum to zero, but the weighting of the factors differs in each case.

But mostly, you will note that all the relative stack power functions evaluate positive, which means that A > B > B > C.

Still, although I have showed that it is possible to construct a function that models several situations correctly, this is not the real stack power function that I will be proposing. More later.

]]>Ok thanks!

]]>annyways, I'm waiting for redrum's final word since he programs the battle calculator logic and would know for sure what is and what isn't possible with this game engine

The battlcalculator just simulates the battle and tells you the % won and lost. Which is an accurate (though sometimes time consuming way) to get a decent prediction. What I (and I think other experienced players) often do is just open the battlecalc to check how many units each side would have, and after seeing the unit numbers the answer is sometimes obvious. Its not 100% accurate with more complex units, but that's okay.

I don't think you can make an equation that produces a single number for the strength of an army (or a unit), because its dependent on your opponent's forces. Its been explained pretty well why. You can't make an equation for individual units either (I tried a while ago), its just not the correct approach.

]]>Interesting you are correct ]]>

Oh by the way, I learned from a great tv show years ago back when tv shows were actually educational that the Nash Embedding Theory proved the paradox that "linear equations are modular" ... which won Nash a Nobel and shows OBVIOUS paradox

annyways, I'm waiting for redrum's final word since he programs the battle calculator logic and would know for sure what is and what isn't possible with this game engine

]]>You were looking for a function that gives back the strength of a unit. What I have shown is that you were asking the wrong question. You cannot evaluate the value of a unit, not even that of an army.

Linear formulas will also break down. If the value of a unit is *scalar1 * hp + scalar2 * power*, then the unit will, under its lifetime, kill *expected_combat_rounds_survived * power / dicesides* hitpoints, so you can write the equation *expected_combat_rounds_survived * power / dicesides * scalar1 = scalar2 * power*. But *expected_combat_rounds_survived* depends both on the average power and the deviation of power of ALL units on the board, and so does the ratio of *scalar1* and *scalar2*.

In short, if all units have 1 power, then 1 power is worth X utilons. If all units have 2 power, then 1 power is worth X/2 utilons.

As for the differential equations for which I admittedly do not have a great affinity, my attempts at giving any sort of useful general solution failed miserably, so did those of others I asked about it. The simplified case where every unit has the same power is clearly solvable, but uninteresting, so I decided not to bother.

Anyway... I really shouldn't be spending time writing comments here. Or if I focused my attention on TripleA, I could at least get back to working on my map. So... good luck with those nasty differential equations.

]]>When I ran a few simulations, I found that all it takes to bring a combat result from a 50% chance to win to approximately 100% is ONE extra unit, or even ONE extra combat point. The first seems reasonable, the second less so, until you consider that that single extra combat point can add up to multiple extra hits over multiple combat rounds. Accordingly, I propose the following unit-strength function:

P = .5 + .5 U + .5 C ,

where P = probability of winning, U = Unit differential, C = combat strength differential.

Now, I know that this function is wrong, but it is a good start. I expect it to provide a decent result, as long as the the unit count is 10 or more. You can see that it works for the limiting cases. Results for P > 1 are taken to be P = 1.

There are two other factors that should be considered: the Average combat strength, although this may already be accounted for by unit count and combat strength, and Skewness, which is a measure of the deviation of the unit strengths from the average. I would expect one point of Skewness to have almost the same effect as an extra combat point.

Ultimately, I will try to solve the differential equations governing the combat. (I'm sure someone has already done this.) Basically, there are two linked differential equations that describe the situation; they state that the reduction in strength of an army is proportional to the strength of the opposing army. This problem could also be solved using the finite-difference approach, and even a program as simple as Excel can handle that.

Spoiler alert: My second-stage test function, which incorporates Skewness and a fudge factor, can predict the result A > B > C > A. I will post that when I have more time.

]]>What you refer to there, surely that is a paradox! And surely it indicates that someone has done a lot of calculations with the combat system, because I cannot believe that that was found on the spur of the moment.

Random thought: If red tank (3/2) beats blue tank, and blue tank beats green tank, does that mean that red tank beats green tank?

Less random thought: The AAA combat system is deterministic, even if it involves probabilities. Thus a non-deterministic outcome is impossible, even if there is no error in the example you showed. And I could not find an error. But there is a solution to this paradox, and it is that the strength of an army is not a fixed value, but is instead a *relative* value, thus: red army > blue army > green army > red army. Indeed, there is no paradox.