Analyzing a roll and keep system

A “roll and keep” system can be tweaked by simple rules to provide some interesting probability distributions. This post will explain what a “roll and keep” system is, take a look at how one such system can be manipulated and provide some source code to experiment.


Since the late 1980’s, certain roleplaying games have made use of “dice pool success” mechanics. Such systems roll a handful of similar dice (usually d6 or d10), with the number of dice usually determined by the traits of the character for whom the roll is being made. That is, typically someone with more skill in something will roll more dice, also referred to as having a “larger pool”. Usually, each die rolled is compared individually to some sort of target, and if the die meets or exceeds that number, the die is considered a “success”. The quality of the roll is determined by how many successes are generated (i.e. how many dice meet or exceed the target).

One appeal of this type of mechanic is that it allows many variables to affect the roll, using a number of different mechanisms. A system might allow the situation to alter to number of dice, the target number, the number of successes needed to reach a goal and so on. As a result, many variations on this the basic idea can be found in different games.

One type of variation is known as a “roll and keep” system. The idea here is that you roll your pool, but only get to keep some subset of the dice. For example, you might roll seven dice but only be able to keep three, selected after the roll is made. Obviously, players will typically pick the best three results.

While not many games use roll and keep systems, the appeal of them is twofold. First, it adds yet another variable into how the roll can be manipulated (i.e. changes to how many dice you keep). Second, and more importantly, it allows a game designer to exert some control over the maximum number of successes generated by a roll. That is, some pool-based systems can get intro trouble with “runaway successes”, where various imbalances between characters can get magnified, with some characters scoring ungodly numbers of successes. Using a roll and keep system allows a designer to focus on a “sweet spot” for the number of generate successes. This post aims to investigate what various rules variations do to a roll and keep system.

One caveat: this analysis starts with a very “crunchy” (rules-heavy) system, and mutates it into an even more crunchy system in some ways. The point is really to see what happens within the roll and keep system, rather than try to convince you that the result is somehow “good”. The system does what it does; it’s up to you to decide if that is useful to you.

Start with an existing system

To keep things slightly more focused, the starting point for this investigation will be a popular pool-based system from a game called Exalted. As written, this game does not use a roll and keep system, but it has a number of features that might be usefully implemented by changing it to a roll and keep system. Some of what follows might make a bit more sense if you know a bit about the world of Exalted, but you don’t really need to know the game to follow along. Some important ideas of the system, as written:

  • It uses pools of d10s.
  • It uses a large number of “traits” rated (mostly) one through five. Some of these are called “Attributes”, some “Abilities”, but there are other kinds as well.
  • Pool size for any given test is based on one Attribute, one Ability and, optionally, one “specialty” (rated zero through three).
  • Dice that roll a seven or higher generate a “success”.
  • Dice that roll a ten count as two successes.
  • One important trait is called Essence and is a very rough measure of “power level” in the game. Mortals have an Essence of one. Very powerful gods have an Essence of ten.
  • Player characters in the game are superhuman, typically with an Essence of two to five.
  • Players have access to magic that allows them to (among other things) manipulate dice in various ways. For example, they might spend “points” of this magic (called motes) to buy extra dice for a roll, etc.
  • Player characters can be different kinds of superhuman, each kind having their own “style” of magic. These different kinds are explicitly not equal in the game, with some being “more powerful” than others.
  • Everything in the game that can use dice pools can gain a few additional dice for a roll just by giving a cool description of what they are doing. This is called “stunting”, and can provide from one to three dice.
  • Everything in the game that can use dice pools also has a set a traits called Virtues. If they are really desperate, anyone can “channel” a Virtue to gain dice for a roll. This is costly, and can only be done a limited number of times.

Mutating into the roll and keep

