Send game seed in inputs. Update HTML.
authorJBM <jbm@codingame.com>
Wed, 3 Jun 2020 16:29:37 +0000 (18:29 +0200)
committerJBM <jbm@codingame.com>
Wed, 3 Jun 2020 16:58:49 +0000 (18:58 +0200)
config/Boss.java
config/statement_en.html
config/stub.txt
src/main/java/com/codingame/game/Player.java
src/main/java/com/codingame/game/Referee.java

index e1bcec3..4c2a766 100644 (file)
@@ -15,6 +15,7 @@ class Player {
 
         int roadLength = in.nextInt();
         int initialStones = in.nextInt();
+        in.nextLong();
 
         while (true) {
             int trollDistance = in.nextInt();
index 58f3d1c..edffecf 100644 (file)
@@ -29,9 +29,7 @@
      <div class="statement-warning-content">
        The following ideas are still in flux, waiting for some
        opinions.  Please drop a word on the
-       <a href="https://www.codingame.com/contribute/view/507070b7925f661e2d2835c14f950b9d157e">
-         contribution's page
-       </a>
+       <a href="https://www.codingame.com/contribute/view/507070b7925f661e2d2835c14f950b9d157e">contribution's page</a>
        or
        <a href="https://forum.codingame.com/t/troll-vs-castles-brainstorm/184827?u=jbm">
          on the forum
          </s></li>
          <li>
            More maps? (a map is a {road length} × {initial stone count} pair)
+           → Yes, there will be more maps.
          </li>
          <li>
-           Leagues? I could conceive the referee being permissive
-           (allow 0 stones thrown) in the first one, and then strict.
-           Off the top of my head:
+           Leagues
            <ol>
-             <li>single small map, cheating is tolerated, boss plays 1</li>
-             <li>the four maps, no cheating, boss plays tit for tat</li>
-             <li>full map continuum</li>
+             <li>
+               single small map, cheating is tolerated, boss plays tit
+               for tat (9/10) or cheats (1/10)
+             </li>
+             <li>
+               rock troll and ice troll unlocked; multiple rounds;
+               four maps available; no cheating; boss plays well but
+               not perfect
+             </li>
+             <li>
+               all races unlocked; map continuum, no boss but default
+               AI doesn't lose.
+               <!-- I've actually got plans on a generic way to do
+                    that.  It's going to need many many hacks and a
+                    viewer module.  It's not planned for too soon.  -->
+             </li>
            </ol>
+           For the WIP phase of this draft, I'll likely merge the last
+           two leagues into one because we need data on what makes the
+           games interesting.
          </li>
          <li>
-           Fog of war? (see only troll position, not enemy
-           throw/stones left) Probably not in this game, be it simple,
-           variable (seeing enemy stones is a boolean decided randomly
-           as part of the map) or by distance.
+           <s>Fog of war?</s> Cancelled.  Not in this game.
          </li>
          <li>
-           Praise for my artistic skillz
+           Praise for my artistic skillz.  There can never be enough
+           of that.
          </li>
          <li>
            Other remarks?
        <span>I/O Protocol</span>
      </h2>
      <div class="statement-protocol-content">
-       Just read the sample code.  You can figure this out.
-       <br>
-       You're currently allowed the default SDK timings.  I think it's
-       one second for the first turn and 50&nbsp;ms then, but don't
-       quote me on this.
+       <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 three space-separated
+             parameters:
+             <var>roadLength</var> <var>initialStones</var> <var>seed</var>
+           </p>
+           <dl style="margin: 1em;">
+             <dt>roadLength</dt>
+             <dd style="margin-left: 6em;">
+               distance between both castles, between <const>6</const>
+               and <const>14</const>.
+             </dd>
+             <dt>initialStones</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>gameSeed</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>
+           </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:
+             <var>trollDistance</var>
+             <var>stones</var>
+             <var>opponentStones</var>
+           </p>
+           <dl style="margin: 1em;">
+             <dt>trollDistance</dt>
+             <dd style="margin-left: 6em;">
+               distance between the troll and your castle
+             </dd>
+             <dt>stones</dt>
+             <dd style="margin-left: 6em;">
+               number of stones you have left
+             </dd>
+             <dt>opponentStones</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 currently allowed the default SDK timings.  I
+             think it's one second for the first turn and 50&nbsp;ms
+             then, but don't quote me on this.
+           </p>
+         </div>
+       </div>
      </div>
    </div>
    <div class="statement-section statement-expertrules">
      </h2>
      <div class="statement-expert-rules-content">
        <p>
-         The following maps are currently available and randomly yet
-         extremely fairly (you wouldn't believe the effort that went
-         into this) chosen uniformly at random among the following:
+         In the lower leagues, the following maps are currently
+         available and randomly yet extremely fairly (you wouldn't
+         believe the effort that went into this) chosen uniformly at
+         random among the following:
        </p>
-       <table>
-         <tr><th>Road length</th><td>│</td><th>Stones</th></tr>
-         <tr><td>──────────</td><td>┼</td><td>──────</td></tr>
-         <tr><td><const>6</const></td><td>│</td><td><const>15</const></td></tr>
-         <tr><td><const>6</const></td><td>│</td><td><const>30</const></td></tr>
-         <tr><td><const>14</const></td><td>│</td><td><const>30</const></td></tr>
-         <tr><td><const>14</const></td><td>│</td><td><const>50</const></td></tr>
+       <table style="margin: 1ex">
+         <tr>
+           <th style="border-bottom: 2px dashed #f2bb13; min-width: 6em;">Road length</th>
+           <th style="border-bottom: 2px dashed #f2bb13; min-width: 6em;">Stones</th>
+         </tr>
+         <tr>
+           <td style="border-bottom: 1px dashed #f2bb13"><const>6</const></td>
+           <td style="border-bottom: 1px dashed #f2bb13"><const>15</const></td>
+         </tr>
+         <tr>
+           <td style="border-bottom: 1px dashed #f2bb13"><const>6</const></td>
+           <td style="border-bottom: 1px dashed #f2bb13"><const>30</const></td>
+         </tr>
+         <tr>
+           <td style="border-bottom: 1px dashed #f2bb13"><const>14</const></td>
+           <td style="border-bottom: 1px dashed #f2bb13"><const>30</const></td>
+         </tr>
+         <tr>
+           <td style="border-bottom: 1px dashed #f2bb13"><const>14</const></td>
+           <td style="border-bottom: 1px dashed #f2bb13"><const>50</const></td>
+         </tr>
        </table>
        <p>
          You can also override them via game
-         settings <tt>roadLength</tt> and <tt>initialStones</tt>, so
-         long as you remember you won't be choosing them for ranking
-         play.
+         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>
      <p>
        This draft's last change is:
        <strong>
-         troll pants' color can be chosen.
+         game seed is sent in inputs.
        </strong>
      </p>
    </div>
index 886ec28..76ff251 100644 (file)
@@ -1,4 +1,4 @@
-read roadLength:int initialStones:int
+read roadLength:int initialStones:int gameSeed:long
 gameloop
 read trollDistance:int stones:int opponentStones:int
 write 1
@@ -9,9 +9,10 @@ Keep the troll out of your castle!
 INPUT
 roadLength: the distance (even) between both castles. The troll starts at half that distance.
 initialStones: the number of stones each castle starts with.
+gameSeed: a random number to salt and help make your games more reproducible.
 trollDistance: distance between the troll and your castle. Keep it above zero!
-stones: number of stones left.
-opponentStones: number of stones left to your opponent.
+stones: number of stones you have left.
+opponentStones: number of stones your opponent has left.
 
 OUTPUT
 number of stones to shoot at the troll.
index e73482a..63f9e50 100644 (file)
@@ -22,8 +22,9 @@ public class Player extends AbstractMultiplayerPlayer {
     }
 
     // same-typed positional parameters… a disaster waiting to happen
-    void gameInit(int roadLength, int initialStones) {
-        sendInputLine(String.format("%d %d", roadLength, initialStones));
+    void gameInit(int roadLength, int initialStones, long seed) {
+        sendInputLine(String.format("%d %d %d",
+                                    roadLength, initialStones, seed));
     }
 
     void sendGameTurn() {
index b15b4b0..f9c442b 100644 (file)
@@ -31,7 +31,8 @@ public class Referee extends AbstractReferee {
         gameManager.getPlayer(1).model = model.p1;
 
         for (Player p: gameManager.getPlayers()) {
-            p.gameInit(model.roadLength, model.initialStones);
+            p.gameInit(model.roadLength, model.initialStones,
+                       gameManager.getSeed());
         }
 
         view.init(model);