The magical hammer of theoryhammer

Got something to talk about? Be it video games, other tabletop or card games, even random stuff - this is the place to post!

Moderator: The Dread Knights

User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

The magical hammer of theoryhammer

Post by Daeron »

Greetings fellow Theoryhammerers,


As I was developing different calculators for my theoryhammering, I felt some numbers were recurring on a regular basis.. and some techniques felt "the same" with only some minor differences here and there. With maths and programming, you try to discover the general pattern that's being reused all the time so you can formulate it once for all applications.
Looking for such a solution comes paired with the usual frustration of solving any logical puzzle: it seems hard at first, until you find the solution and then you smack yourself on the head for its simplicty. Perhaps the solution was known to you, or perhaps you find yourself annoyed at having to reinvent something "very similar" with every application, like me.

I know some of us like to employ numbers in their research, so I thought I'd share my solution that might help you compute... a pretty big deal of things.

The mathematical explanation

We start with a single example. Suppose we have a character attacking a model, and we have the following scores:
- 0 wounds done: 40% chance
- 1 wound done: 40% chance
- 2 wounds done: 20% chance

We could denote Wx as X wounds done. We can then write our character's score as:
Score_character = (40% W0 + 40% W1 + 20% W2)

Now we want to combine this with a supporting attack from his horse, which has the following scores:
- 0 wounds done: 80% chance
- 1 wound done: 20% chance
Score_horse = (80% W0 + 20% W1)

To combine them both... We simply need to multiply this:
(40% W0 + 40% W1 + 20% W2) * (80% W0 + 20% W1)
= 40% W0 * 80% W0 + 40% W0 * 20% W1 + 40% W1 * 80% W0 + 40% W1 * 20% W1 + 20% W2 * 80% W0 + 20% W2 * 20% W1
But we're not really interested in something this complex. We want to see the combined result, so we consider that "W2 * W0 = W(2+0) = W2" (2 wounds done by the character, 0 by the horse) combines to W2 (2 wounds total).

We get:
32% W0 + 8% W1 + 32% W1 + 8% W2 + 16% W2 + 4% W3
which becomes:
32% W0 + 40% W1 + 24% W2 + 4% W3

And voila. We have 24% chance to get 0 wounds, 40% for 1, 24% for 2 and 4% for 3.

A simple php function (and one to help us)

In programming, we could simply write something like "40% W0 + 40% W1 + 20% W2" as an array, with the wounds" as indexes and the percentages as their respective values. For example, in PHP we could write:

Code: Select all

//php arrays start at index 0, so we can just write:
$score_character = array(0.4, 0.4, 0.2);
$score_horse = array(0.8, 0.2);
print_r($score_character); //prints the scores of the character
print_r($score_horse); //prints the scores of the horse



To multiply these scores, we can write a simple function:

Code: Select all

/**
 * multiply_arrays
 *
 */
function multiply_arrays($first, $second){
   //this iniatilizes the array.. nothing more.
   $result = array_fill(min(array_keys($first)) + min(array_keys($second)), max(array_keys($first)) + max(array_keys($second)) - min(array_keys($first)) - min(array_keys($second)) + 1, 0);
   
   // the "multiplication"
   forEach($first as $i => $first_chance) {
      forEach($second as $j => $second_chance) {
         // mind, it -adds- the chance
         $result[($i+$j)] += $first_chance * $second_chance;
      }
   }
   return $result;
}

$score_combined = multiply_arrays($score_character,$score_horse);
print_r($score_combined);
/* prints:
Array
(
    [0] => 0.32
    [1] => 0.4
    [2] => 0.24
    [3] => 0.04
)
*/


Let's take it one step further. We could have a horde of corsairs fighting empire troopers (WS3, T3, 5+AS). Each attack has a 34.5679% chance of scoring a wound. We have 41 attacks, which we could write as:
(65.4321% W0 + 34.5679 % W1)^41

We don't want to code 41 multiplies, so we use a helper function:

Code: Select all

/**
 * array_to_power
 *
 */
function array_to_power($base, $power){
   $result = array(1);
   for($i=0; $i<$power;$i++) {
      $result = multiply_arrays($result, $base);
   }
   return $result;
}

