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 Your first line of input contains space-separated
116 <var>roadLength</var> <var>initialStones</var>
117 <var>gameSeed</var> <var>gameSide</var>
118 <var>reserved1</var> … <var>reservedN</var>
120 <dl style="margin: 1em;">
122 <dd style="margin-left: 6em;">
123 distance between both castles, between <const>6</const>
124 and <const>14</const>.
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>.
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.
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.
147 <dt>reserved<em>N</em></dt>
148 <dd style="margin-left: 6em;">
149 one or more parameters, reserved for future use
155 <div class="title">Turn Input</div>
158 At each turn, you are provided with the following three
159 space-separated values:
160 <var>trollDistance</var>
162 <var>opponentStones</var>
164 <dl style="margin: 1em;">
165 <dt>trollDistance</dt>
166 <dd style="margin-left: 6em;">
167 distance between the troll and your castle
170 <dd style="margin-left: 6em;">
171 number of stones you have left
173 <dt>opponentStones</dt>
174 <dd style="margin-left: 6em;">
175 number of stones your opponent has left
181 <div class="title">Turn Output</div>
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.
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. -->
199 <div class="title">Timing Considerations</div>
202 You're currently allowed the default SDK timings. I
203 think it's one second for the first turn and 50 ms
204 then, but don't quote me on this.
210 <div class="statement-section statement-expertrules">
212 <span class="icon icon-expertrules"> </span>
213 <span>Expert rules</span>
215 <div class="statement-expert-rules-content">
217 In the lower leagues, the following maps are currently
218 available and randomly yet extremely fairly (you wouldn't
219 believe the effort that went into this) chosen uniformly at
220 random among the following:
222 <table style="margin: 1ex">
224 <th style="border-bottom: 2px dashed #f2bb13; min-width: 6em;">Road length</th>
225 <th style="border-bottom: 2px dashed #f2bb13; min-width: 6em;">Stones</th>
228 <td style="border-bottom: 1px dashed #f2bb13"><const>6</const></td>
229 <td style="border-bottom: 1px dashed #f2bb13"><const>15</const></td>
232 <td style="border-bottom: 1px dashed #f2bb13"><const>6</const></td>
233 <td style="border-bottom: 1px dashed #f2bb13"><const>30</const></td>
236 <td style="border-bottom: 1px dashed #f2bb13"><const>14</const></td>
237 <td style="border-bottom: 1px dashed #f2bb13"><const>30</const></td>
240 <td style="border-bottom: 1px dashed #f2bb13"><const>14</const></td>
241 <td style="border-bottom: 1px dashed #f2bb13"><const>50</const></td>
245 You can also override them via game
246 settings <var>roadLength</var> and <var>initialStones</var>,
247 so long as you remember you won't be choosing them for
252 <div class="statement-section statement-protocol">
254 <span class="icon icon-protocol"> </span>
255 <span>Change Log</span>
258 I'm not maintaining the full changelog here anymore as the
259 <a href="https://troll.desast.re/troll.git">game's source
260 repository</a> is now publicly available. I'll just make note
261 of the single latest change, so you can know how far behind you
262 were lagging. Patches welcome, BTW.
265 This draft's last change is:
267 game seed is sent in inputs.
271 <div class="statement-story-background">
272 <div class="statement-story"
273 style="position: relative; min-height: min-content">
274 <div class="story-text">
275 <div style="text-align: center">
276 “Trolls simply detest the very sight of dwarves (uncooked).”
278 <div style="text-align: right">
279 — J.R.R. Tolkien, <i>The Hobbit</i>
282 <div class="story-text" style="margin-top: 4em">
284 Based on an involuntary suggestion by
285 <span class="card" cg-codingamer-card-popup=""
286 userid="user.codingamer.userId">
288 href="/profile/dbfa96e0ac9b77a3db679628f27224ae8509333"
289 title="Zaap38">Zaap38</a>
291 on the #Fr channel. The original appears to be by
292 <a href="http://andre.lovichi.free.fr/teaching/ea/2015-2016/cours/troll/Trolls_et_chateaux.pdf">
293 Romain André-Lovichi