{% extends "main.html" %}
{% load i18n %}
{% load staticfiles %}

{% block rules_selected %}selected{% endblock %}

{% block title %}{% trans "Rules to become the Gamesmaster" %}{% endblock %}

{% block content %}

<h1>What are the rules?</h1>

We have a “big” tic-tac-toe board with a “small” tic-tac-toe board in each
cell. Your goal is to win the big board by winning small ones.

You may only play in the big field that corresponds to the last small field
your opponent played. When you are sent to a field that is already
won/lost/drawn, you can place the move wherever you like.

For example, here is a game where O wins, because X makes an error:

<div>
<div class="board-wrapper">
  <div class="board_here"></div>
  <button class="btn btn-sm btn-default" id="reset">&lt;&lt;</button>
  <button class="btn btn-sm btn-default" id="backward">&lt;</button>
  <button class="btn btn-sm btn-default" id="forward">&gt;</button>
  <button class="btn btn-sm btn-default" id="fastforward">&gt;&gt;</button>
</div>
<div class="status_here"></div>
<div style="clear: both"></div>
</div>

<h1>What should I deliver?</h1>

You write a Lua function that takes 4 arguments (xo, board, row, col) and
returns the coordinates of where to place your move. You can find an example
solution in the <a
href="https://github.com/Motiejus/tictactoelib/blob/master/tictactoelib/examples/dumb_player.lua">tictactoe
library repository</a>. This example is what you are competing against;
if you win, you get a cap!

<h1>What if I cheat?</h1>

Since all the activities are logged, and the contest is quite small, we’ll most
likely discover your cheating. This will, without exception, spell misery for
you, your family, your friends, and your pets, from the moment of your
discovery until the moment of your demise. In short: don’t cheat. You don’t
want to cheat.

<p/>If you manage to get out of the sandbox, bring down the system, read
others’ code or influence the result unfairly, well done, You are a promising
hacker. If you do not report in timely manner, you are not qualified for any
prizes.

<p/>
Be friendly to others, and good luck coding! :-)

<h1>Time and memory restrictions</h1>
As of writing, contestants' code is restricted to 128MB and 10 seconds for a
single game (subject to change). We assume you will never practically hit this
constraint, but the restriction is necessary to keep the server running. If you

hit this restriction, your program is likely buggy. Since time and memory
restriction is shared for both players, we understand it is theoretically
possible to do memory/timing attacks and unfairly win. These kinds of wins do
not count; it is easier to create a real solution to win the Spil cap; but the
Gamesmaster code will be checked manually before the closing ceremony. Also,
obvious timing and memory attacks do not count as an "extra cap" in the hostile
environment.

<h1>Small print</h1>
We have stocked:

<ul>
  <li>
    <b>30 Spil Games summer caps (qualification).</b> First come first served;
    be sure to catch me as soon as you pass the qualification. Hurry up, the
    stock is limited!
  </li>

  <li>
    <b>5 T-shirts (for the Gamesmaster).</b> We are sorry about the unfortunate
    misfit, but only L sizes will be available.
  </li>
</ul>


{% endblock content %}

{% block end_head %}
{{ block.super }}
<link rel="stylesheet" href="{% static "css/board.css" %}">
{% endblock %}

{% block end_body %}
{{ block.super }}
<script type="text/javascript" src="{% static "js/jquery.js" %}"></script>
<script type="text/javascript" src="{% static "js/fight.js" %}"></script>
<script type="text/javascript">
    var gameplay = [79, 55, 19, 56, 22, 57, 25, 1, 20, 58, 21, 61, 80, 59, 0];
    var error = "Invalid move";
    var board = new Board(gameplay, error, $(".board_here"), $(".status_here"));
    $("#reset").click(board.board_reset.bind(board));
    $("#forward").click(board.forward.bind(board));
    $("#backward").click(board.backward.bind(board));
    $("#fastforward").click(board.fastforward.bind(board));
</script>
</script>

{% endblock %}