$score_corsair = array(0.65432098765432098765432098765432, 0.34567901234567901234567901234568);
$score_corsair_unit = array_to_power($score_corsair, 41);
print_r($score_corsair_unit); // score breakdown per number of wounds done by the corsair unit


Multiple Wounds and Killing Blow

In previous methods that I used (mostly binomial coefficients) it was hard to combine killing blow and multiple wounds at the same time. No longer.

Now imagine we have a Hero with a lance and the Twillight Cloak charging into warhounds. Those creatures have 2 wounds, so both the multiple wounda and killing blow have a special value. We get:
- 0 wounds: 13.58%
- 1 wound: 23.05% because (8/9 to hit) * (4/6 to wound without killing blow) * (7/6 from murderous prowess) * (1/3 from d3 multiple wounds)
- 2 wounds: 46.091% (from multiple wounds) + 17.284% from killing blow = 63.37%

We have three attacks, so we use our function as follows:

Code: Select all

$score_twillight = array(0.1358,  0.2305 , 0.6337);
$score_character_charge = array_to_power($score_twillight, 3);
print_r($score_character_charge);
/* Prints out:
Array
(
    [0] => 0.0025045113192245
    [1] => 0.012750239443325
    [2] => 0.056699928433573
    [3] => 0.13124121579435
    [4] => 0.26459966602334
    [5] => 0.27767188121019
    [6] => 0.254532557776
)
*/



Dice scores

We're not limited to kill scores. For example, a single dice outcome could be written as:
Score_dice = 0% D0 + 1/6 D1 + 1/6 D2 + 1/6 D3 + 1/6 D4 + 1/6 D5 + 1/6 D6

Where Dx denotes the outcome of the dice roll.

Throwing 3 dice then becomes:

Code: Select all

// we begin with 0, because we can't roll "0" on a d6
$score_1d6 = array(0, 1/6, 1/6, 1/6, 1/6, 1/6, 1/6);
$score_3d6 = array_to_power($score_1d6, 3);
print_r($score_3d6);

/* Prints out:
Array
(
    [0] => 0
    [1] => 0
    [2] => 0
    [3] => 0.0046296296296296
    [4] => 0.013888888888889
    [5] => 0.027777777777778
    [6] => 0.046296296296296
    [7] => 0.069444444444444
    [8] => 0.097222222222222
    [9] => 0.11574074074074
    [10] => 0.125
    [11] => 0.125
    [12] => 0.11574074074074
    [13] => 0.097222222222222
    [14] => 0.069444444444444
    [15] => 0.046296296296296
    [16] => 0.027777777777778
    [17] => 0.013888888888889
    [18] => 0.0046296296296296
)
*/


And yes, we can calculate the chance for irresistable force too, by calculating the number of 6's we roll. We have 5/6 chance to roll something other than a 6 on a single dice, and 1/6 chance to roll a 6:

Code: Select all

// we begin with 0, because we can't roll "0" on a d6
$sixes_on_1d6 = array(5/6, 1/6);
$sixes_on_3d6 = array_to_power($sixes_on_1d6, 3);
print_r($sixes_on_3d6);

/* Prints out
Array
(
    [0] => 0.5787037037037
    [1] => 0.34722222222222
    [2] => 0.069444444444444
    [3] => 0.0046296296296296
)
*/


We can simply add the chance to have 2 or 3 sixes to know our chance on IF or subtract the chances to get 0 or 1 sixes from 100%.

Code: Select all

// Prints 0.074074074074074
print($sixes_on_3d6[2]+$sixes_on_3d6[3]);
// Prints 0.074074074074074
print(1 - $sixes_on_3d6[0] - $sixes_on_3d6[1]);



Final remarks

Some dice strategies, like discarding or adding dice after a throw, are more difficult to model with this formula. But when it comes to our commonly used dice rolls, cast values, kill scores.. this one formula manages to tackle a considerable amount of situations and probably more than I have seen before. In particular, when it comes to combinations of killing blow with multi wound opponents, multiple wound attacks or combinations of both I haven't found many numbers on this at all. This one formula provides the answer I've been looking for, for quite some time.

