do you wanna be in my gang?

An attack only causes damage if it first hits. So damage output of a piece is a four dimensional landscape, where two small dimensions (POW and ARM) are nested within two large dimensions (MAT and DEF). So the complete landscape looks like a stained glass window. Each attack is a point in this landscape. We can work out the expected damage output at each point by multiplying the expected damage by the probability of the attack hitting . We already know that. If we want to know the amount of damage we expect to cause to a piece, we can add up the expected value of all attackers.

So for example, a Steelhead halberdier has melee ability 5 and power and strength 11. We can quickly calculate damage inflicted for all DEF and ARM values.

> e_damage <- array(data = 0, dim = c(length(DEF), length(ARM), 1),
+     dimnames = list(DEF, ARM, c("ind")))
>
> mat <- 5
> pas <- 11
>
> # one Steelhead
>
> ph <- matrix(probTable2[mat, ],
+     nrow = length(ARM), ncol = length(DEF),
+     byrow = TRUE, dimnames = list(ARM, DEF))
>
> avd <- matrix(mueTabled2[pas, ],
+     nrow = length(ARM), ncol = length(DEF),
+     byrow = FALSE, dimnames = list(ARM, DEF))
>
> e_damage[, , 1] <- t(ph * avd) # elementwise multiplication
>
> round(e_damage[7:14, 5:18, ], 1)
      5    6    7   8   9  10  11  12  13  14  15  16  17  18
7  12.6 11.7 10.7 9.7 8.8 7.8 6.8 5.8 4.9 3.9 3.0 2.2 1.5 0.9
8  12.6 11.7 10.7 9.7 8.8 7.8 6.8 5.8 4.9 3.9 3.0 2.2 1.5 0.9
9  11.9 11.0 10.1 9.2 8.2 7.3 6.4 5.5 4.6 3.7 2.9 2.1 1.4 0.9
10 10.8 10.0  9.2 8.3 7.5 6.7 5.8 5.0 4.2 3.4 2.6 1.9 1.3 0.8
11  9.4  8.7  7.9 7.2 6.5 5.8 5.1 4.3 3.6 2.9 2.2 1.6 1.1 0.7
12  7.6  7.0  6.4 5.8 5.2 4.7 4.1 3.5 2.9 2.3 1.8 1.3 0.9 0.6
13  5.4  5.0  4.6 4.2 3.7 3.3 2.9 2.5 2.1 1.7 1.3 0.9 0.6 0.4
14  3.6  3.3  3.1 2.8 2.5 2.2 1.9 1.7 1.4 1.1 0.9 0.6 0.4 0.3

We can visualize this three dimensional surface with the function wireframe from package lattice. We need to convert our nice neat array into a data frame. We can do this with melt from the reshape package.

> require(lattice)
Loading required package: lattice
> require(reshape)
Loading required package: reshape
> edam <- melt(e_damage, varnames = c("ARM", "DEF"))
> trellis.par.set(regions = list(col = heat_hcl(100, c = 80,
+         l = (range(e_damage) + 7) * 4, power = 0.8)))
>
wireframe(value ~ ARM * DEF, data = edam,
+           scales = list(arrows = FALSE),
+           drape = TRUE, colorkey = TRUE,
+           screen = list(z = -100, x = -50))

Image

We can use the same method to compare the effect of two Steelheads fighting alone, or as part of a combined melee attack. This can be a useful trick; rather than getting two individual attacks, the Steelheads make a single attack adding +2 (the number of participants) to their attack and damage rolls. When should Steelheads give up the extra attack in favour of improved stats?

> e_damage <- array(data = 0, dim = c(length(DEF), length(ARM), 2),
+     dimnames = list(DEF, ARM, c("2ind", "cma2")))
>
> # 2 independent attacks
>
> ph <- matrix(probTable2[mat, , drop = TRUE],
+     nrow = length(ARM), ncol = length(DEF),
+     byrow = TRUE, dimnames = list(ARM, DEF))
>
> avd <- matrix(mueTabled2[pas, ],
+     nrow = length(ARM), ncol = length(DEF),
+     byrow = FALSE, dimnames = list(ARM, DEF))
>
> e_damage[, , 1] <- t(ph * avd * 2) # elementwise multiplication
>
> # CMA2
>    
> ph2 <- matrix(probTable2[mat + 2, , drop = TRUE],
+     nrow = length(ARM), ncol = length(DEF),
+     byrow = TRUE, dimnames = list(ARM, DEF))
>
> avd2 <- matrix(mueTabled2[pas + 2, ],
+     nrow = length(ARM), ncol = length(DEF),
+     byrow = FALSE, dimnames = list(ARM, DEF))
>
> e_damage[, , 2] <- t(ph2 * avd2)
> edam <- melt(e_damage, varnames = c("DEF", "ARM", "group"))
>
> cols <- rep(heat_hcl(5, c = 80,
+         l = (range(edam$value) + 7) * 4, power = 0.8), each = 20)
> i = 120
> trellis.par.set(regions = list(col = cols))
>
>     print(wireframe(value ~ DEF * ARM, data = edam, groups = group,
+         scales = list(arrows = FALSE),
+         drape = TRUE, colorkey = TRUE,
+         screen = list(z = i - 140, x = -50)))

