Sunday, October 20, 2013

X-Wing Attack Odds Calculator Under Development

So I enjoy math but sometimes the math is not as straight forward as you would like.   For example in the X-wing game it is easy to determine the mean results for the attack dice and defense dice under an of the standard rules(no pilot abilities but standard actions allowed) but the mean number of hits and criticals are not going to be the direct comparison of these since if you cancel hits before crits and if you have more evades than hits and crits combined on an specific test those extra evades are wasted.

To do the calculations correctly you have to take each possible final result (10 for 3 attack dice for example from nothing to 3 crits or 3 hits or 2 hits+1crit, etc.) and then calculate all the paths to get that result.  The math here is simple but it gets pretty cumbersome to do for lots of different options.  This is where a Monte Carlo (think Casinos) simulation come in.  You just write the rules into the software and run millions of trials for each set of parameters you are interested in testing.  So I have written up this code in the programming language I use for work to keep me fresh in programming it since I one rarely have to code things.  I started some baseline test but if anyone has specific conditions they would like me to compare just let me know as  weapon values go from 2 to 5 and evasions can go from 1 to 5 and you have target locks, focus and evade actions to worry about which gives you like 320 different attack and defense inputs to compare which is just to much data to generate.

Here is an example of the data where I have looked at Attack 3 vs Defense 3 with 1 action active:

We can see here that both focus and target lock used by the attacker almost doubles the mean hits+crits but target lock gets you more crits on average as you would expect.  Defender Focus reduces hits+crits by about 2/3ths while evade in this case cuts them by 3/4ths.

I am calling this series +-Wing (Plus Wing).  Lets see what we can learn.


  1. interesting but maths goes right above my head LOL

    1. Thanks for commenting. If you are familiar with something like 40K attack where each attack has some chance of hitting, then wounding, and then a save it is easy to calculate the average wounds as the product of all those individual probabilities. X-wing is different since since a 3 dice attack generates so many hits but the defender rolls their same number of defense dice all the time. The two sets of dice are pooled then compared which makes things a little trickier.