External sources

The code used in this topic can be checked here:
http://sandbox.onlinephpfunctions.com/c ... ec49290c03
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

For those interested, there's also a Javascript example of the code here:
http://furnace.orderoftheathanor.eu/?p=814
This should make it possible for anyone to test it in their browser (preferably Chrome, FF or Safari) if they copy paste the code in any HTML file.

I wanted to note another extension to this method. Obviously, it would be "a dream" to be able to deduce statistics for protracted combat: kill scores for every round, outcomes and chance to break or anihilate your opponent.
Following Thraundil's topic (http://druchii.net/viewtopic.php?f=3&t=74071 ) I was thinking about continuing this line of thought and how to make it feasable to program such a combat calculator. I stumbled upon a very long list of rules that such a calculator would have to understand, so it could make the correct calculations for every turn.

The complexity was daunting enough to encourage a different idea: can we simplify the problem? Do we really need to understand rules such as monstrous cavalry, cavalry, attacks per model, killing blow, multiple wounds and more before we can even start such calculations?
Given the above theory, we can atually dodge a lot of this complexity by changing the interpretation a little:
- We need a chart for the attacks of a single model in the front: (F0 + F1 + F2 + ...) where Fx denotes the chance for a front model to score x wounds
- We need a chart for the attacks of a single model giving supporting attacks: (S0 + S1 + S2 + ...) where Sx denotes the chance for a supporting model to score x wounds
This chart can denote anything, including stomps, multiple attacks, multiple wounds, killing blow and so on as we've seen above.

Given these two charts, we can write:
(F0 + F1 + F2 + ...)^n * (S0 + S1 + S2 + ...)^ m
Where n denotes the remaining models in the front, and m denotes the remaining models lending supporting attacks.
What's nifty about this notation is that is cancels the need to remember a lot of rules, for as long as we know how many models (and thus wounds) remain in the battle.

Result coming up soon, in Theraundil's topic :)
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Thraundil
Malekith's Best Friend
Posts: 1177
Joined: Wed Jan 09, 2013 1:46 pm
Location: The Depths of Despair

Re: The magical hammer of theoryhammer

Post by Thraundil »

Damn Daeron, that is quite the idea. Brilliant to reduce the problem to "chance of x wounds". All you then need is to input stats, a few algorithms to figure out the non-linear scaling of "to hit" and "to wound", and you can give anything from chance of breaking someone to chance of winning a 10 turns long grind fest! Looking forward to seeing the results for sure! :D
Name: Ladry (female)
Class: Mage (Pyromancer)
Equipment: Staff, longsword, dagger, 20 gold, insignia ring.
Skills: Power of Aqshy (2), defensive figthing
WS4, S2, T3, D4, I6.
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

some preliminary results here:
http://warhammer.orderoftheathanor.eu/C ... s_cok.html

It still needs some refinements:
- COKs still keep their charge bonus in subsequent rounds
- Champions are not included yet
- Cold Ones strike at the same time as the riders.

But the calculator does reveal that it's possible to calculate the odds for every possible outcome in every round, and subsequent rounds. With a bit more work, the output should become readable :P
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Amboadine
Miscast into the Warp
Miscast into the Warp
Posts: 3510
Joined: Mon Nov 19, 2007 11:07 am
Location: Investigating Mantica

Re: The magical hammer of theoryhammer

Post by Amboadine »

Very impressive work, one of the reasons, I decided to leave the lurk mode, was to express my appreciation.
I look forward to further updates.
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

Thank you Amboadine.

Unfortunately, I've hit a snag. The method works beautifully well for some things:
- To calculate the damage potential of a unit
- To note the wounds remaining on a unit, and deduced information such as banner, champion, models, ranks
But where these methods gracefully merge a lot of calculations, this very merger breaks the ability to calculate combat resolution, which needs the exact number of wounds done and returned, not just the potential spanning over different situations.

As it turns out, this may prove cumbersome to compute. A simple combat by two units would require a computation in 4 dimensions. As the combat becomes more complex, with different initiatives and/or profiles, the computation expands by at least one more dimension per profile.

