+ <p style="margin-bottom: 1em">
+ This place used to read: “Just read the sample code. You can
+ figure this out.” Here are the formalities for <em>that
+ other</em> part of the audience.
+ </p>
+ <div class="blk">
+ <div class="title">Map Input</div>
+ <div class="text">
+ <p>
+ Your first line of input contains five space-separated
+ parameters:
+ </p>
+ <dl style="margin: 1em;">
+ <dt><var>roadLength</var></dt>
+ <dd style="margin-left: 6em;">
+ distance between both castles, between <const>6</const>
+ and <const>14</const>.
+ </dd>
+ <dt><var>initialStones</var></dt>
+ <dd style="margin-left: 6em;">
+ number of stones a castle starts the day with,
+ between <const>0</const> and <const>50</const>.
+ </dd>
+ <dt><var>gameSeed</var></dt>
+ <dd style="margin-left: 6em;">
+ the game's seed. The game AIs use it to provide you
+ with reproducible matches even when they use stochastic
+ algorithms, and you're encouraged to do the same! See
+ examples section below for simple ways to achieve that.
+ </dd>
+ <dt><var>gameSide</var></dt>
+ <dd style="margin-left: 6em;">
+ which side you're on, as <const>-1</const>
+ or <const>1</const>. It's not supposed to make a
+ difference to how you handle the rest of the game, but
+ you can XOR it to your <code>gameSeed</code> to have a
+ (reproducible) random that doesn't necessarily draw
+ when it plays against itself.
+ </dd>
+ <dt><var>reserved</var></dt>
+ <dd style="margin-left: 6em;">
+ reserved for future use, ignore for now.
+ </dd>
+ </dl>
+ </div>
+ </div>
+ <div class="blk">
+ <div class="title">Turn Input</div>
+ <div class="text">
+ <p>
+ At each turn, you are provided with the following three
+ space-separated values:
+ </p>
+ <dl style="margin: 1em;">
+ <dt><var>trollDistance</var></dt>
+ <dd style="margin-left: 6em;">
+ distance between the troll and your castle
+ </dd>
+ <dt><var>stones</var></dt>
+ <dd style="margin-left: 6em;">
+ number of stones you have left
+ </dd>
+ <dt><var>opponentStones</var></dt>
+ <dd style="margin-left: 6em;">
+ number of stones your opponent has left
+ </dd>
+ </dl>
+ </div>
+ </div>
+ <div class="blk">
+ <div class="title">Turn Output</div>
+ <div class="text">
+ <p>
+ After having received your turn input, you are to output
+ a single integer <var>stones</var>: the number of stones
+ you wish to throw at the troll.
+ </p>
+ <p style="margin-top: 1ex">
+ You may optionally provide a <em>message</em> you wish
+ your castle to yell at the troll or at your opponent.
+ Just append it to your output, being sure to separate it
+ with at least one space.
+ <!-- It has no incidence on the game whatsoever. Unless
+ you're god, that is. -->
+ </p>
+ </div>
+ </div>
+ <div class="blk">
+ <div class="title">Timing Considerations</div>
+ <div class="text">
+ <p>
+ You're allowed the default SDK timings. I think it's one
+ second for the first turn and 50 ms then, but don't
+ quote me on this.
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="statement-section statement-examples">
+ <h2>
+ <span class="icon icon-example"> </span>
+ <span>Proper RNG seeding examples</span>
+ </h2>
+ <style>
+ table.jbm-statement th { border-bottom: 2px dashed #f2bb13 }
+ table.jbm-statement td { border-bottom: 1px dashed #f2bb13 }
+ </style>
+ <table class="jbm-statement">
+ <tr>
+ <th>Language Family</th>
+ <th>Inspiration</th>
+ </tr>
+ <tr>
+ <td>JVM</td>
+ <td><code>
+ long mySecretSalt = 0x4242424242424242L;<br>
+ Random random = new Random(gameSeed ^ gameSide ^ mySecretSalt);
+ </code></td>
+ </tr>
+ <tr>
+ <td>C, C++, Perl…</td>
+ <td><code>
+ srand(gameSeed ^ gameSide ^ 0xdeadb33f);<br>
+ std::srand(gameSeed ^ gameSide ^ 12345);<br>
+ srand( $gameSeed ^ $gameSide ^ 0xCAFE_BABE );
+ </code></td>
+ </tr>
+ <tr>
+ <td>Other</td>
+ <td>Unachievable until proven otherwise</td>
+ </tr>
+ </table>
+ </div>
+ <div class="statement-section statement-expertrules">
+ <h2>
+ <span class="icon icon-expertrules"> </span>
+ <span>Expert rules</span>
+ </h2>
+ <div class="statement-expert-rules-content">
+ <p>
+ In the lower leagues, the following maps are available and
+ randomly yet extremely fairly (you wouldn't believe the
+ effort that went into this) chosen uniformly at random among
+ the following:
+ </p>
+ <style>
+ table#jbm-maps th {
+ min-width: 6em;
+ text-align: right;
+ }
+ table#jbm-maps td {
+ text-align: right;
+ padding-right: 1em;
+ }
+ </style>
+ <table class="jbm-statement" id="jbm-maps" style="margin: 1ex">
+ <tr>
+ <th>Road length</th>
+ <th>Stones</th>
+ </tr>
+ <tr>
+ <td><const>6</const></td>
+ <td><const>15</const></td>
+ </tr>
+ <tr>
+ <td><const>6</const></td>
+ <td><const>30</const></td>
+ </tr>
+ <tr>
+ <td><const>14</const></td>
+ <td><const>30</const></td>
+ </tr>
+ <tr>
+ <td><const>14</const></td>
+ <td><const>50</const></td>
+ </tr>
+ </table>
+ <p>
+ You may also override them via game
+ settings <var>roadLength</var> and <var>initialStones</var>,
+ so long as you remember you won't be choosing them for
+ ranking play.
+ </p>
+ </div>
+ </div>
+ <div class="statement-section statement-protocol">
+ <h2>
+ <span class="icon icon-protocol"> </span>
+ <span>Change Log</span>
+ </h2>
+ <p>
+ I'm not maintaining the full changelog here anymore as the
+ <a href="https://troll.desast.re/troll.git">game's source
+ repository</a> is now publicly available. I'll just make note
+ of the single latest change, so you can know how far behind you
+ were lagging. Patches welcome, BTW.
+ </p>
+ <p>
+ This draft's last change is:
+ <strong>
+ not taking any more suggestions.
+ </strong>
+ </p>
+ </div>
+ <div class="statement-story-background">
+ <div class="statement-story"
+ style="position: relative; min-height: min-content">
+ <div class="story-text">
+ <div style="text-align: center">
+ “Trolls simply detest the very sight of dwarves (uncooked).”
+ </div>
+ <div style="text-align: right">
+ — J.R.R. Tolkien, <i>The Hobbit</i>
+ </div>
+ </div>
+ <div class="story-text" style="margin-top: 4em">
+ <p>
+ Based on an involuntary suggestion by
+ <span class="card" cg-codingamer-card-popup=""
+ userid="user.codingamer.userId">
+ <a class="pseudo"
+ href="/profile/dbfa96e0ac9b77a3db679628f27224ae8509333"
+ title="Zaap38">Zaap38</a>
+ </span>
+ on the #Fr channel. The original appears to be by
+ <a href="http://andre.lovichi.free.fr/teaching/ea/2015-2016/cours/troll/Trolls_et_chateaux.pdf">
+ Romain André-Lovichi
+ </a>.
+ </p>
+ </div>