D&D Dice NoteBook
- To: mathgroup at smc.vnet.net
- Subject: [mg38011] D&D Dice NoteBook
- From: "AngleWyrm" <no_spam_anglewyrm at hotmail.com>
- Date: Mon, 25 Nov 2002 01:58:16 -0500 (EST)
- Reply-to: "AngleWyrm" <no_spam_anglewyrm at hotmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Hey, For anyone interested, I've done some handy work on Dungeons & Dragons dice math. This notebook creates a table, lookup function, and accompanying graph for any dice combination! Good for the over-zelous DM :) Just copy all the text below, and paste/interpret into mathematica -:|:- AngleWyrm Notebook[{ Cell[BoxData[{ StyleBox["Dice", "Title"], "\[IndentingNewLine]", StyleBox[\(\(Dungeons\ &\)\ Dragons\ Dice\ Math\), "Subtitle"]}], "Input", CellFrame->{{0, 0}, {2, 0}}], Cell[BoxData[{ \(The\ formula\ for\ any\ homgenous\ dice\ combination\ \(is : \ \((\[Sum]\+\(i = 1\)\%sidesPerDie x\^i)\)\^numDice\)\), "\n", \(The\ polynomial\ expansion\ of\ this\ expression\ lists\ the\ number\ \ of\ occurances\ of\ every\ possible\ combination . For\ instance, with\ 3 \( \(d6\)\(:\)\)\)}], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(TraditionalForm\`Expand[\((\[Sum]\+\(i = 1\)\%6 x\^i)\)\^3]\)], "Input", FontSize->16], Cell[BoxData[ \(x\^3 + 3\ x\^4 + 6\ x\^5 + 10\ x\^6 + 15\ x\^7 + 21\ x\^8 + 25\ x\^9 + 27\ x\^10 + 27\ x\^11 + 25\ x\^12 + 21\ x\^13 + 15\ x\^14 + 10\ x\^15 + 6\ x\^16 + 3\ x\^17 + x\^18\)], "Output"] }, Open ]], Cell["\<\ The power of x represents the die totals, and the coefficient lists the \ number of ways to achieve that total. Let us make a useful function to \ extract the coefficient of any dice roll, given the number of dice, and the \ sides per die:\ \>", "Text"], Cell[BoxData[ \(Chances[\ numDice_, \ sidesPerDie_, \ roll_] := Coefficient[\((\[Sum]\+\(i = 1\)\%sidesPerDie x\^i)\)\^numDice, x\^roll]\)], "Input"], Cell[BoxData[ \(For\ instance, with\ 3 d6, \ how\ many\ ways\ \((out\ of\ 6\^3 = 216)\) are\ there\ to\ get\ a\ \(\(13\)\(?\)\)\)], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Chances[3, 6, 13]\)], "Input"], Cell[BoxData[ \(21\)], "Output"] }, Open ]], Cell[TextData[{ "Which can be confirmed by looking at the coefficient for ", Cell[BoxData[ \(TraditionalForm\`x\^13\)]], "in the polynomial expansion of ", Cell[BoxData[ \(TraditionalForm\`\((x + x\^2 + x\^3 + x\^4 + x\^5 + x\^6)\)\^3\)]], " above. Let us create a table, listing in order:\nRoll, Chances, \ PercentageChance, and Frequency:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(die = 3; \ sides = 6;\), "\[IndentingNewLine]", \(Table[\ {i, Chances[die, sides, i], \ N[Chances[die, sides, i]\/sides\^die], sides\^die\/Chances[die, sides, i]}, \ {i, die, \ die\[Times]sides}] // TableForm\), "\[IndentingNewLine]", \(ListPlot[\ Table[{i, \ Chances[die, sides, i]}, {i, die, \ die\[Times]sides}]]\)}], "Input"], Cell[BoxData[ TagBox[GridBox[{ {"3", "1", "0.004629629629629629`", "216"}, {"4", "3", "0.013888888888888888`", "72"}, {"5", "6", "0.027777777777777776`", "36"}, {"6", "10", "0.046296296296296294`", \(108\/5\)}, {"7", "15", "0.06944444444444445`", \(72\/5\)}, {"8", "21", "0.09722222222222222`", \(72\/7\)}, {"9", "25", "0.11574074074074074`", \(216\/25\)}, {"10", "27", "0.125`", "8"}, {"11", "27", "0.125`", "8"}, {"12", "25", "0.11574074074074074`", \(216\/25\)}, {"13", "21", "0.09722222222222222`", \(72\/7\)}, {"14", "15", "0.06944444444444445`", \(72\/5\)}, {"15", "10", "0.046296296296296294`", \(108\/5\)}, {"16", "6", "0.027777777777777776`", "36"}, {"17", "3", "0.013888888888888888`", "72"}, {"18", "1", "0.004629629629629629`", "216"} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], (TableForm[ #]&)]], "Output"] }, Open ]] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, WindowToolbars->"EditBar", WindowSize->{972, 572}, WindowMargins->{{0, Automatic}, {Automatic, 14}} ]