So it's great to work out, say, the likelyhood to annihilate the opponent in X rounds, but not the actual combat resolutions one had to face along the way.

Hmm hmm.. A different method is needed. One idea is to simply make a list of vectors, each with the required dimensions to express "one possible outcome" of an entire battle, and a probability for this outcome to occur. That should work.
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Thraundil
Malekith's Best Friend
Posts: 1177
Joined: Wed Jan 09, 2013 1:46 pm
Location: The Depths of Despair

Re: The magical hammer of theoryhammer

Post by Thraundil »

Cant it be done in a more simple manner?

Its not really interesting, imo, to have a code capable of computing the odds of winning a massive clusterfuck involving multiple units. Whats really interesting is the "odds-wise" single unit vs single unit in order to evaluate if you should e.g. stand and shoot or flee, or if you should charge him or let him charge you, attempt hold on steadfast and then flank.

What I think you want to make merges well with your code so far. You pitch unit X in battle against unit Y, giving every parameter of the two units. You then compute the likelihood of unit X inflicting Z casualties, and unit Y inflicting V casualties back. So to give combat resolution, subtract Z from V and then you have "odds of winning combat by T %", no?

A straight up "if I charge here, Ill win combat by 5" calculation is, like you said, impossible to make. For many reasons - the obvious one being every dice rolled is a chance. The much more interesting thing would be

If I charge here and rolls are average:
- I will win combat
- Theres 47% chance of breaking my opponent

Or, even better:

If I charge this opponent:
- Theres a 75% chance of winning combat by at least 1
- Theres a 27% chance of breaking my opponent
- Theres a 25% chance I'll lose combat, but
- Theres only 10% chance overall that I'll break and flee

Given the computations you carry out, shouldnt it be easy to extend the numbers by one additional degree of freedom? Because the (obviously made up) examples above would be exactly the information you'll want in any given situation! There is, after all, never a guaratee to break someone, only a fairly good chance. Just HOW good of a chance you want, well, you can always predict it. In your own room in front of your PC, before your games begin. In the actual game, you must as always judge for yourself, but a few quick number crunches like this can really sway in favour of, or against, taking the charge :)
Name: Ladry (female)
Class: Mage (Pyromancer)
Equipment: Staff, longsword, dagger, 20 gold, insignia ring.
Skills: Power of Aqshy (2), defensive figthing
WS4, S2, T3, D4, I6.
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

Unfortunately, it's not as simple. Even for 2 units, it doesn't work. And should one of these units have a combined profile, like our cold one knights, then a two dimensional approach would be insufficient. In fact, there's little difference between supporting multiple units, or simply supporting the split profile from cavalry at their own initiative order.

With the formula's above, it's very easy to calculate the "damage" part. So unit1 would have a list of outcomes, each outcome with some probability. You can even subtract this, easily, from the unit it damages, and use this modified outcome to compute the returning damage.... taking into account the casualties suffered. But the outcomes aren't usable to compute combat resolution.

For example, our Executioners and Demigryphs. The executioners do 17 attacks. The outcome is:
Image

We can work this into the demigryphs. The models remaining in the demigryph unit are:
chance to have 1+ models left 99.99%
chance to have 2+ models left 99.86%
chance to have 3+ models left 93.59%
chance to have 4+ models left 51.05%
chance to have 5 models left 5.18%

This can be taken into account when computing the return damage from the demigryphs to the Executioners:
Image

It gives us the marvellous results of expressing, for every possible kill, the odds of that happening. Now it would seem that, we could combine the odds of scoring 5 wounds with the executioners, with the odds of getting 8 kills by the gryphons ... But we can't.
The chance for the gryphons to score, say... 7 kills... combines the chance for scoring 7 kills in case the executioners killed 0 demis, 1 demi, 2 demis or more. This result can not be reused to calculate combat resolution, because it already incorporates different outcomes.

We can not dodge the requirement that we need to combine:
- one specific number of wounds from which the Executioners start (because scoring 1 kill and taking 1 kill may give different results if that 1 loss means losing a rank or nor).
- one specific number of wounds from the Demigryphs, prior combat for the same reasons
- one specific score from the executioners, combined with 1 specific score of the demigryphs.