Changing this system to a roll and keep system requires answering two questions. First, what determines the basic limit on how many dice are kept? Second, how is this limit manipulated? The way the world of Exalted works suggests some choices here. After some experimentation, the key really comes back to the notion of the different “kinds” of character mentioned above and how these are intentionally not equal. Also important is that most rolling will be using magic, so what happens to the rolls when they are augmented matters more often than how rolls without magic work. While there are number of possibilities here, the following accentuates the differences of the kinds of characters. What seems to work is:

  • As with the standard system, characters roll Attribute + Ability + Specialty.
  • Characters keep a number of dice equal to their Essence + 1. Note that this limit is intentionally on the low side, compared to the size of the pool. This has several ramifications but generally means that adjustments to the keep limit are more formidable than adjustments to pool size.
  • Stunting works as in the standard system, adding dice to the roll.
  • Virtue channeling adds to the number of dice you keep. (Also, for those who really know Exalted, in this system it does not cost Willpower.)
  • The different kinds of characters each have their own basic mechanism for manipulating a roll. (In Exalted terms, the following replace excellencies.) The names for the different types don’t matter so much, but are arranged by “power level”, from strongest to weakest:
    • Solars (and their offshoots) can spend 2m to buy one success, with a maximum of Ability successes added to a given roll.
    • Lunars, prior to rolling, can spend 1m to convert a pool die into a single success instead of rolling it, with a maximum of Attribute die so altered for a given roll.
    • Sidereals can pay a flat 3m to add one to the number of dice they roll, but count two successes for rolling 8 or 9 as well as 10.
    • Alchemicals can pay a flat 1m to raise the number of dice they keep by two. This can only be done once per test.
    • Terrestrials can pay 1m to add two dice to their pool. They may add up to Ability + Specialty dice to a given test.
    • Spirits, Fair Folk, Ghosts and other essence users can pay 1m to add one die to their pool, adding a maximum of Ability dice to a given test


For a particular test, a character uses an Attribute rated at 2, an Ability rated at 4 and a specialty rated at 1. This provides a dice pool of seven dice. The character has an essence of 3, which means, after the roll, she will keep four of those dice.

Her roll is an extremely good one: 2, 5, 8, 9, 9, 10, 10. She obviously elects to keep the best four dice, which are 9, 9, 10, 10. Each 9 gives one success. The 10s give two successes each. Her total is six success.

Later she needs to make a very similar test (based on the same traits). This time, though, she describes her action in a really neat way, and is awarded two stunt die. While this makes the pool larger, it doesn’t change how many dice she can keep. This roll happens to turn out worse: 1, 2, 4, 5, 5, 5, 6, 8, 10. She still keeps four (5, 6, 8, 10), gaining three successes (one for the 8, two for the 10).

Even later, she has to make the same kind of test again. This time she is in real trouble. She describes well again, gaining two stunt dice. She also channels one of her virtues (rated 3), which allows her to keep three additional dice. She rolls well again: 3, 5, 6, 7, 7, 7, 8, 9, 10. Thanks to the channel, she keeps seven dice (6, 7, 7, 7, 8, 9, 10) giving seven successes.

Running the numbers

The various choices were analyzed using software simulation, written in Python (source). The simulation makes a million rolls using 30 dice each. For each roll, the stream of dice is used by a bunch of different “strategies”. Each strategy represents a type of character, adjusting its traits and, importantly, kind. The strategies are set up such that they cover all relevant combinations. Each of these is fed the 30 dice results, but how many they actually use depends on the strategy. If a strategy is supposed to have a pool size of 12 dice, it only takes the first 12 dice for its pool and ignores the rest. By working in this way, all of the strategies use roughly the “same” results for their million rolls. This is not exact, of course, as some strategies use more dice than others, but it provides a more “fair” comparison of the strategies (and is much faster than rolling pools independently for each strategy a million times each).

What turns out to be interesting here are graphs where the traits are kept constant, but the various magical effects are used to the full extent allowed (that is, solars always buy Ability successes, etc.). You can see from these how the magic works at each sort of “skill level”. (It is also illustrative to show how the “canon” system works. That is, the system that doesn’t use a roll and keep mechanism, but rather always keeps all dice.)

Consider characters at Essence 3, but with minimal traits. At this level, the results are fairly homogeneous, and the magic doesn’t change much:

Essence 3, Att 1, Abl 1, Spec 0, Stunt 0, Virt 0

One thing to notice, though it doesn’t show on the graph very well, is that with their additional dice, terrestrials and spirits can occasionally get lucky enough to exceed the maximum achievable by a solar (about an 0.1% chance of getting six successes, while solars can only hit five), even though they do worse on average. This result will hold in any situation where the keep cap exceeds the standard pool size, which doesn’t happen that often. With traits this low, however, it still happens with virtue channeling/stunts:

