keeping ahead

I thought I’d do a quick code reuse example today. It turned out to be a more surprising result than I expected. Previously I compared the likelihood of damaging the left arm compared to the right arm. There was a 10 percentage point swing protecting the right arm when chipping away one point of damage at a time. I found this surprising given that damage grids are symmetrical.

Today I wanted to show that we could also examine the difference between taking out the movement, M, on the bottom left of the grid and the cortex, C, on the bottom right.

1 to 6 select columns, M and C signify movement and cortex systems

1 to 6 selects column, M and C signify movement and cortex systems

The effect was so large that I spent my lunch break debugging my code looking for an error! But the effect is real. Spoilers!

> # we simply need to change the definition
> # of how the systems became crippled
> ironclad_definition <- list(boxes = c(4, 5, 6, 6, 5, 4),
+     left = c(4, 0, 0, 6, 5, 4), # movement
+     right = c(4, 5, 6, 0, 0, 4)) # cortex
> 
> N <- 100000
>
> results <- matrix(as.character(NA), nrow = N, ncol = 12)
>
> for (i in seq_len(12)) {
+
+     for (j in seq_len(N)) {
+
+         object <- list(warjack = ironclad_definition$boxes,
+             no_boxes = no_boxes(max = i), column = colmn(), 
+             crippled = NA)
+
+         out <- kill_warjack(object, max = i)
+
+         results[j, i] <- out$crippled
+     }
+ }
> tab_res <- apply(results, 2, function(x) { c(table(x) / 1000) })
> tab_res
[[1]]
 left right
75.19 24.81

[[2]]
 both  left right
 3.36 68.60 28.04

[[3]]
 both  left right
 5.99 66.77 27.24

[[4]]
 both  left right
 8.59 62.87 28.54

[[5]]
 both  left right
10.42 60.82 28.76

[[6]]
 both  left right
12.00 58.92 29.08

[[7]]
 both  left right
12.35 58.11 29.54

[[8]]
 both  left right
13.36 56.45 30.19

[[9]]
 both  left right
15.67 55.12 29.21

[[10]]
 both  left right
17.86 53.53 28.61

[[11]]
 both  left right
17.92 53.34 28.74

[[12]]
 both  left right
19.16 51.71 29.13

That’s huge! When chipping away one damage point at a time we are three times more likely to take out the movement first.

> tab_mat <- matrix(c(NA, unlist(tab_res)), ncol = 3, byrow = TRUE)
> par(mar = c(5, 4, 1, 1))
> plot(c(1, 12), c(0, 80), type = "n",
+     xlab = "Max Damage", ylab = "First System (%)")
> cols <- hsv(h = c(0, 0.3, 0.6), s = c(0.3, 0.6, 0.9), v = c(0.3, 0.9, 0.6))
> matlines(seq_len(12), tab_mat, lty = c(2, 1, 1), lwd = 2,
+     col = cols)
> legend("topright", legend = c("both", "move", "cortex"),
+     lty = c(2, 1, 1), lwd = 2,
+     col = cols)

Image

Rationally we can see that uniform hits will chip down the columns evenly, until rolls of a 6, 1, 2 or 3 will hit M, as well as rolls of 5 once that column is fully damaged. Only rolls of 4 or 5 can take out the cortex, as well as rolls of 3 once that column is fully damaged. But emotionally that is a very surprising result. In game terms, this is very useful, as the cortex is arguably the most powerful system as it makes the warjack a very interactive piece. I’m kind of liking the cheesy callback with the pun infested title, so I might make it a thing.

Under pressure, your warjacks will be keeping ahead!

Advertisements

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