* TODO referee cleanup
* DONE upgrade deps
* TODO Timings
-* TODO fenceposts
+* DONE fenceposts
+* Quotes
+ Trolls, it is said, were bred by Melkor because he desired a race as powerful as the giant Ents, the Tree-herds.
+ David Day in Tolkien : The Illustrated Encyclopaedia (1993), p. 226
+
+ The folk belief … is that lightning seeks out trolls and giants, perhaps a reflection the giant-slaying of Thor in Old Norse mythology. Many informants have told collectors that the reason the giants or trolls are no longer populous is the accuracy and efficiency of the lightning strokes.
+ John Lindow, in Swedish Folktales and Legends (1978), p. 89
+
+ Senator Stampingston: Gentlemen, it's clear that we're in a universally precarious situation. Dethklok has summoned a troll.
+ General Crozier: That's impossible, there's no such thing as trolls.
+ Senator Stampingston: Then how do you explain the dead unicorns?
+ Metalocalypse, Dethtroll, episode 1.04 (2006)
+
+ They were trolls. Obviously trolls. Even Bilbo, in spite of his sheltered life, could see that: from the great heavy faces of them, and their size, and the shape of their legs, not to mention their language, which was not drawing-room fashion at all, at all.
+ J. R. R. Tolkien, The Hobbit (1937), Chapter 2: "Roast Mutton"
+
+ Trolls are slow in the uptake, and mighty suspicious about anything new to them.
+ J. R. R. Tolkien, The Hobbit (1937), Chapter 2: "Roast Mutton"
+
+ Trolls simply detest the very sight of dwarves (uncooked).
+ J. R. R. Tolkien, The Hobbit (1937), Chapter 2: "Roast Mutton"
+
+ Trolls do not build.
+ J. R. R. Tolkien, The Fellowship of the Ring (1954), Book I, Chapter 12: "Flight to the Ford"; said by Strider.
+
+ 'Now is the time!' cried Gandalf. 'Let us go, before the troll returns!'
+ J. R. R. Tolkien, The Fellowship of the Ring (1954), Book II, Chapter 5: "The Bridge of Khazad-Dûm"
+
+ Trolls are only counterfeits, made by the Enemy in the Great Darkness, in mockery of Ents, as Orcs were of Elves.
+ J. R. R. Tolkien, The Two Towers (1954), Book III, Chapter 4: "Treebeard"
turn if you have any left.
</div>
</div>
- <div class="statement-section statement-warning">
- <h2>
- <span class="icon icon-warning"> </span>
- <span>Breaking Change</span>
- </h2>
- <p>
- The <var>roadLength</var> game input variable used to be the
- cardinal number of positions the troll could be in. That's the
- way it was presented in the original game, but I leaned more
- towards distances to make the I/O protocol easier on beginners.
- So it's currently inconsistent.
- </p>
- <p>
- This is going to change in the following days to be a distance
- everywhere, more in line with the protocol's other measures.
- Not to mention being somewhat more consistent with the variable
- name. Thanks
- <a href="https://www.codingame.com/profile/c4a50746f425cb125f77487aaf51350c7258821">
- @Snef
- </a>
- for reminding me of this.
- </p>
- <p>
- If you used this variable, I suggest you temporarily used one
- of these workarounds so you don't get bit by the upcoming
- change:
- </p>
- <table>
- <tr><th>Former use</th><th>As a</th><th>Try this</th></tr>
- <tr>
- <td><pre>roadLength - 1</pre></td>
- <td><pre>distance to opponent</pre></td>
- <td><pre>roadLength & (~1)</pre></td>
- </tr>
- <tr>
- <td><pre>roadLength</pre></td>
- <td><pre>number of troll states</pre></td>
- <td><pre>roadLength | 1</pre></td>
- </tr>
- <tr>
- <td><pre>roadLength + 1</pre></td>
- <td><pre>I have no idea</pre></td>
- <td><pre>(roadLength + 1) & (-1)</pre></td>
- </tr>
- </table>
- </div>
<div class="statement-section statement-warning">
<h2>
<span class="icon icon-warning"> </span>
</p>
<table>
<tr><th>Road length</th><th>Stones</th></tr>
- <tr><td><const>7</const></td><td><const>15</const></td></tr>
- <tr><td><const>7</const></td><td><const>30</const></td></tr>
- <tr><td><const>15</const></td><td><const>30</const></td></tr>
- <tr><td><const>15</const></td><td><const>50</const></td></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>
As with anything in this <em>draft</em> statement, this
<span>Change Log</span>
</h2>
<ul>
+ <li>
+ Fixed the road length fencepost non-issue.
+ </li>
<li>
Of course that game needed MSG functionality!
</li>
<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>
+
+ <hr>
+
Based on an involuntary suggestion by
<span class="card" cg-codingamer-card-popup=""
userid="user.codingamer.userId">
Keep the troll out of your castle!
INPUT
-roadLength: the length of the road between both castles. The troll starts in the middle.
-initialStones: the number of stones each castle starts with
+roadLength: the distance (even) between both castles. The troll starts at half that distance.
+initialStones: the number of stones each castle starts with.
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 left.
+opponentStones: number of stones left to your opponent.
OUTPUT
-number of stones to shoot at the troll
+number of stones to shoot at the troll.
random = new Random(gameManager.getSeed());
switch (random.nextInt(4)) {
case 0:
- roadLength = 7;
+ roadLength = 6;
initialStones = 15;
break;
case 1:
- roadLength = 7;
+ roadLength = 6;
initialStones = 30;
break;
case 2:
- roadLength = 15;
+ roadLength = 14;
initialStones = 30;
break;
case 3:
- roadLength = 15;
+ roadLength = 14;
initialStones = 50;
break;
}
- trollPosition = (roadLength - 1) / 2;
+ trollPosition = roadLength / 2;
p0 = gameManager.getPlayer(0);
p0.setCastlePosition(0);
p0.setMultiplier(1);
p0.adjustScore(trollPosition);
- p0.sendInputLine(String.format("%d %d", roadLength - 1, initialStones));
+ p0.sendInputLine(String.format("%d %d", roadLength, initialStones));
p1 = gameManager.getPlayer(1);
p1.setCastlePosition(roadLength-1);
p1.setMultiplier(-1);
p1.adjustScore(trollPosition);
- p1.sendInputLine(String.format("%d %d", roadLength - 1, initialStones));
+ p1.sendInputLine(String.format("%d %d", roadLength, initialStones));
drawBackground();
drawPlayer();
graphicEntityModule.commitEntityState(0.5, troll, trollPositionGauge);
int x0 = p0.castle.getX(), x1 = p1.castle.getX();
int y0 = p0.castle.getY(), y1 = p1.castle.getY();
- troll.setX(x0 + trollPosition * (x1-x0) / (roadLength - 1),
+ troll.setX(x0 + trollPosition * (x1-x0) / roadLength,
Curve.ELASTIC);
- troll.setY(y0 + trollPosition * (y1-y0) / (roadLength - 1),
+ troll.setY(y0 + trollPosition * (y1-y0) / roadLength,
Curve.ELASTIC);
trollPositionGauge.setX((trollPositionGauge.getX() + troll.getX()) / 2);
- int delta = trollPosition - (roadLength - 1) / 2;
+ int delta = trollPosition - roadLength / 2;
if (delta < 0) {
trollPositionGauge.setText("← " + Math.abs(delta));
}