Wednesday, November 30, 2011

Rules Interpretations

Last night I got to thinking about how for analytical purposes, I've had to become quite rigid in my interpretation of the rules.  I worry I may be sufficiently rigid here, that it doesn't necessarily accurately reflect how people actually play the game, including myself.  That being said, I'm not necessarily sure what else to do because mathematical analysis lends itself to clearly defined algorithms, and playing it "fast and loose" just messes up the calculations.  That being said, I think that in most cases, while such a rigid interpretation may not reflect the actual probabilities of success, they do reflect the trend correctly.

If anyone who watches this blog (and the statistics reveal more than a few) notices that changing interpretations of the rules changes the statistics, feel free to comment on it.  The results might be interesting.

Friday, November 25, 2011

Searching for Secret Doors

In my D&D group, I'm often disappointed by the lack of team work in searching.  Since the search roll is executed in secret, the fact that you did not find a secret door does not imply that there is none there.  When someone chooses to search I always roll a die in secret, even if I know there's no door.  That creates uncertainty. 

So.. when a single character searches a 10'x10' area of a dungeon he has only a 1/6 probability (excluding the possibility of demi-humans and thieves, which change the numbers, but not the essential idea) of finding a door that may or may not be there.  Given that, it seems insane how easily some players give up.  Even if there is a secret door, you're unlikely to find it given a single turn of searching by one character. 

There's two possible solutions.  Searching for multiple turns, and having multiple characters search the same area simultaneously.  The pay off is fairly quick.  Consider the case of multiple simultaneous searchers with no special abilities.

Figure 1:  Multiple simultaneous searchers with no special ability rapidly increase the likelihood of finding a secret door.
 Given the presense of a secret door, you're much more likely to find it now if everyone in a mid-sized party of 5 or 6 PCs searches the same area.  If a larger party of 9 or 10 people searches, you're really in business, finding more than 80% of any doors that exist in the room.  Elves, dwarves, thieves, magic and what not just make the picture even rosier.

The interesting question now, is how confident are you that there exists no secret door given that you haven't found a secret door.  That requires appealing to Bayes Theorem.  It also depends on the number of secret doors in the dungeon and the size of the dungeon.  I figured the Caves of Chaos was a fairly good dungeon to sample, so I just counted the number of squares in the goblin lair and found that only 2 out of 119 10'x10' squares had a secret door in them, so that means the probability of there being no secret door is >0.98.  Assuming that's an adequate "average" dungeon the following chart holds.

Figure 2:  With 3 or 4 characters you can be very sure that there's no secret door if you didn't find one.

The first interesting observation is that even with the dismal search performance of a single character, not finding a secret door still means it's overwhelmingly likely that there is in fact no secret door.  Ruling out doors isn't really a problem.  That's a function of the fact that most walls in a dungeon don't have secret doors.  The problem is that if there is one, you're not likely to find it either. That being said with 4 or 5 characters searching simultaneously in the same area you can almost certain there's no door while having better than 50/50 odds of finding those doors which are there.

A similar result can be achieved by spending time searching.  A single character searching 5 turns will have the same effect as 5 characters searching simultaneously.  The down side of this is that a dungeon master will most likely be rolling for wandering monsters during this time.  If this is the case, the other characters should stand guard.

I also wonder if this is a case where it's wise to designate a "caller" even though in most parties there isn't usually one regardless of the recommendation of the rule book.  Leadership and decision making pay off big time in the game.  Individualism tends to lead to lackluster performance.

Saturday, November 19, 2011

Explaining Probability Distributions

I keep thinking it's important that I write up a post explaining the multinomial distribution and how it's related to rolling dice since I've relied on it for several results now and rolling dice is the fundamental random process of D&D.  I've sat down and tried to write it up three times now, and every time I do it, it ends up becomming a fairly involved project and I'm not sure I ended up clarifying anything.  The first time I started, I ended up finding that I'd really just described the binomial distribution and hadn't illuminated the multinomial distribution at all.  The second time I started to show how the multinomial distribution was a generalization of the binomial distribution and decided I wasn't clear enough.  The third time I tried some combination of both approaches and just ended up being more long winded.  The whole exercise has done nothing but reveal to me why there's so many lousy statistics books out there.  It's actually pretty difficult to be clear.  I also think the case of rolling dice is particularly difficult compared to say, coin flips.