While I mention above that we'll need to compute in several "dimensions", or depths of a computational tree as it is were, this needn't be with endless loops within loops, for as long as we can find a clean way to represent out intermediate results in a manner that's reusable through the different "stages" of a single round of combat.

And this can be done as follows, I think:
"State of a Unit" can be denoted as:
- W, the wounds it started with
- D, the wounds it inflicted
- T, the wounds it has taken thus far.
- p, the probability of this occurring.

We would need one such "state" for every possible outcome, but that's just a flat list of states. Every stage of a round of combat can take such a list as input, calculate its impact, and work out the resulting list of states with it. This can be done for an arbitrary number of stages... and thus any combination of profiles, units, you name it.

At the end of a round of combat, states can be used to calculate the odds for every possible combat resolution... And these results can be merged back into the elegant style I used above. So we still get our cool graphics, and easy way to compute the remaining models or damage potential along the way.
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

One thing never quite sat well with me, with the theory I presented here. I couldn't imagine I invented something new, so I went out to look for the right name for the theories I was using. I started by adopting the name "multinomial" as the probability distribution over several factors would be the "multinomial distribution". I stumbled on this, when looking for a more general case of the binomial distribution.

But somehow that never sounded entirely right. I took my time, but I feel the best way to describe it is simply polynomials, of which the sum of the coefficients must be 1.
While that sounds very silly, it's actually important when looking up math theories that are similar to the ones presented here.

In fact, we could assume that we simply modeled an "attack" as a polynomial as such:
outcome = p_fail + p_success X

And in case we have a chance at doing multiple wounds, we could make this:
outcome = p0 + p1 X^1 + p2 X^2 + ... + pn X^n
And to do this attack multiple times we simply multiply this polynomial with itself as often as we execute the attack:

outcome_of_10_attacks
= outcome * outcome * .... * outcome (10 times)
= outcomes^10

One piece is missing in the OP. How do we compute a random number of attacks? Say, D3 attacks? And the chance to wound is 1/3? And each attack does d3 wounds?
I knew how to calculate this, before I knew how to name this operation. Silly me. The reason why it's quite simple is because we're simply doing substitution.

D3 wounds can be modeled as:
D3_wounds = 1/3 W^1 + 1/3 W^2 + 1/3 W^3
chance_to_wound = 2/3 W^0 + 1/3 W^1
Substitute W in chance_to_wound by D3_wounds and we get wounds_per_attack:
wounds_per_attack = 2/3 + 1/3 * (1/3 W^1 + 1/3 W^2 + 1/3 W^3)
wounds_per_attack = 2/3 + 1/9 W^1 + 1/9 W^2 + 1/9 W^3

We take D3 attacks to be:
D3_attacks = 1/3 A^1 + 1/3 A^2 + 1/3 A^3
To get the total score, we simply substitute A by "wounds_per_attack":
total_sore = 1/3 (2/3 + 1/9 W^1 + 1/9 W^2 + 1/9 W^3) + 1/3 (2/3 + 1/9 W^1 + 1/9 W^2 + 1/9 W^3)^2 + 1/3 (2/3 + 1/9 W^1 + 1/9 W^2 + 1/9 W^3)^3
which, after some work, comes down to:
total_score = 46.91% W^0 + 13.58% W^1 + 14.81% W^2 + 16.10% W^3 + 03.84% W^4 + 02.74% W^5 + 01.55% W^6 + 0.27% W^7 + 0.14% W^8 + 0.05% W^9

Or plotted out, for a more attractive representation:
Image

So, we're simply using computations with polynomials. This also merges nicely with the previous theory of computing chances, using binomial distribution because a polynomial with only 2 terms is called a binomial, and the binomial distribution simply computes the binomial coefficients when multiplying a binomial by itself.
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
jeffman
Corsair
Posts: 89
Joined: Thu Sep 26, 2013 6:24 pm
Location: netherlands

Re: The magical hammer of theoryhammer

Post by jeffman »

This is pretty much chinese to my
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

