# Random selection from a set of arbitrary size?

I'm new to Dungeons and Dragons in general, and none of my friends have played before either but we were looking to start a campaign (still flipping back and forth between 3.5 and 5, I think 5 sounds more fun but some in my group think 3.5 looks simpler).

In an effort to make the campaign unique I started looking at items and abilities I could create, and one idea won't leave my head though I can't think of how it would be implemented in the system without some assumptions that I'd rather not make.

The idea originally came when I was looking at 5e's sorcerer wild magic surges. I was thinking it would be neat if there was an item or enchantment that could pull one random spell from a player's remaining spells and force them to use it. The problem is how do you pick which spell to use when the number of spells may not line up easily with a die roll (such as 4,6,8,10,12,20).

Is there a typical method for doing something like this without a lot of confusing rolls, or should I just try to avoid this situation entirely? I'm really curious if this sort of mechanic has any precedent and if so if it has worked out for other people.

• The discussion of which of D&D 3.5e or D&D 5e is more recommendable/simpler has been moved to chat. – SevenSidedDie Mar 30 '16 at 6:57
• Minor nitpick about semantics. You're not really dealing with a set of 'unknown' size. What you have is a set of known but variable (though generally fairly constrained) size. Solving the problem for a set of an unknown (and/or arbitrarily large) size is actually quite hard. – aroth Mar 30 '16 at 13:45

Try an online die roller. Google "rpg online dice roller". Many allow you to specify an arbitrary n-sided die.

For instance, rolz.org allows you to specify an arbitrary n-sided die and roll it in like 1d3 seconds.

Or, as some have suggested, just reroll if the dice show a combination too high for your number of items.

I will second (or third or fourth) the suggestions for 5e in general and for playing it straight-out-of-the-box the first time around. There is even a starter kit that has dice, basic rules, and a starter adventure.

Good luck!

• Or get a dice roller app for your phone and use that. – Ilmari Karonen Mar 30 '16 at 11:01
• I would recommend random.org for online random-number generation. Pseudorandom values are sufficient for RPGs, but why not get the best you can? – Passage Mar 30 '16 at 17:02

Plenty of spells in 3.5 have random effects based on a die roll; they’re just designed with a number of possibilities that maps neatly onto a die (often a d8, for a reason that’s about to become clear). For example, see prismatic spray, or really any of the spells with “prism” in the name (hence the tendency to use a d8, with seven options matching the colors of the rainbow, and a roll of 8 getting you the ability to roll twice).

But to truly allow for arbitrary-sized sets, the answer is to not use dice at all. Instead, what you want are cards. The crusader from Tome of Battle uses this approach, and Wizards of the Coast published maneuver cards on their website that you could print out. The crusader gets to “ready” a certain number of maneuvers, but only a subset of these is “granted” at a time, while the rest are “withheld.” To determine which were granted and which were withheld, cards with the names (and, potentially, the entire description) of the readied maneuvers are shuffled in a deck, and you draw cards equal to the number of granted maneuvers. For the crusader, additional maneuvers were granted each turn, so he kept drawing cards, until the deck was empty, at which point all the cards were re-shuffled (“recovering” the manuevers) and a new set of granted maneuvers were drawn, repeating the process.

This worked extremely well for the crusader. Part of its success, however, is that the crusader could control the “deck” that the cards were drawn from, because he could choose which maneuvers to ready, and also that in the worst case he still had 40% of his options available, and the remaining 60% would become available over the next few rounds so nothing was “missed.” This dramatically improved the play of the class; it’s one of my favorites.

A wild-magic sorcerer could be made along similar lines, potentially. The exact details of doing so well would take quite a bit of careful thought, a bit of mathematical modeling, and quite a bit of testing to get right, but I could see it working.

On a complete tangent, 5e is widely lauded as being much simpler to learn and play than earlier editions of D&D. As it turns out, 3.5e is actually an extremely complicated, well, mess. And I say this as a pretty big fan of 3.5e that plays the system and/or its spin-off Pathfinder almost exclusively.

• I think the hardest part of the question—which isn't addressed in this otherwise excellent answer—is the part wherein the caster is forced to cast the randomly determined spell. The crusader's got it easy because his random effects are all hit things!, but when random chance means wasting a turn casting anything from, for example, illusory script underwater to lightning bolt at a blue dragon to magic circle against good while surrounded by demons, I can't see anyone having fun playing such a variant. – Hey I Can Chan Mar 29 '16 at 22:53
• @HeyICanChan That is why I emphasize the concept of getting to choose what the set is. Perhaps this sorcerer would be able to set up a few different categories: Offense, Defense, Utility, perhaps, for a really bare-bones example? But ultimately I felt that implementation was beyond the scope of this answer (or really, anything on this site). – KRyan Mar 29 '16 at 23:11
• I've once conceived a Wilder Magic Sorcerer that would get a random list of spells he can use each day (or upon DM request). I've made myself a web app to generate that list. Drawing cards from a shuffled deck sounds so much simpler and I'm ashamed of not having thought of it myself... Especially since I've already printed out all the spell cards... – DaFluid Mar 30 '16 at 12:59