None the less, I feel I have to tackle the problem if I'm going to keep explaining my thinking about tactics and decisions in D&D.

Friday, November 11, 2011

The Psychology of Probabilities

In a conversation regarding saving throws I had, someone argued that magic users had better saving throws versus spells than the other character classes, hence it wasn't worth attempting to cast a Light spell on their eyes.  When you work out the numbers, though, a level 1-5 magic user has only a 35% chance of saving and a 6-10 level magic user still has less than 50-50 odds.  When you throw initiative into the mix, the chance of coming out on top is better, but it's by no means decisive.  Since we're gambling, D&D is, after all, governed by chance, I'd say cast the spell on a spell caster.  They may do better than average at saving but it's still not great.

That left me wondering about the psychology of probability.  It seemed like the fact that a character had better than average odds of success was taken to mean that they had good odds of success, which isn't the same thing.  I guess it revolves around what you mean by "good."  "Good" in this case is a relative term.  One must always ask "good compared to what?"  If they mean other characters, then yes, magic users have good saving throws versus spells.  The thing is, what really matters is not the other characters.  A probability is a number between 0 and 1.  With 0 meaning I'd bet I'll never happen, and 1 meaning I'd bet it'll always happen.  Ideally, when one makes decisions, it'd be with only the 0-1 scale in mind for assessing their risk of failure.  In practice, though, this person seemed to reveal that what really matter is other people's risk of failure. 

It seems like a statistical version of keeping up with the Jones'.  As as if people aren't going to do something because objectively they'll do well.  They're going to do something because they're more likely to better than they other guy.

Tuesday, November 8, 2011

2d6 Versus 1d12 and Clerics Turning Undead

A discussion of clerics turning undead got me thinking about how likely they would be successful given multiple attempts.  To turn undead, you roll 2d6 and compare the result to the target.  I wanted to see how likely one was to succeed against varying hit-dice of baddies, and what the cumulative probability would be if there was no limit on the number of attempts. That in turn got me thinking about why we use 2d6 instead of 1d12 and what the impact would be. 

The d12 is probably the least loved die.  People tend to use 2d6 instead.  But should they? 

The answer is, of course, it depends on what you want to do.  The reason is that the results are distributed differently. 

Figure 1:  1d12 results are uniformly distributed while 2d6 follow a peaked distribution favoring moderate outcomes.

Using 2d6 tends to force more moderate outcomes at the expense of more extreme outcomes.  Using 1d12, since the results are uniformly distributed if the die is fair, will result in more extremes.

Figure 2:  2d6 makes exceeding higher targets less likely while lower targets are easier.
Using 2d6 makes clerics more powerful against lesser undead with lower target numbers to turn, but less powerful against more powerful undead with higher targets.  Using 1d12 makes them more powerful against powerful undead and less powerful against easier undead.  It's an interesting result, I think.

Saturday, November 5, 2011


In the course of a discussion of D&D tactics, it was brought up how in old school D&D the closest equivalent they have to "flanking" like in 3.5e is a thieve's backstabbing.  While I'm not sure the analogy is necessarily the best, it got me thinking about what the most effective use of backstabbing is.  For a thief to backstab, they have to use both their "Move Silently" and "Hide in Shadows" ability to move behind their target.  Because the probabilities multiply, a quick calculation reveals that this is a high-risk endeavor for any thief. Following the Labyrinth Lord rules, a first level thief has a less than 3% probability of successfully backstabbing, and no thief stands greater than 50-50 odds until he is 10th level.  Given that, my intuition is that the payoff for backstabbing is on average fairly low.  I'd only recommend thieves choose to backstab in the face of a real risk of total party kill (TPK).  To say more would require more modeling, though.  Since I'm already behind on my Markov model for my elf versus an orc, it's probably best that I hold off on going much further on this one.

Monday, October 24, 2011

I haven't posted lately because I've been working on preparing for an actual game at my local hobbyshop.  I'm planning on running The Keep on the Borderlands using the Labyrinth Lord rules.  I hope it goes well.  It's the first time I've DMed in years.  I'm looking forward to it.