Essence 3, Att 1, Abl 1, Spec 0, Stunt 2, Virt 3

One oddity you see emerge here is that the because of the way sidereal magic works, they are more likely to get even numbers of successes than odd.

When traits move to 3 dots each, you can see another emergent behavior: when the base pool and the cap become close, without magic the basic “roll and keep” behaves very similarly to canon, but magic causes the various types of exalts to have much different expectations of success:

Essence 3, Att 3, Abl 3, Spec 0, Stunt 0, Virt 0

Essence 3, Att 3, Abl 3, Spec 0, Stunt 2, Virt 3

Also note the “canon” line in the graphs above. Bear in mind this is just a standard roll in the original system, without any magical augmentation. Since each die can possibly generate two successes (by rolling a 10), Exalted has a bigger issue with “runaway successes” than most other pool based games do. The “roll and keep” tends to keep runaway successes under the original system more constrained, with magic use having a bigger impact than luck.

Things get more interesting when you ignore the virtue channeling and add only some additional dice, say from a stunt or specialty. Since these two cases are mostly the same (the only difference being that three dice from a specialty help terrestrials more than three dice from a stunt would), we’ll look at the specialty case:

Essence 3, Att 3, Abl 3, Spec 3, Stunt 0, Virt 0

Here, you can really see how the excellency differences play out:

  • Solars are simply “more excellent” than the others, but since they are limited in how many successes they can buy, not overwhelmingly so. This is a departure from the canon rules, were the gap between solars and others can be severe.
  • Lunars have the same minimum and maximum successes as solars, but average one fewer success. Still they outshine other types.
  • Sidereals leave much more up to luck, but still regularly hit celestial levels of success. Their minimum is much lower than solar and lunars (they can still actually get zero successes), and their max is slightly lower, but they have a much flatter curve, that favors the high end.
  • Terrestrials, unlike celestials, can’t gain more with magic than without, but are much more likely to hit the high end of their range.
  • Alchemicals most closely match the canonical curve. They can do better than even solars, but not very often.
  • Spirits are similar to, but outmatched by, terrestrials.

As the traits climb to five, all of these trends become more accentuated, and the higher powered exalts make better use of their increased skill:

Essence 3, Att 5, Abl 5, Spec 3, Stunt 0, Virt 0

When you add stunts and channeling to mix, however, the odds tend to even out a bit, particularly for those in the mid power range:

Essence 3, Att 5, Abl 5, Spec 3, Stunt 2, Virt 3

Higher Essence

As Essence increase to five (the realistic upper limit for PCs in most games), the keep limit becomes less relevant, particularly at average skill levels, because you are keeping nearly all of the dice you roll. You start to see a more canonical behavior of the magic:

Essence 5, Att 3, Abl 3, Spec 0, Stunt 0, Virt 0

Once traits are maximized, however, the disparity between pool size and limit cap returns, and the difference between the types of characters become more pronounced:

Essence 5, Att 5, Abl 5, Spec 3, Stunt 0, Virt 0

The low end

One thing that turns out to matter a lot in this analysis (and the reason Exalted is being used as a base) is the notion that rolling a 10 generates two successes. This mixes in interesting ways with the keep limit. Obviously, 10s are much more worth keeping but, more importantly, they allow the success count to exceed the keep limit. That is, even if you can only keep two dice, it’s possible to get four successes. Further, the more dice you roll, the more likely that outcome is.

For example, if you roll only two dice and keep both, the chance of getting four successes is only 1% (with a 34% chance of failure). If, however, you roll 12 dice and keep two, the chances of four successes is closer to 35% (with the chance of failure dropping to around 0.2%). So, the limit and the 10s rule combine to reign in the number of total possible successes, but yet still let skill matter.

This is easier to see when looking at the results for the low end of the power scale: Essence 1 characters. Since mortals can’t use magic (and everyone that can use magic has Essence 2 or more), graphs at this level are more simple. At this level, it is a bit more useful to look at how the roll and keep results change the dynamics of the game compared to the canonical system.

