dice_notation.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>&lt;no title&gt; &#8212; xdice 1.0.0 documentation</title>
  7. <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: './',
  12. VERSION: '1.0.0',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true,
  16. SOURCELINK_SUFFIX: '.txt'
  17. };
  18. </script>
  19. <script type="text/javascript" src="_static/jquery.js"></script>
  20. <script type="text/javascript" src="_static/underscore.js"></script>
  21. <script type="text/javascript" src="_static/doctools.js"></script>
  22. <link rel="index" title="Index" href="genindex.html" />
  23. <link rel="search" title="Search" href="search.html" />
  24. <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  25. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
  26. </head>
  27. <body>
  28. <div class="document">
  29. <div class="documentwrapper">
  30. <div class="bodywrapper">
  31. <div class="body" role="main">
  32. <p># Dice Notation</p>
  33. <p><em>Dice notation</em> is nearly fully understood by pydice.</p>
  34. <p>## Dice</p>
  35. <p>&gt; Following patterns can be passed to the Dice.parse() class method, and will then return the corresponding Dice object.</p>
  36. <p><strong>[See Wikipedia for a complete definition.](https://en.wikipedia.org/wiki/Dice_notation)</strong></p>
  37. <p>#### Bases</p>
  38. <p>Die rolls are given in the form AdX. A (amount) and X (sides) are variables, separated by the letter “d”, which stands for die or dice.</p>
  39. <ul class="simple">
  40. <li>A is the number of dice to be rolled (1 if omitted).</li>
  41. <li>X is the number of faces of each die.</li>
  42. </ul>
  43. <p>If the final number is omitted, it is assumed to be a twenty. (This can be changed trough the class property Dice.DEFAULT_SIDES)</p>
  44. <p>&gt; For example, if a game would call for a roll of d4 or 1d4 this would mean, “roll one 4-sided die.”
  45. &gt; <cite>3d6</cite> would mean, “roll three six-sided dice”</p>
  46. <p>Note: the <cite>D%</cite> notation is read as <cite>D100</cite></p>
  47. <p>#### Selective results</p>
  48. <p>This pattern can be followed by <cite>Ln</cite> and/or <cite>Hn</cite> expressions.
  49. ‘L’ and ‘H’ respectively stand for lowest and highest.</p>
  50. <p>In this case, the lowest/highest n scores will be discard when the dice will be rolled.</p>
  51. <p>&gt; <cite>3D6L1</cite> will roll three 6-sided dice, and drop the lowest, while <cite>3D6H1</cite> will roll three 6-sided dice, and drop the highest.</p>
  52. <p>If no number follow the ‘L’ or ‘H’, it is assumed to be a 1.
  53. ‘L’ and ‘H’ can be combined inside a single pattern.</p>
  54. <p>## Patterns</p>
  55. <p>&gt; Following patterns can be passed to the Pattern.parse() class method.</p>
  56. <p>#### Bases</p>
  57. <p><cite>AdX</cite> notations can be integrated in complex expressions.</p>
  58. <p>Any mathematical expression is allowed:</p>
  59. <blockquote>
  60. <div>&gt;&gt; 1d10+1d5+1
  61. &gt;&gt; 1d20-6
  62. &gt;&gt; 1d6*2
  63. &gt;&gt; 2d20//4
  64. &gt;&gt; 1d6*(1d4**2)</div></blockquote>
  65. <p>#### Builtin python functions</p>
  66. <p>Currently, the following python functions are allowed: <cite>abs</cite>, <cite>max</cite>, <cite>min</cite></p>
  67. <p>#### Repeat pattern</p>
  68. <p>The <cite>Rn(AdX)</cite> notation can be used to repat n times the <cite>AdX</cite> command.</p>
  69. <p>For example, the pattern <cite>R3(2d6+2)</cite> will roll <cite>2d6+2</cite> three times.</p>
  70. <p>## Examples</p>
  71. <p><cite>1d6</cite> &gt; Roll a 6-sided die
  72. <cite>1d6+3</cite> &gt; Roll a 6-sided die, then add 3
  73. <cite>2*(1d6+3)</cite> &gt; Roll a 6-sided die, add 3, then multiply by 2
  74. <cite>3d6L2</cite> &gt; Roll three 6-sided dice, and drop the two lowest.
  75. <cite>R2(1d6+3)</cite> &gt; Similar to <cite>1d6+3+1d6+3</cite>
  76. <cite>1d%</cite> &gt; Similar to <cite>1d100</cite>
  77. <cite>d6</cite> &gt; Similar to <cite>1d6</cite>
  78. <cite>min(1d6+10,3d6)</cite> &gt; Keep the minimal score between <cite>1d6+10</cite> and <cite>3d6</cite></p>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  83. <div class="sphinxsidebarwrapper">
  84. <h1 class="logo"><a href="index.html">xdice</a></h1>
  85. <h3>Navigation</h3>
  86. <div class="relations">
  87. <h3>Related Topics</h3>
  88. <ul>
  89. <li><a href="index.html">Documentation overview</a><ul>
  90. </ul></li>
  91. </ul>
  92. </div>
  93. <div id="searchbox" style="display: none" role="search">
  94. <h3>Quick search</h3>
  95. <form class="search" action="search.html" method="get">
  96. <div><input type="text" name="q" /></div>
  97. <div><input type="submit" value="Go" /></div>
  98. <input type="hidden" name="check_keywords" value="yes" />
  99. <input type="hidden" name="area" value="default" />
  100. </form>
  101. </div>
  102. <script type="text/javascript">$('#searchbox').show(0);</script>
  103. </div>
  104. </div>
  105. <div class="clearer"></div>
  106. </div>
  107. <div class="footer">
  108. &copy;2017, Olivier Massot.
  109. |
  110. Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.3</a>
  111. &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.10</a>
  112. |
  113. <a href="_sources/dice_notation.md.txt"
  114. rel="nofollow">Page source</a>
  115. </div>
  116. </body>
  117. </html>