Even so I haven't forgotten about my project.  I need desperately to post the probability tree for the combat I worked out.  It's sitting next to my bed on a piece of graph paper, but I need to figure out a better way to present it.  There's A LOT of possible outcomes and there's several ways to get there.  A Markov model will probably work well for this case, but to go any further I'm going to need to come up with some kind of Monte Carlo simulation.  There's just too many states and spending all night multiplying numbers together is a lot of tedious work.  I can say I did the work up front to understand the problem analytically before resorting to some kind of computer model. 

Monday, August 15, 2011

Other Initiative Bonuses and the Next Step

This afternoon, in a spasm of post-computer modeling boredom, I computed the remaining probabilities for +2, +3, and +4 initiative bonuses.  A +5 initiative bonus is uninteresting because it is equivalent to the orc automatically losing initiative unless he has some bonus that negates the elf's bonus.  In that case, though, it becomes statistically equivalent to the 0, +1, +2, +3 or +4 case.  The results of these and my previous investigations are summarized below.  They were all arrived at by methods identical to the previous posts.

Figure 1: The probability of the elf winning initiative as a function of any bonuses.

Figure 2: The probability of the elf tying initiative as a function of any bonus.

To proceed any further in my effort, I need to define some more of the properties of my elf and my orc.  I need to determine their weapons, hit points, and armor.  The orc is easy:

Orc(1): AC: 6, HD: 1, 8 hp, MV: 120'(40'), ATT:  1 sword, DAM: 1d8, Save As: F1, ML: 8, ALIGN: Chaotic.

That's just reading straight out of the rules and assuming maximum hit points.  I figure the orc is a good "standard" bad guy against which to gauge the capabilities of a character.  Similarly, I'll assume a "standard" level 1 PC elf with max hit points for now.  The PC elf will be wearing leather armor with a shield giving him an armor class of 7, which is slightly inferior to the orc.

According to the Labyrinth Lord attack tables, the Orc must roll a 12 or better to hit the elf, and the elf must roll a 13 or better to hit the orc.  This implies P(elf hits orc) = 40%, and P(orc hits elf) = 45%.  This places the orc at a slight advantage in terms of hitting ability. Given the previous observations that what really makes the difference in initiative, besides bonuses, is the ability to survive in a tied initiative round, I can't help but wonder if this slight advantage will translate into a noticeable advantage in the end for the orc.

At this point, the system is completely defined.  Neglecting magic and missiles (which I left out), I have everything necessary to fill out a probability tree for the turn.  The goal will then be to create a process so that I can analyze trade offs.  Then I can ask questions like, rationally, when is a two handed weapon worth losing initiative?  Irrational, "I think battle axes are cool!" is perfectly fine.  Lord knows, PCs should not feel constrained to act rationally, and resolving all of a character's choices to a series of optimized tactical trade offs is probably one of the least interesting and fun ways to play the game.  None the less, the question remains there to be answered what's the best decision?

Whatever results I get from this experiment are going to be driven by the assumptions going into them.  What's the best weapon to carry against an orc, might not be the best weapon to carry against another elf.  I'm also neglecting magic.  Really, whether the results of this experiment gives any indication of the "best" choice anything is a subject of debate.  Any "best" choice would certainly be highly situation dependant.  I imagine one day compiling a list of optimized equipment for various foes.  I doubt I'll do it, though.

For my next step, I'm going to boldly forgo proving that the combat turn is a Markov process and just fill out the tree assuming each state of the system is annotated by the elf's hit points and the orc's hit points.  Hence, on turn one, the beginning state is E(6)O(8) for "Elf: 6 hp, Orc 8hp."  There are 63 possible states.  I guess now I need to fill out my probability tree...

Sunday, August 14, 2011

Initiative in a One on One Combat with a +1 Bonus

What is the impact of an initiative bonus on combat?  I'll start to answer this question using the same sorts of observations I made previously. Assuming a +1 bonus, the initiative matrix looks like this:

Figure 1:  Initiative Outcomes Assuming a +1 Bonus to the Elf
The PC elf now has an appreciable advantage in the intiative phase.  P(Elf Wins) = 21/36 = 58.33%, which is a pretty substantial edge if you can maintain the advantage through the later phases of combat round.  It is, by no means decisive.

Figure 2: Elf Wins Initiative 58.33% of the Time with a +1 Bonus
The advantage would be even more substantial if the elf enjoyed further combat advantages enabling good survivability in the event of tied initiative.

Figure 3: Elf Wins Ties Initiative 13.89% of the Time with a +1 Bonus

