The Goal

Don't get destroyed by the troll.

  Rules

If you have stones, shoot 1 or more of them.
If you don't have stones, shoot 0 exactly.

  Rule Evolution

The following ideas are still in flux, waiting for some opinions. Please drop a word on the contribution's page or on the forum
  • Is it even worth publishing? can the problem be totally solved?
  • More maps? (a map is a {road length} × {initial stone count} pair)
  • 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:
    1. single small map, cheating is tolerated, boss plays 1
    2. the four maps, no cheating, boss plays tit for tat
    3. full map continuum
  • 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.
  • Praise for my artistic skillz
  • Other remarks?
Victory Condition
Your opponent loses.
Defeat Condition
  • The troll reaches your castle.
  • When no player has stones left, the troll is closer to your castle.

  I/O Protocol

Just read the sample code. You can figure this out.
You're currently allowed the default SDK timings. I think it's one second for the first turn and 50 ms then, but don't quote me on this.

  Expert rules

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:

Road lengthStones
────────────────
615
630
1430
1450

You can also override them via game settings roadLength and initialStones, so long as you remember you won't be choosing them for ranking play.

  Change Log

I'm not maintaining the full changelog here anymore as the game's source repository is now publicly available. I'll just make note of the single latest change, so you can know how far behind you were lagging. Patches welcome, BTW.

This draft's last change is: game parameters can be overridden.

“Trolls simply detest the very sight of dwarves (uncooked).”
— J.R.R. Tolkien, The Hobbit

Based on an involuntary suggestion by Zaap38 on the #Fr channel. The original appears to be by Romain André-Lovichi .