Well, in plain English it means that if Aliens land in London, the pink cows will shoot you with paintball guns because of all the ice cream growing in the deserts.

While the fancy names may indeed make this a challenge, it isn't so hard to understand as it might seem. We probably all saw this in math's classes:
Image

Take the (x+y)^3 example.
Imagine our Master with a pegasus and lance were to charge a Sorceress with a 5++, then he:
- hits on 3+, with reroll, or 8/9 chance to hit
- wounds on 2+ with reroll of 1, or 8/9 chance to wound
- passes all armour saves
- can pass the ward save with 4/6 chance.
Total chance to wound: 52.67%

Now we take the (x+y)^3 formula. Replace x by "47.33% FAIL" and y by "52.67% WOUND". Then the end result is:
10.6% FAIL^3 + 35.39% FAIL^2 WOUND^1 + 39.39% FAIL^1 WOUND^2 + 14.62% WOUND^3

Plotted out, per number of wounds:
Image

If we want to give him the cloak of Twilight, assuming it's a supreme sorceress (3 wounds), then we have to take into account that every unsaved wound can yield 1, 2 or 3 wounds. Expressed as:
1/3 WOUND^1 + 1/3 WOUND^2 + 1/3 WOUND^3

If we go back to this one:
10.6% FAIL^3 + 35.39% FAIL^2 WOUND^1 + 39.39% FAIL^1 WOUND^2 + 14.62% WOUND^3
And replace "WOUND" by "1/3 WOUND^1 + 1/3 WOUND^2 + 1/3 WOUND^3"
(we can actually drop the fail for simplicity)
Then we get this cumbersome result:
10.60% WOUND^0 +11.80% WOUND^1 +16.17% WOUND^2 +21.09% WOUND^3 +14.75% WOUND^4 +12.00% WOUND^5 +8.17% WOUND^6 +3.25% WOUND^7 +1.62% WOUND^8 +0.54% WOUND^9

Or plotted for convenience:
Image

Which shows the chance to do X wounds.
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Amboadine
Miscast into the Warp
Miscast into the Warp
Posts: 3510
Joined: Mon Nov 19, 2007 11:07 am
Location: Investigating Mantica

Re: The magical hammer of theoryhammer

Post by Amboadine »

jeffman wrote:This is pretty much chinese to me


Yes, but so beautiful and logically at the same time.
Actually like many chinese people I know :)
jeffman
Corsair
Posts: 89
Joined: Thu Sep 26, 2013 6:24 pm
Location: netherlands

Re: The magical hammer of theoryhammer

Post by jeffman »

Ok it doesnt completely bedazzles me, it actually looks allot like the statistic classes i took. Come to think of it, it IS statistics!
jeffman
Corsair
Posts: 89
Joined: Thu Sep 26, 2013 6:24 pm
Location: netherlands

Re: The magical hammer of theoryhammer

Post by jeffman »

Amboadine wrote:
jeffman wrote:This is pretty much chinese to me


Yes, but so beautiful and logically at the same time.
Actually like many chinese people I know :)


Haha i didn't mean it looks like chinease people haha, that would be kind of racisme. I meant the lannguage
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

jeffman wrote:Ok it doesnt completely bedazzles me, it actually looks allot like the statistic classes i took. Come to think of it, it IS statistics!


If you really want a trip back through memory lane of your statistic classes, then look up the binomial distribution:
http://en.wikipedia.org/wiki/Binomial_distribution
They teach this one in every class, I think. This is usable for all "simple" attacks with just 1 wound per attack. But it can't be used to compute the odds when taking into account:
- Random number of attacks, like a chariot's impact hits
- Random number of wounds, like our Cloak of Twillight does, or how killing blow works on multiwound models.
Because of this, I set out to expand the theory and see how I could calculate that. The above theory isn't novel by far, but I do find that using it is extremely effective because it can calculate almost anything with just 2 tricks: multiplying polynomials and substitution. Depending on how optimal we want the code to be, we could make a program that computes this in only 1 or 2 dozen lines of code.

That's how those plots are done btw :) I wrote that program.
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Amboadine
Miscast into the Warp
Miscast into the Warp
Posts: 3510
Joined: Mon Nov 19, 2007 11:07 am
Location: Investigating Mantica

