1 <div class="statement-body">
 
   3    <div class="statement-section statement-goal"> 
 
   5        <span class="icon icon-goal"> </span> 
 
   8      <div class="statement-goal-content"> 
 
   9        Don't get destroyed by the troll.
 
  13    <div class="statement-section statement-rules"> 
 
  15        <span class="icon icon-rules"> </span> 
 
  18      <div class="statement-rules-content">
 
  19        If you have stones, shoot <const>1</const> or more of them.
 
  21        If you don't have stones, shoot <const>0</const> exactly.
 
  24    <div class="statement-section statement-warning">
 
  26        <span class="icon icon-warning"> </span>
 
  27        <span>Rule Evolution</span>
 
  29      <div class="statement-warning-content">
 
  30        The following ideas are still in flux, waiting for some
 
  31        opinions.  Please drop a word on the
 
  32        <a href="https://www.codingame.com/contribute/view/507070b7925f661e2d2835c14f950b9d157e">contribution's page</a>
 
  34        <a href="https://forum.codingame.com/t/troll-vs-castles-brainstorm/184827?u=jbm">
 
  39            Is it even worth publishing? can the problem be totally solved?
 
  42            More maps? (a map is a {road length} × {initial stone count} pair)
 
  43            → Yes, there will be more maps.
 
  49                single small map, cheating is tolerated, boss plays tit
 
  50                for tat (9/10) or cheats (1/10)
 
  53                rock troll and ice troll unlocked; multiple rounds;
 
  54                four maps available; no cheating; boss plays well but
 
  58                all races unlocked; map continuum, no boss but default
 
  60                <!-- I've actually got plans on a generic way to do
 
  61                     that.  It's going to need many many hacks and a
 
  62                     viewer module.  It's not planned for too soon.  -->
 
  65            For the WIP phase of this draft, I'll likely merge the last
 
  66            two leagues into one because we need data on what makes the
 
  70            <s>Fog of war?</s> Cancelled.  Not in this game.
 
  73            Praise for my artistic skillz.  There can never be enough
 
  82    <div class="statement-victory-conditions">
 
  83      <div class="icon victory"></div>
 
  85        <div class="title">Victory Condition</div>
 
  86        <div class="text">Your opponent loses.</div>
 
  89    <div class="statement-lose-conditions">
 
  90      <div class="icon lose"></div>
 
  92        <div class="title">Defeat Condition</div>
 
  94          <li>The troll reaches your castle.</li>
 
  95          <li>When no player has stones left, the troll is closer to your castle.</li>
 
  99    <div class="statement-section statement-protocol">
 
 101        <span class="icon icon-protocol"> </span>
 
 102        <span>I/O Protocol</span>
 
 104      <div class="statement-protocol-content">
 
 105        <p style="margin-bottom: 1em">
 
 106          This place used to read: “Just read the sample code.  You can
 
 107          figure this out.”  Here are the formalities for <em>that
 
 108          other</em> part of the audience.
 
 111          <div class="title">Map Input</div>
 
 114              This section's HTML gets messed up somewhere in the SDK
 
 115              pipeline.  <a href="https://forum.codingame.com/t/misleading-html-in-the-sdk-skeleton/184828/8?u=jbm">I reported it there;</a> and there
 
 116              you'll be able to find a readable representation of this
 
 117              block.  Sorry about the inconvenience…
 
 120              Your first line of input contains five space-separated
 
 122              <var>roadLength</var> <var>initialStones</var>
 
 123              <var>gameSeed</var> <var>gameSide</var>
 
 126            <dl style="margin: 1em;">
 
 128              <dd style="margin-left: 6em;">
 
 129                distance between both castles, between <const>6</const>
 
 130                and <const>14</const>.
 
 132              <dt>initialStones</dt>
 
 133              <dd style="margin-left: 6em;">
 
 134                number of stones a castle starts the day with,
 
 135                between <const>0</const> and <const>50</const>.
 
 138              <dd style="margin-left: 6em;">
 
 139                the game's seed.  The game AIs use it to provide you
 
 140                with reproducible matches even when they use stochastic
 
 141                algorithms, and you're encouraged to do the same!  See
 
 142                examples section below for simple ways to achieve that.
 
 145              <dd style="margin-left: 6em;">
 
 146                which side you're on, as <const>-1</const>
 
 147                or <const>1</const>.  It's not supposed to make a
 
 148                difference to how you handle the rest of the game, but
 
 149                you can XOR it to your <code>gameSeed</code> to have a
 
 150                (reproducible) random that doesn't mecessarily draw
 
 151                when it plays against itself.
 
 154              <dd style="margin-left: 6em;">
 
 155                reserved for future use, ignore for now
 
 161          <div class="title">Turn Input</div>
 
 164              At each turn, you are provided with the following three
 
 165              space-separated values:
 
 166              <var>trollDistance</var>
 
 168              <var>opponentStones</var>
 
 170            <dl style="margin: 1em;">
 
 171              <dt>trollDistance</dt>
 
 172              <dd style="margin-left: 6em;">
 
 173                distance between the troll and your castle
 
 176              <dd style="margin-left: 6em;">
 
 177                number of stones you have left
 
 179              <dt>opponentStones</dt>
 
 180              <dd style="margin-left: 6em;">
 
 181                number of stones your opponent has left
 
 187          <div class="title">Turn Output</div>
 
 190              After having received your turn input, you are to output
 
 191              a single integer <var>stones</var>: the number of stones
 
 192              you wish to throw at the troll.
 
 194            <p style="margin-top: 1ex">
 
 195              You may optionally provide a <em>message</em> you wish
 
 196              your castle to yell at the troll or at your opponent.
 
 197              Just append it to your output, being sure to separate it
 
 198              with at least one space.
 
 199              <!-- It has no incidence on the game whatsoever.  Unless
 
 200              you're god, that is. -->
 
 205          <div class="title">Timing Considerations</div>
 
 208              You're currently allowed the default SDK timings.  I
 
 209              think it's one second for the first turn and 50 ms
 
 210              then, but don't quote me on this.
 
 216    <div class="statement-section statement-examples">
 
 218        <span class="icon icon-example"> </span>
 
 219        <span>Proper RNG seeding examples</span>
 
 223          <th style="border-bottom: 2px dashed #f2bb13;">Language Family</th>
 
 224          <th style="border-bottom: 2px dashed #f2bb13;">Sample</th>
 
 227          <td style="border-bottom: 1px dashed #f2bb13;">JVM</td>
 
 228          <td style="border-bottom: 1px dashed #f2bb13;"><code>
 
 229              long mySecretSalt = 0x4242424242424242L;<br>
 
 230              Random random = new Random(gameSeed ^ gameSide ^ mySecretSalt);
 
 234          <td style="border-bottom: 1px dashed #f2bb13;">C, C++, Perl…</td>
 
 235          <td style="border-bottom: 1px dashed #f2bb13;"><code>
 
 236              srand(gameSeed ^ gameSide ^ 0xdeadb33f);<br>
 
 237              std::srand(gameSeed ^ gameSide ^ 12345);<br>
 
 238              srand( $gameSeed ^ $gameSide ^ 0xCAFE_BABE );
 
 242          <td style="border-bottom: 1px dashed #f2bb13;">Other</td>
 
 243          <td style="border-bottom: 1px dashed #f2bb13;">Unachievable until proven otherwise</td>
 
 247    <div class="statement-section statement-expertrules">
 
 249        <span class="icon icon-expertrules"> </span>
 
 250        <span>Expert rules</span>
 
 252      <div class="statement-expert-rules-content">
 
 254          In the lower leagues, the following maps are currently
 
 255          available and randomly yet extremely fairly (you wouldn't
 
 256          believe the effort that went into this) chosen uniformly at
 
 257          random among the following:
 
 259        <table style="margin: 1ex">
 
 261            <th style="border-bottom: 2px dashed #f2bb13; min-width: 6em;">Road length</th>
 
 262            <th style="border-bottom: 2px dashed #f2bb13; min-width: 6em;">Stones</th>
 
 265            <td style="border-bottom: 1px dashed #f2bb13"><const>6</const></td>
 
 266            <td style="border-bottom: 1px dashed #f2bb13"><const>15</const></td>
 
 269            <td style="border-bottom: 1px dashed #f2bb13"><const>6</const></td>
 
 270            <td style="border-bottom: 1px dashed #f2bb13"><const>30</const></td>
 
 273            <td style="border-bottom: 1px dashed #f2bb13"><const>14</const></td>
 
 274            <td style="border-bottom: 1px dashed #f2bb13"><const>30</const></td>
 
 277            <td style="border-bottom: 1px dashed #f2bb13"><const>14</const></td>
 
 278            <td style="border-bottom: 1px dashed #f2bb13"><const>50</const></td>
 
 282          You can also override them via game
 
 283          settings <var>roadLength</var> and <var>initialStones</var>,
 
 284          so long as you remember you won't be choosing them for
 
 289    <div class="statement-section statement-protocol">
 
 291        <span class="icon icon-protocol"> </span>
 
 292        <span>Change Log</span>
 
 295        I'm not maintaining the full changelog here anymore as the
 
 296        <a href="https://troll.desast.re/troll.git">game's source
 
 297        repository</a> is now publicly available.  I'll just make note
 
 298        of the single latest change, so you can know how far behind you
 
 299        were lagging.  Patches welcome, BTW.
 
 302        This draft's last change is:
 
 304          demo references still existing sprites.
 
 308    <div class="statement-story-background">
 
 309      <div class="statement-story"
 
 310           style="position: relative; min-height: min-content">
 
 311        <div class="story-text">
 
 312          <div style="text-align: center">
 
 313            “Trolls simply detest the very sight of dwarves (uncooked).”
 
 315          <div style="text-align: right">
 
 316            — J.R.R. Tolkien, <i>The Hobbit</i>
 
 319        <div class="story-text" style="margin-top: 4em">
 
 321            Based on an involuntary suggestion by
 
 322            <span class="card" cg-codingamer-card-popup=""
 
 323                  userid="user.codingamer.userId">
 
 325                 href="/profile/dbfa96e0ac9b77a3db679628f27224ae8509333"
 
 326                 title="Zaap38">Zaap38</a>
 
 328            on the #Fr channel.  The original appears to be by
 
 329            <a href="http://andre.lovichi.free.fr/teaching/ea/2015-2016/cours/troll/Trolls_et_chateaux.pdf">
 
 330              Romain André-Lovichi