When the available options can vary a lot, the quickest and easiest way to pick a random item from the options is to count them, pick any single die with the higher number of sides than the available options, roll that, and if the output goes over the maximum number of items, simply roll again.

So a quick example, to pick a random spell for a Wizard with the following slots still available:

• 0st: Light, Detect Magic
• 1st: Magic Missile, Mage Armor
• 2nd: Bull's Strength
• 3rd: Fireball, Lightning Bolt

You count 7 options. You pick a die with more sides, so a d8. You roll the die. If you get a 5, you pick the 5th spell from the list (that is, Bull's Strength). If you roll an 8, simply roll again.

This has the advantage of not having to prepare anything beforehand and works quite well for lists with quite a few items.

• Or get a d30. – SevenSidedDie Mar 30 '16 at 3:33
• @Erik that isn't uniformly distributed. To look at a simpler example consider rolling 2d6 vs rolling 1d12. There is a 1/12 chance of getting a 12 on 1d12. However, you need both 2d6's to come up 6 to get a 12 on 2d6, so the probability is 1/36. You could use 2 d10s to simulate a d100 by letting one choose the first digit and the other choose the units digit. This has 1/10 chance for each tens digit and 1/10 for each units digit, making each value have 1/100 which is what you want from a simulated d100. – Thoth19 Mar 30 '16 at 4:15
• @Thoth19 In Eric's example d3 is the tens die and d10 is the units die. – Tommi Mar 30 '16 at 5:31
• As a side note, this method is called "Rejection Sampling". en.wikipedia.org/wiki/Rejection_sampling – Jens Mar 30 '16 at 10:43
• For a list of 21 spells, you could also roll a d3 and a d7 using the formula: 7*(d3-1)+d7 – Dan Henderson Mar 30 '16 at 15:11

I've done some quick maths for you because it interested me enough.

The general rule with getting a random number with set dice which falls between the maximum values of your dice, is to simply re-roll any result which is higher than the maximum number you want.

Example: You want a number between 1 and 18, you roll a d20 and re-roll any results of 19 or 20.

This still means that each result is just as likely to come up as another.

This doesn't help much if you want a number between 1 and 22, as you'd have to roll a d100 and you're likely to have to keep re-rolling time and time again.

I've produced some steps between 20 and 100 (non-inclusive) which you can get random rolls for:

16 > (1d4-1) *4  + 1d4
24 > (1d4-1) *6  + 1d6
32 > (1d4-1) *8  + 1d8
36 > (1d6-1) *6  + 1d6
40 > (1d4-1) *10 + 1d10
48 > (1d4-1) *12 + 1d12
60 > (1d6-1) *10 + 1d10
72 > (1d6-1) *12 + 1d12
80 > (1d8-1) *10 + 1d10
96 > (1d8-1) *12 + 1d12


This works as follows:

If you need a number between 1 and 55, you pick the next highest (in this case, 60 > 1d6-1 *10 + 1d10). You roll 1d6-1, multiply it by 10 and then add 1d10.

If you get a higher number than 55, then re-roll the whole thing. It's important that you don't just re-roll the 1d10.

This will get you even likelihood results and isn't as tricky nor time consuming as it looks. I'll admit, it still leaves the possibility of re-rolls, but it reduces them considerably.

• It might be best to put parentheses around your 1dx-1's. And an extra space before the + on the first 4 lines wouldn't hurt. :) – Dan Henderson Mar 30 '16 at 15:14
• @DanHenderson +1 You're absolutely right. Thanks! – Matthew Mar 30 '16 at 18:24

You can use a deck of cards and assign each spell to a card. You could also use dice other than d10 in the same way as d10 are used to generate between 1 and 100 (or 0 to 99). A pair of d6 will generate numbers in base 6 and will go from 1 (6 and 1) to 36 (6 and 6), though numbers in other bases are less obvious and might be confusing.

You can also mix dice, a d4 and a d10 can generate 1 - 40.

Adding dice together will produce results that are peaked and weighted toward the center, so that's probably not what you're after.

• I suggest you replace "bell curved" with "peaked". Since this question is tagged statistics I'd expect readers to have a higher-than-usual bar for mathematical precision, and the adding of two dice yields a piecewise-linear probability distribution rather than a Gaussian. – nitsua60 Mar 29 '16 at 21:39
• Won't it become a Gaussian in the limit as number of (identical) dice increases? – Thoth19 Mar 30 '16 at 4:17
• @Thoth19 The limit of (suitably normalized) sum of independent and reasonable random variables is the normal distribution; this is the central limit theorem: en.wikipedia.org/wiki/Central_limit_theorem . (The limit is in the sense of convergence in distribution.) Any finite sum of discrete r.v. is still discrete and hence not normally distributed. – Tommi Mar 30 '16 at 5:36