Re: The magical hammer of theoryhammer

Post by Amboadine »

jeffman wrote:Haha i didn't mean it looks like chinease people haha, that would be kind of racisme. I meant the lannguage


I know what you meant, don't worry, just a little tongue in cheek :)

All my wife's family (and my daughter) are Thai/Chinese so I feel I can get a way with it.
User avatar
T.D.
Killed by Khorne
Killed by Khorne
Posts: 2818
Joined: Fri Apr 12, 2013 3:51 pm
Location: Hinterlands of Khuresh; The Lost City of the Angels

Re: The magical hammer of theoryhammer

Post by T.D. »

Amboadine wrote:All my wife's family (and my daughter) are Thai/Chinese so I feel I can get a way with it.


Congratulations on an international marriage!

I hope to bag some currently unsuspecting foreign woman ...one day :P
OldHammer Advanced Ruleset
- Adding Tactical Depth to Your Favourite Tabletop Wargame
User avatar
Amboadine
Miscast into the Warp
Miscast into the Warp
Posts: 3510
Joined: Mon Nov 19, 2007 11:07 am
Location: Investigating Mantica

Re: The magical hammer of theoryhammer

Post by Amboadine »

Quickly moving back on topic, in case T.D reveals overly sinister Druchiiesque plans for the unsuspecting populous...

Daeron, what is your next planned line of interrogation?
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

As far as this theory is concerned, it's almost done. It has reached its potential to calculate almost any single round of combat statistics. But it can be taken one step further.
Instead of writing out your unit like "30 models", you could say:
UNIT = 100% WOUNDS^30.
With 30 wounds being the amount of wounds the unit has. Now if these are empire state troops getting hit by a bunch of witch elves, then the incoming damage can be expressed as a polynomial as mentioned above:
Image
Let's call it "DAMAGE".

Then it should be possible somehow to work out UNIT / DAMAGE to look at how probable it is that you have X wounds left. Unfortunately, this isn't a clean polynomial operation (though it can be well-defined) so we're breaking a few math principles. But the result is, again, a polynomial that can be plotted.

Why is this relevant? Because if we know the chance to have X wounds left on the unit, then we know the chance that X models will fight back. And this can be done using the substitution explained above. Consider it like random attacks, except that the chance to have 2 attacks is defined by the chance to have 2 state troopers left.

This method works. Well, even. But the benefit of calculating has its limitations:
- It can be used to compute who would win the grind fest, or the odds to wipe the enemy unit in X rounds of combat. But this can not include loss of frenzy, combat resolution, break tests, etc.
- It seems to become increasingly less reliable as the number of actors increases.
- It can not be used to calculate your chance to actually win combat... only work out the grind fest.

But aside from that there's a lot on my todo list ;) For starters I'm cleaning up my plotting script to use the proper mathematical terms. And I have a few things in the pipeline:
- An interface to actually help making such graphs
- A textual interface to such a graph plotter.. So that

Code: Select all

[math]20 attacks, 4+ to hit, reroll to hit, 4+ to wound, 3+ armour save, poison, murderous prowess[/math]

gets translated to:
Image
- Calculating the odds to get hit by a stone thrower and how to use them most effectively.
- Calculating the impact of being hit by a cannon or stone thrower
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
T.D.
Killed by Khorne
Killed by Khorne
Posts: 2818
Joined: Fri Apr 12, 2013 3:51 pm
Location: Hinterlands of Khuresh; The Lost City of the Angels

Re: The magical hammer of theoryhammer

Post by T.D. »

Thanks very much for all the effort you've put into this Daeron. Much food for thought :)
Last edited by T.D. on Tue Mar 10, 2015 8:12 pm, edited 1 time in total.
OldHammer Advanced Ruleset
- Adding Tactical Depth to Your Favourite Tabletop Wargame
jeffman
Corsair
Posts: 89
Joined: Thu Sep 26, 2013 6:24 pm
Location: netherlands

Re: The magical hammer of theoryhammer

Post by jeffman »