One twist here is that Exalted divides mortals into two groups: standard mortals and heroic mortals. The difference is that, for standard mortals, rolling a 10 only generates one success. This changes things a lot for them. (If you suspect that mortals are a bit screwed in the world of Exalted, you’d be totally right.)

Let’s look at a minimal mortal, with all traits at one. Since the keep limit equals the number of dice, this works just like canon, so is not particularly interesting, but consider when this character stunts:

Essence 1, Att 1, Abl 1, Spec 0, Stunt 2, Virt 0

Heroic mortals cannot do better than four successes here, even with the stunt, because stunting doesn’t change the cap. The standard mortal can only get two successes in this situation. Compared to not stunting, the difference for the standard mortal is a drastic increases the likelihood of getting two successes (from around 16% to 53%), and decrease the chance of failure (from 36% to 13%).

You can also see how, compared to canon, the 2+ success results are “compressed” into a lower range.

But what if, instead of stunting, they channel a virtue (rating 3)? Looks like this:

Essence 1, Att 1, Abl 1, Spec 0, Stunt 0, Virt 3

Under r&k, the mortals still can’t crack four and two successes, respectively. In this case, the culprit is the size of their dice pool. Their keep limit is over twice the size of how many dice they actually can roll. The canon case has much different behavior here, as it is rolling five dice instead of just two.

Channeling a virtue in this situation is much worse for the mortal than a stunt. This turns out to be more of a fringe case, but it has an interesting effect: mortals simply cannot do “legendary” things, unless they both stunt and channel. Or, put another way, it is possible for even the weakest mortals to do awesome things if they stunt like hell and pour their heart into it:

Essence 1, Att 1, Abl 1, Spec 0, Stunt 2, Virt 3

You can really see the divergence from canon here. Compare standard mortals in canon to heroes in r&k, for example. In this case, canon mortals gain 7 successes 3 times out of every two thousand rolls. Heroes in r&k don’t do this as often, though they can get 8 successes while standard canon mortals can’t (meanwhile, canonical heroes can get as many as 14). Note that standard r&k mortals still cannot achieve “legendary” successes, though they could with a higher virtue.

As mortal traits increase, the result of raising their attributes doesn’t affect their success caps, but moves their results more reliably to the higher end of that cap:

Essence 1, Att 3, Abl 3, Spec 0, Stunt 0, Virt 0

Essence 1, Att 3, Abl 3, Spec 0, Stunt 2, Virt 3

Essence 1, Att 5, Abl 5, Spec 0, Stunt 0, Virt 0

Essence 1, Att 5, Abl 5, Spec 0, Stunt 2, Virt 3

So, on the low end, this system seems to at least function, and does a fairly good job of “keeping the man down”. Can’t have mortals get too uppity. With enough stunting and heart, they can still do “legendary” things.


While initially intended to be a somewhat generic look at how you might manipulate a roll and keep system, the results actually turn out to depend heavily on the specifics of the original system used, particularly the rule that awards two successes on a 10.

On the other hand, if you consider the specific flavor of the game in question, you actually can use roll and keep to make the game work a bit more like it is described. That is, with some minor mechanical changes, the success rate of the various kinds of exalted can be tinkered with until they match the relative power levels implied by the game’s descriptions, all in a way that minimizes the huge success disparity of the original system.

Making d20 SRD spell cards using XSL and FOP

Some popular, rules-heavy roleplaying games can benefit from reference cards, where all the information about a specific item is printed on a small card, allowing each player to have a stack of cards specifically for the rules she cares about. This post deals specifically with creating such cards for spells, one per card. While you can spend six bucks on a spell card PDF to print out at your own expense and cut with a paper cutter, why do this you can spend ten bucks to buy Avery® business cards and build the output yourself?

This post acts as a how-to describing how you can build such cards yourself, should the muse strike you. More generally, it demonstrates how you can use two different but complementary XML-based technologies (XSLT and FOP) to format output for Avery business cards, mailing labels, etc. from an XML data source. An assumption is made that you know what XML is and have enough technical chops to install and setup the various technologies involved.

Formatting Objects Processor

