Tuesday 15 May 2012

Simulating a dX

I've been thinking for a few months about how to best simulate rolling a dX, which is the same as indexing X entries randomly. It takes time to sort ideas and thoughts out; this is a starting point for collecting things together.

There are six standard polyhedral dice: d4, d6, d8, d10, d12 and d20. When using these we assume that the dice are fair - each side is equally likely to come up. If we were to create or simulate a die with X sides it would be best if it were fair. We cannot simulate a d11 using 2d6 directly - we get a range of 11 possible values, but there are different probabilities for each value. The simulated die would not be fair.

We can simulate a few dice with the six standard polyhedral dice through either re-rolling on the high value, or by "halving the die". It is not too difficult to introduce simple notation to account for both of these actions.

d6/2 gives a d3. We let d6r stand for the situation where we reroll the 6. We only want values 1-5 so d6r results in a fair d5. However, d10/2 also gives d5, and without the reroll. From the standard polyhedral dice we can simulate the following dice easily:

d2 = d4/2, d6/3, etc.
d3 = d6/2, d12/4.
d5 = d10/2, d20/4.
d7 = d8r.
d9 = d10r.
d11 = d12r.
d19 = d20r.


We could also simulate a fair d9 by rolling two d3s; these act as indexing nine entries in a table. We could denote this with d3 x d3 or (d3)^2.

d3 x d3 1 2 3
1 1 2 3
2 4 5 6
3 7 8 9

These various actions - re-rolling, halving and dividing across tables - allow us to build up a greater number of simulated fair dice. I'll go into more detail in future posts, and see if I can start to make sense about how we might simulate a dX for any positive integer X.

2 comments:

  1. I like this, it has a mildly Sisyphan quality that suggests the RPG madness has truly begun to sink in.

    Why shouldnt you be able to generate a roll of ANY positive integer using only a bunch of rpg dice?

    ALL OF THEM. ALL OF THE INTEGERS.

    "Roll DX" sounds like an awesome part of a spell description.

    ReplyDelete
  2. It's the prime numbers that, in general, are going to be really awkward I think. I've worked things out up to d40, and a dX is not too difficult if you can get the X from multiplying quantities of 2,3,4,5,6,8,9,10 - but unfortunately that means there are lots and lots of numbers which don't fit that bill. So I have to think about a neat and tidy way of doing it.

    Which is quite fun actually.

    And yes, the madness is really settling on top of my psyche.

    ReplyDelete