Does a +1 bonus enable a serious "first strike" advantage?  Probably not.  But over several combat rounds would the cumulative effect become noticable?  You'd notice it. particularly if you were strong enough to withstand a tied round now and then.  If that was the case, then it'd be pretty decisive.   

Beginning with the Combat Round

To begin my analysis, I decided to start with the combat round.  I plan to start off very simply and describe a notional encounter between a PC elf and an orc.  This one-on-one renders questions about group versus individual initiative irrelevant for now.  I expect I'll get back to that some other time.  I'll flesh out their characteristics further as it's necessary.  The first step of a combat round is initiative.    To determine who wins initiative, we roll 1d6 and who ever's roll is higher wins.  If both sides roll the same number, actions are assumed to occur simultaneously.  There are 6^2=36 possible outcomes in the initiative phase.

Figure 1: Initiative Outcomes in a One-on-One Encounter
What is the probability of the elf winning initiative and getting one up on the orc?  As the above table shows, the elf wins, 15 out of 36 times.  Therefore P(Elf Wins) = 15/36 = 41.67%.  Since the system is symmetric the orc has an equal probability of winning initiative.

Figure 2: Elf Wins Initiative in 15 Possible Outcomes
 The diagonal elements of the matrix of possible outcomes constitutes ties.  There are 6 possible ties.  Therefore P(Tie) = 6/36 = 16.67%. 

Figure 3: Elf and Orc Tie Initiative in 6 Possible Outcomes

 The first effect of group initiative is that neither the orc nor the elf is likely to win initiative.  This isn't to say that neither side has an advantage due to initiative.  If for some reason (armor, spells, special abilities, etc.) the elf might have an advantage in the event of a tie, the initiative might actually slightly favor the PC because the probability of winning or tie-ing, P(win ^ tie)=58.33%. 

Assuming that's not the case, however, most of the time a PC is not going to get any "first strike" advantage, therefore to be really effective in combat, a PC needs to survivable against a monster's first strike or the outcome of a tied round. A one-on-one combat in D&D, therefore is about survivability.  With no initiative bonuses, combat as an ambiguous scenario, where if any side has any advantage at all it results from other combat related advantages such as armor class, hit points or saving throws. 

Certain special abilities entail the player or DM applies a small bonus to their initiative rolls.  A dexterity score of 13 entails a +1 bonus.  How large are the effect of bonuses in initiative?  I'll have to play with that calculation later, though. 

Friday, August 12, 2011

Starting The Mathematics of Old School D&D

Much ink has been spilt on how old school Dungeons and Dragons favors clever players who act cautiously in the face of terrible danger.  But what actually constitutes playing cleverly?  What course of action is, in fact, wise?  What is an effective precaution?  Cleverness can consist of acting imaginatively and thinking "out of the box." While that kind of thinking often leads to entertaining gaming sessions, a lot of D&D is also about learning to play the odds effectively.   A more modest sort of cleverness is about making good decisions to improve one's probability of survival in a hostile and constantly evolving environment.  Both players and dungeon masters must learn to make decisions in the face of uncertainty, simply by virtue of the randomness inherent in the game's rules. 

This isn't to say I'm intending to blog on power-gaming or meta-gaming.  That's because creating over-powered characters in old school D&D is fairly difficult.  They're created randomly by one of several processes.  Rather, I intend to focus on rational decision making and planning for dungeon masters and players.  I'm also curious about the implications some house rules have on the outcome of combat.  I want to steer away from questions that may involve thinking too much about "realism" through the lens of physics.  As far as I'm concerned, talking about "realism" in a fantasy game is a waste of time.  What does realism mean in an imaginary world where unicorns and pixies frolic, anyhow?  I'm more concerned purely with what the rules entail and any insights thinking about things mathematically might provide for the sake of an improved afternoon of play.

I'll try to present charts, graphs and equations to explain my thinking.  If I'm feeling ambitious, I may even present the results of the odd Monte Carlo model.  If I'm wrong, feel free to call me out on it.  My hope is that this doesn't turn into me pedantically droning on about stochastic processes and turns into an interesting discussion of rational decision making, tactics, techniques and the interesting mathematical problems presented by old school roleplaying games in general, and D&D specifically.  Hopefully the end result will be a practical advice that will contribute to better dungeons, better dungeon masters, and smarter players.