| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Dice Notation — xdice 1.0.0 documentation</title>
- <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
- <script type="text/javascript">
- var DOCUMENTATION_OPTIONS = {
- URL_ROOT: './',
- VERSION: '1.0.0',
- COLLAPSE_INDEX: false,
- FILE_SUFFIX: '.html',
- HAS_SOURCE: true,
- SOURCELINK_SUFFIX: '.txt'
- };
- </script>
- <script type="text/javascript" src="_static/jquery.js"></script>
- <script type="text/javascript" src="_static/underscore.js"></script>
- <script type="text/javascript" src="_static/doctools.js"></script>
- <link rel="index" title="Index" href="genindex.html" />
- <link rel="search" title="Search" href="search.html" />
- <link rel="next" title="Command-Line" href="cli.html" />
- <link rel="prev" title="Introduction" href="introduction.html" />
-
- <link rel="stylesheet" href="_static/custom.css" type="text/css" />
-
-
- <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
- </head>
- <body>
-
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body" role="main">
-
- <div class="section" id="dice-notation">
- <h1>Dice Notation<a class="headerlink" href="#dice-notation" title="Permalink to this headline">¶</a></h1>
- <p><em>Dice notation</em> is nearly fully understood by pydice.</p>
- <p><em>xdice</em> is case insensitive.</p>
- <div class="section" id="dice">
- <h2>Dice<a class="headerlink" href="#dice" title="Permalink to this headline">¶</a></h2>
- <blockquote>
- <div>Patterns describes here can be passed to the Dice.parse() class
- method, and will then return the corresponding Dice object.</div></blockquote>
- <p><a class="reference external" href="https://en.wikipedia.org/wiki/Dice_notation">See Wikipedia for a complete definition.</a></p>
- <div class="section" id="bases">
- <h3>Bases<a class="headerlink" href="#bases" title="Permalink to this headline">¶</a></h3>
- <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>
- <ul>
- <li><p class="first">A is the number of dice to be rolled (1 if omitted).</p>
- </li>
- <li><p class="first">X is the number of faces of each die.</p>
- <blockquote>
- <div><p>For example, if a game would call for a roll of d4 or 1d4 this would
- mean, “roll one 4-sided die.” 3d6 would mean, “roll three
- six-sided dice”</p>
- </div></blockquote>
- </li>
- </ul>
- </div>
- <div class="section" id="default-values">
- <h3>Default values<a class="headerlink" href="#default-values" title="Permalink to this headline">¶</a></h3>
- <p>If the A value is omitted, it is assumed to be a 1.</p>
- <p>If the X value is omitted, it is assumed to be a 20.
- This behavior can be modified trough the class property Dice.DEFAULT_SIDES.</p>
- </div>
- <div class="section" id="d-notation">
- <h3>D% Notation<a class="headerlink" href="#d-notation" title="Permalink to this headline">¶</a></h3>
- <p>The <code class="docutils literal"><span class="pre">D%</span></code> notation is allowed, and read as <code class="docutils literal"><span class="pre">D100</span></code>.</p>
- </div>
- <div class="section" id="selective-results">
- <h3>Selective results<a class="headerlink" href="#selective-results" title="Permalink to this headline">¶</a></h3>
- <p>The <code class="docutils literal"><span class="pre">AdX</span></code> pattern can be followed by <code class="docutils literal"><span class="pre">Ln</span></code> and/or <code class="docutils literal"><span class="pre">Hn</span></code> (‘L’ and ‘H’
- respectively stand for lowest and highest).</p>
- <p>In this case, the lowest/highest n scores will be discard when the dice
- will be rolled.</p>
- <p>> Eg: <code class="docutils literal"><span class="pre">3D6L1</span></code> will roll three 6-sided dice, and drop the lowest, while <code class="docutils literal"><span class="pre">3D6H1</span></code> will roll three 6-sided dice, and drop the highest.</p>
- <p>Notes:</p>
- <ul class="simple">
- <li>If no number follow the ‘L’ or ‘H’, it is assumed to be a 1.</li>
- <li>‘L’ and ‘H’ can be combined inside a single pattern, but ‘L’ must precede ‘H’: <code class="docutils literal"><span class="pre">6D6L1H2</span></code></li>
- </ul>
- </div>
- <div class="section" id="exploding-dice">
- <h3>Exploding dice<a class="headerlink" href="#exploding-dice" title="Permalink to this headline">¶</a></h3>
- <p>Append an <code class="docutils literal"><span class="pre">X</span></code> or a <code class="docutils literal"><span class="pre">!</span></code> to a pattern to make the dice ‘explode’.
- ‘Explode’ means each maximal score will trigger a new roll.
- The resulting score will be add to the results.</p>
- <p>For example, if <code class="docutils literal"><span class="pre">3d6!</span></code> give <code class="docutils literal"><span class="pre">[6,3,2]</span></code>, one more die will be rolled (because 6 is the max value)
- The final result could be <code class="docutils literal"><span class="pre">[6,3,2,4]</span></code>.</p>
- </div>
- </div>
- <div class="section" id="patterns">
- <h2>Patterns<a class="headerlink" href="#patterns" title="Permalink to this headline">¶</a></h2>
- <blockquote>
- <div>Patterns describes here can be passed to the Pattern.parse() class
- method.</div></blockquote>
- <p><code class="docutils literal"><span class="pre">AdX</span></code> notations can be used in more complex expressions.</p>
- <p>Any mathematical expression is allowed:</p>
- <div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">>></span> <span class="mi">1</span><span class="n">d10</span><span class="o">+</span><span class="mi">1</span><span class="n">d5</span><span class="o">+</span><span class="mi">1</span>
- <span class="o">>></span> <span class="mi">1</span><span class="n">d20</span><span class="o">-</span><span class="mi">6</span>
- <span class="o">>></span> <span class="mi">1</span><span class="n">d6</span><span class="o">*</span><span class="mi">2</span>
- <span class="o">>></span> <span class="mi">2</span><span class="n">d20</span><span class="o">//</span><span class="mi">4</span>
- <span class="o">>></span> <span class="mi">1</span><span class="n">d6</span><span class="o">*</span><span class="p">(</span><span class="mi">1</span><span class="n">d4</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
- </pre></div>
- </div>
- <p>Following builtin python functions are also allowed: <code class="docutils literal"><span class="pre">abs</span></code>, <code class="docutils literal"><span class="pre">max</span></code>,
- <code class="docutils literal"><span class="pre">min</span></code>. That mean you can parse patterns like <code class="docutils literal"><span class="pre">max(1d6+1,</span> <span class="pre">2d4)</span></code>.</p>
- <div class="section" id="repeat">
- <h3>Repeat<a class="headerlink" href="#repeat" title="Permalink to this headline">¶</a></h3>
- <p>The <code class="docutils literal"><span class="pre">Rn(AdX)</span></code> notation can be used to roll n times the <code class="docutils literal"><span class="pre">AdX</span></code> command.</p>
- <p>For example, the pattern <code class="docutils literal"><span class="pre">R3(2d6+2)</span></code> will roll <code class="docutils literal"><span class="pre">2d6+2</span></code> three times: <code class="docutils literal"><span class="pre">(2d6+2)+(2d6+2)+(2d6+2)</span></code></p>
- </div>
- </div>
- <div class="section" id="examples">
- <h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
- <ul class="simple">
- <li><code class="docutils literal"><span class="pre">1d6</span></code> > Roll a 6-sided die</li>
- <li><code class="docutils literal"><span class="pre">1d6+3</span></code> > Roll a 6-sided die, then add 3</li>
- <li><code class="docutils literal"><span class="pre">2*(1d6+3)</span></code> > Roll a 6-sided die, add 3, then multiply by 2</li>
- <li><code class="docutils literal"><span class="pre">3d6L2</span></code> > Roll three 6-sided dice, and drop the two lowest.</li>
- <li><code class="docutils literal"><span class="pre">R2(1d6+3)</span></code> > Similar to <code class="docutils literal"><span class="pre">1d6+3+1d6+3</span></code></li>
- <li><code class="docutils literal"><span class="pre">1d%</span></code> > Similar to <code class="docutils literal"><span class="pre">1d100</span></code></li>
- <li><code class="docutils literal"><span class="pre">d6</span></code> > Similar to <code class="docutils literal"><span class="pre">1d6</span></code></li>
- <li><code class="docutils literal"><span class="pre">min(1d6+10,3d6)</span></code> > Keep the minimal score between <code class="docutils literal"><span class="pre">1d6+10</span></code> and <code class="docutils literal"><span class="pre">3d6</span></code></li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
- <div class="sphinxsidebarwrapper">
- <h1 class="logo"><a href="index.html">xdice</a></h1>
- <h3>Navigation</h3>
- <ul class="current">
- <li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
- <li class="toctree-l1 current"><a class="current reference internal" href="#">Dice Notation</a><ul>
- <li class="toctree-l2"><a class="reference internal" href="#dice">Dice</a><ul>
- <li class="toctree-l3"><a class="reference internal" href="#bases">Bases</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#default-values">Default values</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#d-notation">D% Notation</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#selective-results">Selective results</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#exploding-dice">Exploding dice</a></li>
- </ul>
- </li>
- <li class="toctree-l2"><a class="reference internal" href="#patterns">Patterns</a><ul>
- <li class="toctree-l3"><a class="reference internal" href="#repeat">Repeat</a></li>
- </ul>
- </li>
- <li class="toctree-l2"><a class="reference internal" href="#examples">Examples</a></li>
- </ul>
- </li>
- <li class="toctree-l1"><a class="reference internal" href="cli.html">Command-Line</a></li>
- <li class="toctree-l1"><a class="reference internal" href="api.html">API Reference</a></li>
- </ul>
- <div class="relations">
- <h3>Related Topics</h3>
- <ul>
- <li><a href="index.html">Documentation overview</a><ul>
- <li>Previous: <a href="introduction.html" title="previous chapter">Introduction</a></li>
- <li>Next: <a href="cli.html" title="next chapter">Command-Line</a></li>
- </ul></li>
- </ul>
- </div>
- <div id="searchbox" style="display: none" role="search">
- <h3>Quick search</h3>
- <form class="search" action="search.html" method="get">
- <div><input type="text" name="q" /></div>
- <div><input type="submit" value="Go" /></div>
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
- <script type="text/javascript">$('#searchbox').show(0);</script>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- <div class="footer">
- ©2017, Olivier Massot.
-
- |
- Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.3</a>
- & <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.10</a>
-
- |
- <a href="_sources/dice_notation.rst.txt"
- rel="nofollow">Page source</a>
- </div>
-
-
- </body>
- </html>
|