Building a TicTacToe competitor

The next job is to create a tictactoe competition program that fits into the framework that allows someone to play the competitor using a browser.  I have developed this framework (consisting of 3 Python3 programs and one webpage) that you'll need, and you can add your program to the framework to run TicTacToe through your browser.

The following show the requirements for your program to fit into the framework.  Any program not fullfilling these requirements will fail to run properly and will be punished.  As an example, let's say you have the program fred.py which is your competitor program.

  1. The progam will be called by the python program on the command-line, as in:
    $ python fred.py .... {command-line arguments}...
    so make sure that your preferred python interpreter is called python (and you don't have to call python3 if you need that version of python)

  2. fred.py will be called with a number of command-line arguments, some of which it may ignore.  These arguments may be given in any order.  Here they are:

    1. result_prefix={some-string}    This argument will be given.  fred's first line of output, whether to a file or to stdout, must be the string given by result_prefix followed by '\n'.  For instance, if the argument is result_prefix=Fleep then the first line of output must be Fleep.

    2. result_file={filename}  This argument is optional.  If provided, all output should be to that file.  If not provided, output should be printed.

    3. board={9-char board}  This argument is optional and will be given if the task is to return the best next move.  Either this argument or id=1 must be given.  When this argument is provided, the output should look something like this:
      Fleep
      move=2
      Best move:  upper-right.  Draw in 4 moves.

    4. id=something   The something can be any value.  This argument is optional.  If given, then fred will output the author and title of the program.  When this argument is provided, the output should look something like this:
      Fleep
      author=Beelzebub
      title=The Best (v. 19.2.b)

    5. cutoff_time={seconds}   The maximum amount of time allocated to this program.  Feel free to ignore.  This will be enforced by the parent of this program.

  3. So, the program will either be called to compute the next best move (when the "board=" argument is given) or to identify itself (when the "id=" argument is given).

  4. When outputing the best move, also say it in English with the appropriate future claim: (as in: "Best move: upper-right. Draw in 4 moves").

  5. Typically, you'll be given 4 seconds to compute (actually, this is elapsed time, not CPU time).  Your program should be able to do this easily, without a sliderule or WolframAlpha.

  6. To show you how the plumbing works, I've included a brilliant competitor program: TTT-Random.py which will assess its opponent's personality virtues and credit score, and choose a move accordingly.

  7. Having built a competitor, it's time to try RUNNING IT (omg).