The Formatting Objects Processor (FOP) is a free, cross-platform technology from Apache. It claims to be “driven by XSL formatting objects (XSL-FO)”. All this really means is that it makes use of a specific XML format called XSL-FO, which is built to represent printed page layout. FOP can read in this format and render it into a wide variety of output, including text, PostScript and the format we’ll be using here, PDF. The XSL-FO standard has enough in common with HTML that its basics are fairly simple to pickup if you know that language; however, it is more complicated and much more accurate, capable of millimeter-level control over the output.

In principle, all you need to to use FOP is a source file written in XSL-FO markup. Nearly every demo you’ll find on the web uses the same mechanism of generating this source that we will (XSLT, see below); however, FOP really doesn’t care where it comes from. Keep in mind that it’s just an XML file, so you could just as easily, say, build the XSL-FO with a Perl script or even by hand. Typically, you will also have some source of data in hand, such as a database or text file. In our case, we have some XML data in a totally different format.

The d20 Standard Reference Document in XML

The d20 game uses a (mostly) open standard, based around the d20 Standard Reference Document. Fortunately for us, an enterprising soul named Andargor has gone through the trouble of translating this SRD into XML and some other data-based formats. His XML files use a fairly straight-forward format of his invention. This format, of course, is pure data and nothing like the XSL-FO layout format. Nor should it be. So, what we need is something to translate the d20 XML into the XSL-FO markup describing the page layout we want.

Extensible Stylesheet Language Transformations

Many paths exist to convert the d20 XML into XSL-FO. Python scripts, Java, heck even sed. We’re using a technology meant to transform XML input into some other kind of output (usually XML, HTML or text) called the Extensible Stylesheet Language (XSL). XSL is yet another special XML format geared towards matching XML data and transforming it. (It is, believe it or not, turing complete.) It makes heavy use of a standard called XPath, which is a funky query language for specifying exact subsets of nodes within an XML document. Though XPath looks nothing like SQL, it is similar in purpose, except querying a hierarchy tree instead of relational tables.

An XSL transformation (XSLT) is specified in an .xsl file. Typically, such files are very specific, written exactly for the combination of data type being transformed and output format being written. That is, the XSL file we use here is specifically for turning the d20 SRD XML format into XSL-FO formatted for Avery business cards. If you need to change either end of this, you should make a copy of the file and mutate it into a new transformation that does what you need.


We need some kind of tool that allows a two-step workflow (or knows how to combine the two steps into one). First, we convert the d20 SRD XML data into XSL-FO using XSLT. (That’s a lot of acronyms.) Second, we take the result of that and feed it into FOP to build our PDF. The four files are involved are:

  1. spells.xml – The d20 XML data containing all the spells in the SRD.
  2. spellcards.xsl – The XSLT to do the translation into XSL-FO.
  3. – The XSL-FO generated by the transformation.
  4. spellcards.pdf – The final PDF file.

A number of tools exist to do this. I happen to use oXygen, as it combines everything needed to run this process into a single step, and also functions as a very good XML and XSLT editor. It’s a powerful tool, but pricey. Stylus Studio costs even more. Some less feature-rich alternatives might be TestXSLT. If you want to go the Java route, your best bet is to download the recent FOP package, which contains the Xalan XSLT engine and a command line to use it. If you know of other tools, leave a comment with a URL.


Once you have the tools picked out, download the XML d20 SRD and find the spells.xml file. Now, take a look at the transformation file. It is fairly well commented. Save a copy of it to your local drive as your spellcards.xsl file. Now tell your tools to use spellcards.xsl to transform spells.xml into, then channel it into FOP.

If using oXygen, do the following (note, there may be some changes between versions of oXygen, so this may not be exact):

  1. Open the two files.
  2. Make spellcards.xsl the active document and select the menu “Document → XML Document → Configure Transformation Scenario”.
  3. In the dialog that comes up, click “New”.
  4. Name the scenario “spellcards” or something similar
  5. In the dialog’s “XSLT” tab, set the “XML URL” to your local copy of spells.xml. You should be able to leave the other settings alone on this tab.
  6. In the dialog’s “FO Processor” tab, check “Perform FO Processing” and make sure the “XSLT result as input” is selected. You want to use the “pdf” method and the built-in FOP.
  7. In the dialog’s “Output” tab, click the “Save As” radio button and provide a place to save the spellcards.pdf file. Click the “Open in browser” checkbox and the “Saved file” radio button.
  8. Click OK to close the dialog.
  9. Back in the “Configure Transformation Scenario” dialog, you can click “Transform Now” to test out your settings.
  10. Hopefully, you should be looking at a PDF now. If you need to run the transformation again, you can hit the big red “play button” toolbar icon (which is called “Apply Transformation Scenario”).

