Monday, February 17, 2025

Math in TTRPGs

Recently I was discussing a possible proceduraly generated puzzle, and issue that came up was that in order to reliably check whether you actually got the correct solution, you would need at least 5 equations. It was not a problem that I originally considered, but it reminded me of something I have long thought about.

Mechanics as mathematical models

3 out of 4 of TTRPG activity categories (as described by Proph at Traveler's Homebrew) can be described to varrying degree using math. (A case could be made for Freeform as well, but that is a discussion for another time.) For the Random side of the spectrum, this is quite obvious - whenever chance is involved, whatever occurs can be described as some form of statistical phenomena. As for the "Puzzle" a sort of binary "Pass/Fail" logic needs to be present, even if just to describe the outcome - for a simple puzzle this could look like a simple logical statement:

"In the room ahead lie two keys. A red key and a blue key. At the far end of the room is a closed blue door."

We can assume that the correct key will be blue, hence the solution can be written as a statement:
 " The key is blue, AND the door is open"; or in mathematical notation: (Blue key) ∧ (Open door). A simple table could then be constructed:

Key is Blue Door is Open (Blue key) ∧ (Open door)
1 1 1
1 0 0
0 1 0
0 0 0

Note that we used Conjunction instead of Implication to describe the solution, as the fact that the blue key opens the door does not mean there is no other key that could open the door, it simply means that the blue key will, but in our situation the only other key is the red key, which is (obviously) wrong.

I'm sure everyone is aware dice can be described using odds and number ranges, but we can actually use math to describe other tools we use - such as cards. We label each card 0 through 12 (0 is reserved for Ace and 1, 11 and 12 represent the Jack, Queen and King respectively - you'll see why shortly) and do so in a base 13 system - this means we can use the "thirteens" digit to represent the card suit (0 - Clubs, 1 - Spades, 2 - Hearts, 3 - Diamonds), and the "ones" to describe the individual cards (0 for Ace, 1 for the Jack, 2 - A for the respectively numbered cards, B for the Queen and C for the King*). So for example 1B would be the Queen of Spades. If we were to then design a game where whoever draws a King wins, their odds of winning are 1/13 (There is only one King for each suit), and this condition could be stated using logic, as described above.
* - highest digit in the tredecimal system is 12 - represented by the letter C.

As you can see I'm sure, with enough mathematical rigour, all mechanical procedures can be described using a combination of logic, and proper use of equations.

"But this is all obvious, how else could there be virtual tabletops that automate mechanics, how is any of this actually useful to a hobby designer/game master?"

Math for analyzing TTRPGs

Now that I have convinced you that mechanics can be described by using the proper math, how do we actually use this? Well, after we have found a way to describe whatever we are using as some form of a mathematical construct, we can now use this for gathering useful data about our game/session. For example AnyDice is a popular site for analyzing values and odds different dice can produce - which can be very useful for any game.
Another method is formulating aspects of our game as new mathematical constructs - my favourite example is Complexity.

My definiton of Complexity for a mechanic is "The number of elementary steps a player needs to perform in order to complete a procedure".
Let's break this down using Skill checks from D&D - how many steps does a player need to perform in order to resolve a skill check?
  1. Roll the die (d20)
  2. Find all relevant modifiers
  3. Calculate the result (add the modifiers to the die roll)
  4. Consult the Game master
This would put a simple Skill check at a Complexity value of 4 - fairly average, but it could be lowered by simply stating the odds of success on their character sheet before hand:

  1. Find the relevant Skill rating on the Character sheet
  2. Roll the die
  3. Compare the roll to the number on the sheet
With one simple change, we reduced the number of steps a player needs to perform by 1 - a whole 25% in this case! Given how many Skill checks an average player makes, this can quickly stack up to decrese the mental fatigue over a whole session.
Now, not all steps are created equal, as some things are easier to process than others - Solving an inequality without any unkowns is much easier than solving an equation - everyone knows that 4 < 15, but 15 - 4 = X takes a tiny bit longer to solve. We could then create a new concept for how difficult something is to perform, or break it into constituent steps which would then impact the overall Complexity of a mechanic, and thus give a more accurate rating.
None of this is to say mechanics with high Complexity are bad - if something involves multiple steps a player will need to engage with it for longer, thus making them more occupied and, and the whole action will feel more important than something that comes almost instinctually to them. It is just important to understand this distinction and how Complexity impacts how players will engage with something - if a seemingly mundane task has high Complexity, players will probably tend to avoid it, because the whole process will feel like a meaningless ordeal because they need to expend a lot of mental effort for mediocre results. On the other hand, if a task of extreme importance has a Complexity of 1, then the victory might feel hollow and unearned.
Point is: Always use the right tools for the job.

Conclusion

Describing various parts and concepts of games using math can provide us with a clearer picture about what we are actually dealing with, and yield useful data to fine tune the experience, as if we were only dealing with ideas and established perspectives.
Thanks for reading, enjoy your next game!

Math in TTRPGs

Recently I was discussing a possible proceduraly generated puzzle, and issue that came up was that in order to reliably check whether you ac...