I'm seeing Dearon on his next tournament with a smartphone with his program on it, looking his opponent in the eye just before the match. Dearon is quickly entering his opponents list in his program. The other player is still debating on whether if he wants to go first or not until all of a sudden Dearon says: "good game, i won. 14-6, do you or me want to report the results" without a single dice roll.

I do like the math. If you keep collecting data you could calculate the best average optimal unit sizes. If you could write the program that it quickly calculates for example the damage outcome in wounds of a unit witch elves from 10-40 models against all other units and unit sizes possible, you could calculate the best average unit size of witch elves against all units, and what units to avoid with that unit size.

In later expansion of this program you could ad other outcomes than damage like combat resolution for example.

i don't know if writing such an extensive program is feasible. however if you can run witch elves against all other unit types and sizes, it means u can run all other unit types and sizes against all others aswell
User avatar
Calisson
Corsair
Corsair
Posts: 8820
Joined: Fri Mar 14, 2008 10:00 pm
Location: Hag Graef

Re: The magical hammer of theoryhammer

Post by Calisson »

Nice finding, Daeron. Polynomials indeed, not statistics.
I do not expect it to lead anywhere as jeffman illustrates, but that could be a good help for theoryhammer, such as proving that the AP banner is beter used with BG or WE in such meta, or similar considerations.
Winds never stop blowing, Oceans are borderless. Get a ship and a crew, so the World will be ours! Today the World, tomorrow Nagg! {--|oBrotherhood of the Coast!o|--}
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

A fully computed model simply isn't possible... Not to mention unreliable. This unreliability is exactly what I'm showing, and why I'm going through the trouble of computing the chance of different outcomes. Instead of going "well, on average you'd do 3 wounds", I can show you'd have less than 50% chance of scoring 3 wounds, even though that is the most likely outcome of all.

As for computing the matchups of every unit, well... I'd like to bring back this one to memory
http://warhammer.orderoftheathanor.eu/C ... DE_V6.html
But it's still a work in progress. The theory in this topic will help me continue that tool :)
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
jeffman
Corsair
Posts: 89
Joined: Thu Sep 26, 2013 6:24 pm
Location: netherlands

Re: The magical hammer of theoryhammer

Post by jeffman »

but you can however calculate the lowest unit size to be successful against a set percentage of enemies right?

You'd have to define success (perhaps winning combat with only 20% wound loss). Then you'd "run" every possible unit size of witch elves against every other unit and unit size. you'd put in a critical value (60% chance of success (as defined earlier).

An outcome could be: a unit of min 34 witch elves (horde formation) has a 60% success rate against 40% of all other units and unit sizes.

Variables that could be changed would be the "success definition" perhaps winning with 40% wound loss is considered success to you, or winning with no losses at all); also "success rate" as perhaps you want 90% of achieving the success. and finally you could perhaps don't want to include definite losses in your equation (like a unit of demigriphs consisting of more than 5).

you can calculate the success rates against every individual unit and unit size and thus optimize minimal unit sizes for yourself.

If you intend to use witches against enemy infantry only, you can calculate the success (success= winning with less than 20% wound loss) against infantry units only, excluding unusable unit sizes. and u can perhaps find out that a unit of 34 witches has a 70% success rate against all other infantry.

I think theoretically creating such a program should be possible and it is helpful in determining optimal unit sizes.
I do not however know how time and energy consuming creating such a program is.
User avatar
Daeron
Malekith's Best Friend
Posts: 3975
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: The magical hammer of theoryhammer

Post by Daeron »

That is theoretically possible but it's a lot of work and I doubt the results are worth it... or even usable. While it is easier to compute the chance of success, given a situation, it's much harder to compute an ideal situation that achieves success. The reason is that there is a very large space of possible situations which are difficult to formalize.

By narrowing it down to optimal unit size, you can bet money on big units winning. That doesn't prove they are better, as MSU and avoidance armies show. Additionally, it would require an insane amount of input, to weigh unit sizes, units and armies more likely to appear in the meta... A meta that you influence by your own choices.
Then add in magic or synergy with different units.

There's not even a guarantee that you can find an optimal unit. Take rock, paper scissors. Which one is the best option?
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
Post Reply