Saturday, June 11, 2011

The math of the game

Time for some math. This is an abstraction and a bit more goes into it, but creating a combat system is fundamentally the solving of this formula:

0 = [(Enemy Hit Points – (((21 - Ave Target Defense + Attack)/20) x (Base damage + damage modifiers) x # combat rounds x Average # attacks per turn) / # PCs] -- [(PC Hit Points – (((21 - Ave Target Defense + Attack)/20) x (Base damage + damage modifiers) x # combat rounds x Average # attacks per turn) / # Monsters]

So let’s parse that apart. The formula is “zero equals the subtraction of” this formula doubled; once for the PCs and once for the monsters:

[(Enemy Hit Points – (((21 - Ave Target Defense + Attack)/20) x (Base damage + damage modifiers) x # combat rounds x Average # attacks per turn) / # PCs]

Which is really just hit points less expected hit rate x total average damage x number of rounds x number of attacks per round discounted across the number of PCs. Then we do the same for monsters, subtract the two, and look at the result. If the result is zero, then combat is equally matched. If the result is positive, the PCs have the mathematical advantage. If it is negative, the monsters have the advantage. Simple as that.

It is pretty hard to reliably hit the zero target for balance, so you sort of have to take a design stance: which side do you lean towards. I actually lean towards negative side or giving the monsters the edge. I lean this way for a number of reasons including (a) combat should be dangerous, (b) the formula doesn’t take into consideration tactics or cooperation, (c) players will make sum positive tradeoffs (like reducing attack for an increase to damage that that has a sum positive impact), (d) power creep will emerge, and (e) the favorable system assumption here is to make monsters more powerful and let the GM find equilibrium by either changing monsters or empowering characters. If combat is made too easy by default, toughening it up requires the GM to be the “bad guy.”

There are a lot of other neat things hidden away in the formula that emerge when you start working with it. For instance, the system has to be agnostic with regards to the # PCs part of the formula because the system has to accommodate any group. The easiest solution is to set the number of monsters equal to the number of PCs and remove both terms from the equation.

We also see that number of combat rounds is a hugely influential design decision. In 3e we routinely had combats that varied in length dramatically. Some were over in two rounds, others took 20. That was sort of just the way things were. Fourth edition has a tighter expectation and I think that is better design. It is easier to make determinations about combat resources when you know how many rounds those resources will be stretched over. Of course, the formula really only focuses on typical rounds of combat, so it is possible to have longer combats where rounds are dedicated to other things like movement (climbing, jumping) or defeating some other thing outside the traditional combat scope (like solving a trap or puzzle).

Finally, and this will sound dumb, we see that some things are harder to change than others. That was actually sort of a big discovery because it revealed an order of operations for designing the game. A change to target defense has a lot of ramifications based on average attack, damage, damage bonuses, how often you attack, and so on. This statement is sort of true for all variables in the formula, but some are more fundamental than others. For instance, hit points stand relatively independent in the formula and so they are a useful place to balance or accommodate other design goals. As a result, hit points are sort of set aside and you only make decisions on them once you are fairly confident about other parts of the game.

A quick example helps explain. Technically any variable can progress at any rate desired. But some rates of progression are better than others. With regards to monsters, nice round numbers like “+1 per level” make developing monsters really simple. We want that simplicity. When that simplicity trickles through the formula, there is less simplicity left over for the other variables. All of the sudden you need damage to increase at 1.36545/level to stay balanced. But, what the hell, “+2 damage per level” is simpler and so we put it in. Suddenly there is less simplicity left for the other variables. All the constraints you put on other variables is left for the end.

Finally, we get to hit points, who, like a champ, are this really small incremental variable in the game. By the time we get to hit points, all of that rounding has compounded into reasonably large-ish integer like numbers. And while we needed other things to be like “+1 per level”, hit points work just fine at “+6 per level” or some less round number.

But there is one final piece to the puzzle and that is healing.

The formula is actually really constraining; it doesn’t give us that many variables. Far fewer variables, in fact, than a game demands. Players want each class to feel different and play differently and the formula just doesn’t introduce that much variability. The solution was to let each variable be fulfilled by multiple different routes and hit points are a great example of that. You can meet the formula’s expectations of hit points by just having a lot of hit points, or you can have less but easily heal the difference, or you can have less but generate temporary hit points each turn, or you can have less but reduce damage taken. It also works to combine those various mechanisms in different ratios.  

They also play a lot differently than you might initially think. Obviously, just having a lot of hit points means you show up ready to take hits, but it also means your bloodied value is much higher than other character’s values. This has a visible impact. The ability to easily heal means you get bloodied quicker, but it also means that in combats where you aren’t hit you have more resources (that you didn’t have to spend towards healing) to be more effective in different places. Generating temporary hit points each round means you actually have incentive to be hit each round. Someone who generates temporary hit points and also invests in a high defense is diluting the value of those temp hit points. Of course, they only want to be hit once per round, which means they prefer head-to-head style matchups. This is distinct from the character that reduces damage, because they prefer to be hit multiple times per round (ideally by foes that deal small amounts of damage).

These strategies and differences work both ways. A character who deals bit hits might prefer to go against a target that easily heals with the hope that they can take them out before they have time to heal. A character that makes multiple attacks will avoid the damage reduction target, and so on.

Each strategy gets us to “a number” but by very different routes that look, feel, and play very differently. When you start to think about all of the different ways all of the different variables can be achieved, we start to see that a very balanced game can emerge with a lot of options to carve out your particular play style and vision.


  1. Do keep in mind when figuring out the math of the combat system (which is really what you're doing right now, not the math of the game in general) the power of multi-attacks as it stands. Because they offer the ability to add static modifiers to damage rolls with each attack, multiattacking is the best way under the current 4th edition rules structure to deal tons and tons of damage.

    There are a couple of ways to get around this: one is to remove static modifiers from attacks which attack a single target multiple times. This is a simple solution, but can often cause problems with suspension of disbelief, partiularly if you're using traditional +number weapons in your game (ie. the "why isn't my magic sword helping me out with my second swing).

    Another option (kin to the first one) is to allow modifiers to be applied once to any single attack. This has some more flexiblity, but runs into the same problems.

    The third option is to penalize multiple attacks in some way that makes up for stacking modifiers. The problem with this is that (just like in 3.5) this will assume that characters have a certain number of modifiers to make up for the to-hit penalties. This can be problematic because it can presume significant optimization, which is always bad for the game.

    The best option in my mind is to make multiattacking carry some sort of other price, which can only be made up by allocation of character resources. A good example of this would be having multi-attacking with weapons require wielding two weapons, preventing the use of a shield (and thus the bonus to defenses that grants). For non-weapon multiattacks (or single weapon multiattacks) you can balance them by issuing self-induced status afflictions like combat advantage or dazing that create a choice "do I want to do incredible damage, even if it means that I have to sacrifice durability?"

    Part of the answer to the question of how to balance multiple attacks is to determine what roll you want each combat style to play in the game. Do you want it to draw on historical methods of fighting with two weapons (a balanced mix of offense and defense, where one weapon was primarily used as defense and opportunistic attacks) or go for the gonzo fantasy approach where barbarians routinely swing two hefty battleaxes while charging into battle?

    As an aside, I'd also love to see if you have any plans for a skill-challenge system in this game you're working on, or if you're planning on incorporating some sort of "social combat" mechanics into it.

  2. As always, a great comment. It'll probably take multiple replies to parse through the ideas...

    My current thoughts with multi-attacks are to include a range of tradeoffs. For many characters, multi-attacks are only achieved through special powers that always require either multiple targets (see the Barbarian's ricochet) or the expenditure of extra resources like action points. For other characters, it will require two-weapons which occludes shields and requires investment in multiple weapons.

    Generically, a second attack will occur at a -5 penalty and this penalty will gradually be offset across levels, but probably reaching a penalty floor at -2.

    Concurrently, there is base damage, damage modifiers, and damage bonuses. Base damage is things like weapon die + str. Modifiers are things like strength and specialization. Base damage and modifiers apply to all attacks. Bonus damage typically only applies to a single attack. This would be things like sneak attack that apply only a single time/rnd.

    So far, this combination seems to keep expected damage (damage discounted by chance to hit) relatively stable across levels. The dominant strategies change depending on when you face a high defense foe or a high resistance for or whatever, but that was a goal. We want the dominant strategy to change so that everyone gets a chance to shine.

  3. With regards to what role I want fighting styles to play, I'm fairly agnostic. I find that any given table includes a range of players who show up for different things. For my group, it usually included at least one each of: (a) I want to be mechanically powerful, (b) I want to look cool, (c) I want to recreate a classic fantasy trope like a knight. Those goals are so diverse that it is hard to intentionally appease them all.

    What I do want is for all of the rules to be fair and fun. I don't want anything to be dramatically more powerful than anything else such that people feel compelled to play it. If someone else really wants to two-weapon fight with a gun and a sword, I'd really rather it be doable. The rules will never be perfectly balanced, and that is fine, but if forced to pick I want them to be quick to resolve and unobtrusive.

  4. I completely understand your desire for balanced play, and applaud it-a lot of "amateur" game designers (and more than a few professional ones) just through stuff together and hope that it comes out to something appromiximating playable. More often it just turns out to be a horribly unablanced, confusing mess. So I'd definitely say you're on the right track.

    That being said, eventually there's got to be some sort of stand taken on fighting styles-what mechanical roll that you want them to play. Because invariably, no matter what people's ancillary goals are (power, fidelity to a backstory or the story being created, looking awesome) people are going to worry about what a particular decision means for their character from a mechanical perspective.

    It's perfectly okay to say that there's no mechanical difference between fighting styles-to just abstract everything, and have feats, maneuevers, and trades cover the particulars of how much damage you deal vs. defense vs. durabilty and have things like whether you're wielding a dagger or a greataxe just be fluff. That however, might prove unsatisfying to some who prefer games with more defined mechanics (I myself don't mind it in games like Wushu, which are exceedingly abstract, but for a more conventional game I do like some mechanical crunch to various options).

    If you do decide to have fighting style have a mechanical impact on a character (especially since you want all of them to be balanced with one another), you need to determine what each is going to specialize in. Tradeoffs and decision points are key to balance, and if every fighting style can do everything equally well then there's no point to listing different fighting styles as mechanical options.

    What I meant when I said the roll that each one will play is to determine it's core competencies: what it's good at, and then allowing individuals to correct some of the problems with the style by expending resources (such as trades or feats). For example you might determine fighting styles this way:

    Two Weapon Fighting
    Good At: Dealing lots of damage
    Okay At: Defense
    Poor At: Area attacks

    This is just an example, but by determining the strengths and wekanesses of each, you have skeleton to build upon with your design.

  5. We are largely in agreement but differ by method. The way I want to distinguish fighting styles is by the way in which they reach the same rally point. For instance, if the math says that a character needs expected damage of X and Y level, I want the fighting styles to take different routes to get to that rally point. The Rogue might make one big sneak attack that may hit or miss, the fighter may reliably hit for a smaller amount of damage, and the two-weapon fighter may make multiple attacks that may hit or miss.

    They all end up at the same rally point (i.e. expected X damage) but play differently. These differences are further enhanced by the foes they fight. So the sneak attack (that may hit or miss) loses more expected damage against the high defense foe than the fighter does. The two-weapon character suffers more against the high DR foe than the fighter or the rogue. Etc.