## 08 July 2009

### 150 ways to destroy a Battlemech

Following up on my last post about calculating probability of destroying Mechs with a given amount of damage, I have hit on a big snag ... actually, it's more like 150 little snags.

I had worked out how to calculate the probability distribution for transferred damage from one location to another, but this turns out to not be quite right. It's more accurate to work this out as increasingly larger subsets of locations on the Mech. For example, if I want the distributions describing the Left Arm (LA), separate calculations for LA armor then damage transferred to the LA internal structure doesn't work out right. I need the distribution for the LA armor and the sum of the LA armor + internal structure.

For calculating the probability that a Mech is destroyed though, it's better to start at the Center Torso (CT) and work out. Once I realized this, it occurred to me that I was missing a lot of calculations, so I started trying to count all the ways a Battlemech can be destroyed by some combination of damage striking different locations.

So I started counting. Here "CT" refers to damage striking the CT location to destroy the sum of Armor and Internal Structure there, and "CT+LT" is damage striking either location (etc.). (I also need similar calculations for Armor-only at each location for the purpose of critical hits, but that's another story.) Counting, and ignoring damage from the rear (for the moment), here is a partial list of ways to destroy a Battlemech:
CT
CT+LT
CT+LT+LA
CT+LT+LL
CT+LT+LA+LL
CT+RT+LT+LA
CT+RT+LT+LL
CT+RT+LT+LA+LL
...

If I include damage from the rear, the list starts off like this:
CT@front
CT@rear
CT@front&rear
CT@front+LT@front
CT@front+LT@rear (not needed)
CT@front+LT@front&rear
CT@rear+LT@front (not needed)
CT@rear+LT@rear
CT@rear+LT@front&rear
CT@front&rear+LT@front
CT@front&rear+LT@rear
CT@front&rear+LT@front&rear
...

I think that enough to give the general idea. Many of these probabilities will likely turn out so small as to be trivial, but since my goal is to do this right, I still need all of these to check my results (sums of all probabilities should add up to 1.0). I ended up writing a simple program to list all possible combinations of locations, and then eliminated those that are not needed, leaving me with a list of 150 probability calculations needed. Ouch.
This also moves the problem out of the realm of of problem that can be solved in an excel spreadsheet, because there is an upper limit of 256 columns, and each calculation needs at least two columns (and that doesn't count critical hit calculations either). Ouch ouch.
Even if I could set this up in a spreadsheet, the prospect of checking all those calculations individually for correctness is truly daunting. I could have errors and never spot them. Ouch ouch ouch.

The solution to all this is going to be a computer program. I've been looking for an excuse to learn R, because I need it at work too, so this should give me a good introduction. When I get this part worked out, setting up a near approximation in a spreadsheet will be relatively trivial in comparison. I never said this was going to be easy!
[]