Image

This plot shows the two expected damage outputs from two Steelheads attacking individually or as a combined melee attack. As before the colour tone denotes damage output. To make this easier to see, I created plots for i between 70 and 260 and combined them into a GIF using ImageJ.

This shows that for low DEF, low ARM opponents, the damage output is expected to be dramatically higher for individual attacks than combined attacks. For high DEF and high ARM, damage output is low for both types. However, there is a band where combined attacks produce quite a bit more damage than individual attacks, either due to the low chance of hitting, or the low chance of damaging.

If we apply the function diff across the two outcomes, then we can see the cost of choosing CMA over individual attacks. Mostly bad, but at around the DEF 15-16 mark (where we’re hitting on tens), there’s a benefit of ~2 damage to combining.

> round(apply(e_damage, 1:2, diff)[7:18, 5:18], 1)
       5    6    7    8    9   10   11   12   13   14   15   16  17  18
7  -10.7 -9.7 -8.8 -7.8 -6.8 -5.8 -4.9 -3.9 -2.9 -2.0 -1.2 -0.5 0.0 0.3
8  -10.7 -9.7 -8.8 -7.8 -6.8 -5.8 -4.9 -3.9 -2.9 -2.0 -1.2 -0.5 0.0 0.3
9   -9.2 -8.4 -7.5 -6.7 -5.8 -4.9 -4.1 -3.2 -2.4 -1.6 -0.8 -0.3 0.2 0.4
10  -7.1 -6.4 -5.7 -5.0 -4.3 -3.6 -2.9 -2.2 -1.5 -0.9 -0.3  0.1 0.4 0.6
11  -5.0 -4.5 -4.0 -3.4 -2.9 -2.4 -1.9 -1.3 -0.8 -0.3  0.1  0.4 0.6 0.7
12  -2.7 -2.3 -2.0 -1.7 -1.3 -1.0 -0.7 -0.3  0.0  0.3  0.5  0.7 0.8 0.8
13   0.0  0.1  0.2  0.3  0.4  0.6  0.7  0.8  0.9  1.0  1.0  1.0 1.0 0.8
14   1.5  1.5  1.5  1.4  1.4  1.4  1.4  1.3  1.3  1.3  1.2  1.1 1.0 0.8
15   1.9  1.8  1.7  1.7  1.6  1.5  1.4  1.3  1.2  1.2  1.0  0.9 0.8 0.6
16   2.0  1.9  1.8  1.7  1.6  1.4  1.3  1.2  1.1  1.0  0.9  0.7 0.6 0.5
17   1.8  1.7  1.6  1.4  1.3  1.2  1.1  1.0  0.9  0.8  0.7  0.5 0.4 0.3
18   0.5  0.5  0.5  0.4  0.4  0.4  0.4  0.3  0.3  0.3  0.2  0.2 0.2 0.1

As you can see, we can quite quickly make observations about what decisions we should be making. Note that we’re still talking about damage expectation, which for a symmetrical distribution will only be achieved half of the time. But the take home message is avoid forming a CMA gang unless the odds are long, at least with two Steelheads. This four dimensional landscape is a fickle mistress…

Advertisements

3 thoughts on “do you wanna be in my gang?

  1. Very interesting. I wonder if the result would be similar if you were to assume you were attacking single wound troops (aka you only need to do one damage to kill them)? I suspect that it would skew the odds in favour of combining at a lower level.

  2. Great point. This seems like a good point to include a bit more depth on confidence of kill. I’ll have a look into this and post hopefully over the weekend.

  3. Pingback: i get knocked down | analytical gaming

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s