a63199aaf36ce72e0f7512c787072136df7db310
[troll.git] / config / statement_en.html
1 <div class="statement-body">
2    <!-- GOAL --> 
3    <div class="statement-section statement-goal"> 
4      <h2> 
5        <span class="icon icon-goal">&nbsp;</span> 
6        <span>The Goal</span> 
7      </h2> 
8      <div class="statement-goal-content"> 
9        Don't get destroyed by the troll.
10      </div>
11    </div> 
12    <!-- RULES --> 
13    <div class="statement-section statement-rules"> 
14      <h2> 
15        <span class="icon icon-rules">&nbsp;</span> 
16        <span>Rules</span> 
17      </h2> 
18      <div class="statement-rules-content">
19        If you have stones, shoot <const>1</const> or more of them.
20        <br>
21        If you don't have stones, shoot <const>0</const> exactly.
22      </div>
23    </div>
24    <div class="statement-section statement-warning">
25      <h2>
26        <span class="icon icon-warning">&nbsp;</span>
27        <span>Rule Evolution</span>
28      </h2>
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>
33        or
34        <a href="https://forum.codingame.com/t/troll-vs-castles-brainstorm/184827?u=jbm">
35          on the forum
36        </a>
37        <ul>
38          <li><s>
39            Is it even worth publishing? can the problem be totally solved?
40          </s></li>
41          <li>
42            More maps? (a map is a {road length} × {initial stone count} pair)
43            → Yes, there will be more maps.
44          </li>
45          <li>
46            Leagues
47            <ol>
48              <li>
49                single small map, cheating is tolerated, boss plays tit
50                for tat (9/10) or cheats (1/10)
51              </li>
52              <li>
53                rock troll and ice troll unlocked; multiple rounds;
54                four maps available; no cheating; boss plays well but
55                not perfect
56              </li>
57              <li>
58                all races unlocked; map continuum, no boss but default
59                AI doesn't lose.
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.  -->
63              </li>
64            </ol>
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
67            games interesting.
68          </li>
69          <li>
70            <s>Fog of war?</s> Cancelled.  Not in this game.
71          </li>
72          <li>
73            Praise for my artistic skillz.  There can never be enough
74            of that.
75          </li>
76          <li>
77            Other remarks?
78          </li>
79        </ul>
80      </div>
81    </div>
82    <div class="statement-victory-conditions">
83      <div class="icon victory"></div>
84      <div class="blk">
85        <div class="title">Victory Condition</div>
86        <div class="text">Your opponent loses.</div>
87      </div>
88    </div>
89    <div class="statement-lose-conditions">
90      <div class="icon lose"></div>
91      <div class="blk">
92        <div class="title">Defeat Condition</div>
93        <ul>
94          <li>The troll reaches your castle.</li>
95          <li>When no player has stones left, the troll is closer to your castle.</li>
96        </ul>
97      </div>
98    </div>
99    <div class="statement-section statement-protocol">
100      <h2>
101        <span class="icon icon-protocol">&nbsp;</span>
102        <span>I/O Protocol</span>
103      </h2>
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.
109        </p>
110        <div class="blk">
111          <div class="title">Map Input</div>
112          <div class="text">
113            <p>
114              Your first line of input contains space-separated
115              parameters:
116              <var>roadLength</var> <var>initialStones</var>
117              <var>gameSeed</var> <var>gameSide</var>
118              <var>reserved1</var> &hellip; <var>reservedN</var>
119            </p>
120            <dl style="margin: 1em;">
121              <dt>roadLength</dt>
122              <dd style="margin-left: 6em;">
123                distance between both castles, between <const>6</const>
124                and <const>14</const>.
125              </dd>
126              <dt>initialStones</dt>
127              <dd style="margin-left: 6em;">
128                number of stones a castle starts the day with,
129                between <const>0</const> and <const>50</const>.
130              </dd>
131              <dt>gameSeed</dt>
132              <dd style="margin-left: 6em;">
133                the game's seed.  The game AIs use it to provide you
134                with reproducible matches even when they use stochastic
135                algorithms, and you're encouraged to do the same!  See
136                examples section below for simple ways to achieve that.
137              </dd>
138              <dt>gameSide</dt>
139              <dd style="margin-left: 6em;">
140                which side you're on, as <const>-1</const>
141                or <const>1</const>.  It's not supposed to make a
142                difference to how you handle the rest of the game, but
143                you can XOR it to your <code>gameSeed</code> to have a
144                (reproducible) random that doesn't mecessarily draw
145                when it plays against itself.
146              </dd>
147              <dt>reserved<em>N</em></dt>
148              <dd style="margin-left: 6em;">
149                one or more parameters, reserved for future use
150              </dd>
151            </dl>
152          </div>
153        </div>
154        <div class="blk">
155          <div class="title">Turn Input</div>
156          <div class="text">
157            <p>
158              At each turn, you are provided with the following three
159              space-separated values:
160              <var>trollDistance</var>
161              <var>stones</var>
162              <var>opponentStones</var>
163            </p>
164            <dl style="margin: 1em;">
165              <dt>trollDistance</dt>
166              <dd style="margin-left: 6em;">
167                distance between the troll and your castle
168              </dd>
169              <dt>stones</dt>
170              <dd style="margin-left: 6em;">
171                number of stones you have left
172              </dd>
173              <dt>opponentStones</dt>
174              <dd style="margin-left: 6em;">
175                number of stones your opponent has left
176              </dd>
177            </dl>
178          </div>
179        </div>
180        <div class="blk">
181          <div class="title">Turn Output</div>
182          <div class="text">
183            <p>
184              After having received your turn input, you are to output
185              a single integer <var>stones</var>: the number of stones
186              you wish to throw at the troll.
187            </p>
188            <p style="margin-top: 1ex">
189              You may optionally provide a <em>message</em> you wish
190              your castle to yell at the troll or at your opponent.
191              Just append it to your output, being sure to separate it
192              with at least one space.
193              <!-- It has no incidence on the game whatsoever.  Unless
194              you're god, that is. -->
195            </p>
196          </div>
197        </div>
198        <div class="blk">
199          <div class="title">Timing Considerations</div>
200          <div class="text">
201            <p>
202              You're currently allowed the default SDK timings.  I
203              think it's one second for the first turn and 50&nbsp;ms
204              then, but don't quote me on this.
205            </p>
206          </div>
207        </div>
208      </div>
209    </div>
210    <div class="statement-section statement-examples">
211      <h2>
212        <span class="icon icon-example">&nbsp;</span>
213        <span>Proper RNG seeding examples</span>
214      </h2>
215      <table>
216        <tr>
217          <th style="border-bottom: 2px dashed #f2bb13;">Language Family</th>
218          <th style="border-bottom: 2px dashed #f2bb13;">Sample</th>
219        </tr>
220        <tr>
221          <td style="border-bottom: 1px dashed #f2bb13;">JVM</td>
222          <td style="border-bottom: 1px dashed #f2bb13;"><code>
223              long mySecretSalt = 0x4242424242424242L;<br>
224              Random random = new Random(gameSeed ^ gameSide ^ mySecretSalt);
225          </code></td>
226        </tr>
227        <tr>
228          <td style="border-bottom: 1px dashed #f2bb13;">C, C++, Perl&hellip;</td>
229          <td style="border-bottom: 1px dashed #f2bb13;"><code>
230              srand(gameSeed ^ gameSide ^ 0xdeadb33f);<br>
231              std::srand(gameSeed ^ gameSide ^ 12345);<br>
232              srand( $gameSeed ^ $gameSide ^ 0xCAFE_BABE );
233          </code></td>
234        </tr>
235        <tr>
236          <td style="border-bottom: 1px dashed #f2bb13;">Other</td>
237          <td style="border-bottom: 1px dashed #f2bb13;">Unachievable until proven otherwise</td>
238        </tr>
239      </table>
240    </div>
241    <div class="statement-section statement-expertrules">
242      <h2>
243        <span class="icon icon-expertrules">&nbsp;</span>
244        <span>Expert rules</span>
245      </h2>
246      <div class="statement-expert-rules-content">
247        <p>
248          In the lower leagues, the following maps are currently
249          available and randomly yet extremely fairly (you wouldn't
250          believe the effort that went into this) chosen uniformly at
251          random among the following:
252        </p>
253        <table style="margin: 1ex">
254          <tr>
255            <th style="border-bottom: 2px dashed #f2bb13; min-width: 6em;">Road length</th>
256            <th style="border-bottom: 2px dashed #f2bb13; min-width: 6em;">Stones</th>
257          </tr>
258          <tr>
259            <td style="border-bottom: 1px dashed #f2bb13"><const>6</const></td>
260            <td style="border-bottom: 1px dashed #f2bb13"><const>15</const></td>
261          </tr>
262          <tr>
263            <td style="border-bottom: 1px dashed #f2bb13"><const>6</const></td>
264            <td style="border-bottom: 1px dashed #f2bb13"><const>30</const></td>
265          </tr>
266          <tr>
267            <td style="border-bottom: 1px dashed #f2bb13"><const>14</const></td>
268            <td style="border-bottom: 1px dashed #f2bb13"><const>30</const></td>
269          </tr>
270          <tr>
271            <td style="border-bottom: 1px dashed #f2bb13"><const>14</const></td>
272            <td style="border-bottom: 1px dashed #f2bb13"><const>50</const></td>
273          </tr>
274        </table>
275        <p>
276          You can also override them via game
277          settings <var>roadLength</var> and <var>initialStones</var>,
278          so long as you remember you won't be choosing them for
279          ranking play.
280        </p>
281      </div>
282    </div>
283    <div class="statement-section statement-protocol">
284      <h2>
285        <span class="icon icon-protocol">&nbsp;</span>
286        <span>Change Log</span>
287      </h2>
288      <p>
289        I'm not maintaining the full changelog here anymore as the
290        <a href="https://troll.desast.re/troll.git">game's source
291        repository</a> is now publicly available.  I'll just make note
292        of the single latest change, so you can know how far behind you
293        were lagging.  Patches welcome, BTW.
294      </p>
295      <p>
296        This draft's last change is:
297        <strong>
298          game seed is sent in inputs.
299        </strong>
300      </p>
301    </div>
302    <div class="statement-story-background">
303      <div class="statement-story"
304           style="position: relative; min-height: min-content">
305        <div class="story-text">
306          <div style="text-align: center">
307            &ldquo;Trolls simply detest the very sight of dwarves (uncooked).&rdquo;
308          </div>
309          <div style="text-align: right">
310            &mdash;&nbsp;J.R.R. Tolkien, <i>The Hobbit</i>
311          </div>
312        </div>
313        <div class="story-text" style="margin-top: 4em">
314          <p>
315            Based on an involuntary suggestion by
316            <span class="card" cg-codingamer-card-popup=""
317                  userid="user.codingamer.userId">
318              <a class="pseudo"
319                 href="/profile/dbfa96e0ac9b77a3db679628f27224ae8509333"
320                 title="Zaap38">Zaap38</a>
321            </span>
322            on the #Fr channel.  The original appears to be by
323            <a href="http://andre.lovichi.free.fr/teaching/ea/2015-2016/cours/troll/Trolls_et_chateaux.pdf">
324              Romain Andr&eacute;-Lovichi
325            </a>.
326          </p>
327        </div>
328      </div>
329    </div>
330 </div>