If you are using the command line tool that comes with FOP instead of oXygen, the command you need should be something like this:

fop -xml spells.xml -xsl spellcards.xsl -pdf spellcards.pdf


Once you have the PDF created, make a test print of one of the pages. Put this page behind one of the Avery business card pages and hold it up to the light to see how it lines up. Every printer feeds slightly differently, so you may need to tweak the measurements slightly to align the cards just right. You do this by altering the spellcards.xsl file.

Search this file for the word “tweak”. You’ll find a couple, which identify spots in the file that measurements can be altered. One place is the margins for the whole page. The other is the padding within a table cell. Adjust these until your test page lines up with the Avery labels. Once this all works, print out a test page on the Avery label paper. Hopefully it will still match up. If not, tweak again. Once it works, print them all.

Note, the measurement tweaking locations (as well as some nearby tags) within spellcards.xsl can be altered more radically to support other types of Avery pages, such as index cards or mailing labels.


You may not want to make cards of every single thing in the spells.xml file. You can use different XPath statements within the spellcards.xsl file to select subsets of the data. There are two logical places to do this in the file, both of which can be found by searching for “filter” in the text.

The primary location is the select of the main apply-templates tag. In the file, there are a half-dozen or so alternate examples for this statement that you can use. Just comment out the first one and uncomment the one you want. You should be able to find a statement close to what you want and alter it to taste.

For more exotic filtering, there is a very slim chance that you what you want can’t be done in the main select. You can, instead, examine each spell as it comes through and make more complicated tests. The transformation file contains a skeleton to do such filtering, but always lets everything through. You’d need to change this to set include to true.

Filtering this data is harder than it could be, because the level tag in the spells.xml file is a string that combines all of the level information into a single field, rather than more structured data. For example, if a line like:

<level>Cleric 6, Druid 6, Sorcerer/Wizard 6</level>

…was instead…


…it would be a lot easier to do more powerful XSLT filtering and sorting.

First Age mosaic map released

In the game of Exalted, there was a long past First Age, when everything was awesome (except for the growing psychosis of the demigod rulers of the place) and Creation was much larger. No maps had been produced of this time, but DivNull has released one to Lore 5, created as if it were a tile mosiac that might be found in a tomb or ruined palace.

This was a raster project done in Photoshop, with much of the heavy lifting done by a demo of Xenofex. This could be improved in a number of ways, particularly by adding a bit more depth.

Taking on Mac building duties for Anathema

AnathemaDivNull Software has become responsible for building the Mac OS X release of Anathema, a java-based manager for the Exalted role-playing game. The job consists of turning a Java application in a double-clickable Mac app.

While much of Anathema is not particularly Mac-looking, DivNull will work to make it more so. A post on an Exalted-based forum tracks problems found during the process so far, and their solutions.

Old English name list for Omnihedron

OmnihedronAfter asking for, and quickly receiving, permission from both the author and Wizards of the Coast, an Omnihedron conversion of Jay Treat’s tables to generate character names using Old English roots and meanings is now available. Mr. Treat’s tables appeared in issue #72 of Dragon Magazine. The tables implemented by this file are ©Wizards of the Coast and are used by permission.

This data set highlights some of Omnihedron’s more subtle power, as the tables follow an interesting logic. There are different tables for the start and end of the name being generated; however, you roll on the table for the end first. Some, but not all, of the end results can also be used in the start of a name. If you hit one of these entries, you make a random roll to see if you use it as the start or the end, and then fill in the rest with a roll on the other table. While most “list rolling” software wouldn’t be able to do this, Omnihedron handles it easily.

The lists may be downloaded on the Omnihedron lists page.