Saturday, 31 May 2014

Analysis - Exploring success rates in 40k combat using computer simulations

I have a working version of my combat simulator up and running in Python. It's relatively simplistic at the moment, you can generate a squad of troops of any size equipped with specific ranged and close combat weapons. These squads can shoot at each other and fight in close combat, recording the number of wounds and reducing squad size etc. For those of you who are interested in programming, each squad is an instance of a class, with attributes specified for the selected troop type and methods for all aspects of shooting/assault as well as saving rolls and recording wounds. I've tried to make the code as modular as possible so special rules can be added easily in future.

Once I bug tested the code a bit, I started simulating some fire fights between squads. The simulations were pretty simplistic with each unit just standing and firing at each other until one squad dies. Now I realise that in a game of 40k the situation is almost always much more complicated than that (there's many units, cover, special weapons, characters, squads can break, there's objective to capture etc etc), but the whole point of computer modelling is to try and strip back all the complexity and determine how the system works fundamentally. This allows you to see things that are obscured normally as varying parameters, even slightly can have dramatic and unintuitive effects in any complex system.

At first I was interested in looking at how weapon skill, ballistic skill, strength, toughness and saving throws effect the outcome of combat, and these all had interesting results (which I'll explore more deeply in later articles), but then I started to vary relative squad size and I found the results to be quite surprising.

Simulations were run for fire fights between Termagants (varying squad size) and a tactical squad of 10 Space Marines, both of these had no upgrades using fleshborers and bolters (no rapid fire) respectively. Each squad fired at each other alternately and removed casualties. No morale checks were simulated and combat took as many turns as necessary to wipe out one squad. This was repeated 1000 times and the victor was recorded, and this was used to give a percentage win rate. The number of Termagants was increased and the simulations were ran again. Here's a plot of the results with the ratio of marines to gants (i.e. a value of 1 is 1/1 so 10 gants and 10 marines, so a value of 3 is 3/1 = 30 gants to 10 marines) against the gant success rate:

As you can see there is a sigmoidal relationship between relative squad size and success rate in combat, and this is not only true for shooting but assault as well. Before I did this I assumed there would be a linear relationship i.e. the success rate would increase proportionally one squad got bigger than the other. If this were the case double the amount of troops would double the success rate. I dare say some of you reading this would have realised why this is not the case, but I'll explain why for the rest of us.

Every time a model is killed, not only does the squad size decrease but its combat effectiveness drops as well. As the combat progresses, a compound effect arises where due to its reduced damage dealing potential, the (eventual) losing squad becomes very unlikely to kill enough of the enemy to reduce their damage dealing ability quickly enough to win themselves. And so it becomes more and more likely that the enemy will kill far more troops.

This is all very well but what does it mean in relation to the game itself and how can you apply it? Due the exponential section of this plot (the steep part) certain engagements are going to have really unpredictable outcomes. This can make the combat quite exciting but is not very helpful if you're trying to plan ahead into subsequent turns. However, it also plateaus quickly allowing you predict how many more troops are required to win a particular engagement with high certainty. This allows you to use your force more efficiently as you can then commit those troops and no more, which could potentially be only a very few pts worth of models. For example, I first noticed this effect when I ran a simulation with 25 gants vs 10 marines (just to test the code), the gants came out with a 40% chance of winning the combat. I reran this with 30 gants and 10 marines, which predicted an 80% chance of the gants winning, doubling the win rate for only 20 points! The same result would occur if you reduced the starting number of marines slightly too, so a single volley from a long range weapon could flip the odds of winning.

Taking the idea further, it makes sense that the ratio required to win combat also changes based on who fires/strikes first:

This plot contains the original simulations (in blue) where the termagants shot first and another set of simulations where the marines shoot first (in red). Again this makes sense as the unit that fires second has reduced combat effectiveness going into the fight. This information makes me value high initiative models even more as striking first every round of combat could have a dramatic effect on the outcome of the assault.

These simple simulations are not meant as a way of guaranteeing victory or saying "unit x is better than unit y", but they absolutely could help players choose engagements more sensibly and predict more accurately the outcome of the various situations that arise in a game of 40k. There are some caveats to what I said here, multi-wound models behave differently as they can take wounds and not have their combat effectiveness reduced, so think about how this might effect your troops. I'm still tinkering away on the combat simulator but if anyone would like a copy of the code please ask in the comments section. I'll have another analysis article next weekend, any suggestions on what to discuss are welcome.

Thanks very much for reading!

No comments:

Post a Comment