Dice math
From Verge
This is for the Verge RPG.
I have been experimenting with Professor Torben Mogensen's Roll program, found on his home page, to calculate dice probabilities for Verge's Signal & Noise dice system, based on the frequency of the mode — that is, the number of dice in the most commonly occurring value, so if you roll 1 2 2 2 3 4 4 5 6 6, the result is 3 since there are three 2's and 2 is the most commonly occurring number. The dice system allows for rerolls under certain circumstances.
I'm trying to determine how to scale the game's Trait values and set some critical constants in the system. I can't do that without understanding the probability of certain results occurring. Thus, I found this dice program, which calculates and outputs the probabilities of arbitrarily complicated dice systems.
I put up a copy of the Roll Manual (PDF) on my web site, in case you want to peek at it without downloading the entire kit.
Signal & Noise Dice, First Roll
The following graph shows the occurrence of various results using 1 to 20 dice (d6es) and the Signal & Noise dice method. This method counts the most commonly occurring dice (frequency of the statistical mode).
Note that the stacked bar graph may not add up to 100 for the larger numbers of dice because only results of 9 matching dice or lower are shown. The occurrence of matching 10 or more dice (even on 20d6) is so low that it is not worth displaying. For 20d6, the chance of matching 10 or more dice is 0.359 percent and matching 11 or more dice is 0.063%.
Note that when you roll 7 or more dice, you necessarily match 2 or more dice. When you roll 13 or more dice, you necessarily match 3 or more dice.
Here's the program I wrote for it:
\ roll Signal & Noise with no rerolls let sides = 6 in let pool = N # d sides in largest 1 (foreach face in 1..sides do count (=face pool))
This finds the frequency of the mode for N d6. I called the program repeatedly, passing in N each time:
roll.exe signal_noise_freq.d 0 N=1
roll.exe signal_noise_freq.d 0 N=2
roll.exe signal_noise_freq.d 0 N=3
...
A run of the program produces output like this:
> roll.exe signal_noise_freq.d 0 N=5
Value Probability for = Probability for <
1 : 0.0925925925926 0.0
2 : 0.694444444444 0.0925925925926
3 : 0.192901234568 0.787037037037
4 : 0.0192901234568 0.979938271605
5 : 0.000771604938272 0.999228395062
Average = 2.1412037037 Spread = 0.591320792373
They don't start getting slow till the 12-15 range. N=20 takes a minute or two.
Signal & Noise Dice, One Reroll
Tonight I extended the program to calculate results for Signal & Noise dice with one reroll. I set up a DOS 'for' loop to execute the program with N=1 to N=20 and save the results in a text file. Something like this:
> for %n in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) do roll.exe 0 N=%n >> rolls.txt
I started the program at 9:30 PM last night and it's still running now at 9 AM the next morning. It's on N=17, so I expect it to run through this evening. It has my PC's CPU pegged at 100%.
The problem is that it has to do all the same work from the last set of dice (without the reroll), and it has to 'explode' the results of each roll to another combination of rolls. Essentially, where it was O(N^2) before, it's now O(N^4). Here's the code:
\ roll Signal & Noise with no rerolls \ choose the MODE automatically (if there's more than one mode value, choose the highest) \ initial roll let sides = 6 in let pool = N # d sides in let freq = largest 1 (foreach face in 1..sides do count (=face pool)) in let mode = largest 1 (foreach face in 1..sides do (if =freq (count (=face pool)) then face else 0)) in \ 1st reroll let reroll = (N-freq) # d sides in let matchfreq = count (=mode reroll) in freq + matchfreq
I wish there was a simpler way to calculate the mode. I suppose I could brute-force check 1..6 and keep the largest. I don't know that that would be faster, though. I will run some tests after my sequence finishes running.
Here's what the graph of the results of one reroll look like:
I'll update this page with results once I have them. Also, I've started the analysis of the results and I'll post my thoughts here eventually.
Analysis
| dice | occurrence (%) | |||||
|---|---|---|---|---|---|---|
| pool | of 1 | of 2 | of 3 | of 4 | of 5 | of 6 |
| 2 | 83% | 17% | ||||
| 4 | 28% | 62% | 9% | ~0% | ||
| 6 | 2% | 63% | 31% | 4% | ~0% | ~0% |
| 8 | 30% | 52% | 15% | 3% | ~0% | |
| 9 | 17% | 56% | 22% | 4% | 1% | |
| 10 | 7% | 53% | 31% | 7% | 2% | |
| 11 | 3% | 44% | 39% | 11% | 3% | |
| 12 | ~0% | 35% | 43% | 17% | 4% | |
I marked off the "sweet spots" on both diagrams. These are the zones (by number of dice rolled) that produce "interesting" results. By interesting, I mean that there's a suitable range of results possible (and probable). Rolling 2 dice isn't very interesting because there are only two results: 1 (83%) and 2 (17%). Rolling 4 dice still isn't very interesting because you roll 1-2 91% of the time and a 3 almost 9% of the time. The 8-12 dice range sits neatly in the middle of the S-curves. Rolling 8 dice, you have four likely results: 2 (30%), 3 (52%), 4 (15%), or 5 (3%). Rolling 10 dice, those options change to: 2 (7%), 3 (53%), 4 (31%), and 5 (7%) and there's a small (2%) chance of getting 6 successes. Rolling 12 dice, the 2 option drops nearly out, and the other results come out to: 3 (35%), 4 (43%), 5 (17%), and 6 (4%).
With a single reroll, the results essentially shift up about 2 points. Figure that, on average, you'll add 1 out of every 6 rerolled dice to the result. When rerolling 2 dice, chances are 30% that at least one of them will match your result pool. That chance increases to 42% with 3 dice, 52% with 4 dice, and 60% with 5 dice.


