It is strongly suggested before running any other experiments that you first do a run or two with XOR to verify that everything is set up and working properly.

Tic-Tac-Toe is a traditional 2-player game in which players take turns placing tokens on a 3x3 grid with the goal of being the first to place 3 tokens in a row horizontally, vertically, or diagonally.

It is a simple and useful domain to use as a jumping off point for board games in general. At the GECCO 2004 conference we presented a paper entitled "A Comparative Analysis of Simplification and Complexification in the Evolution of Neural Network Topologies" which uses Tic-Tac-Toe as an experimental domain. We recommend reading this paper, as it includes a full description of our primary representation, as well as a good overview of NEAT.

Before doing any run, it is a good idea to look at the properties file for any domain in ANJI and become familiar with them. Please see the Parameter Descriptions page first (scroll down for parameters specific to game domains such as Roshambo and Tic-Tac-Toe). In the current ttt.properties file, the follow settings for properties are listed:

tournament.direct.opponents=bad, best

This means that neural network members of the population will have their fitness assigned each generation based on their performance against hand-coded players, in this case "bad" and "best" (see the paper above for descriptions of how these players play).


These properties indicate the hierarchical structure of tournaments in ANJI. In this example, each neural network each generation will play one match of 100 games against each hand-coded player. The networks will be reset between each game (i.e., values from recurrent activations will be flushed out). Results will be logged at the match level, but the results for every individual game will not be displayed. In games in which players take turns, players alternate going first every other game.

To perform a run with Tic-Tac-Toe using these parameters, follow the steps below.

1) Open a command shell (from the Start menu select Run..., type "cmd", select OK).
2) Navigate to the anji_2_00/ directory.
3) Type "evolve.bat ttt.properties" and press Enter.

1) Open a command shell.
2) Navigate to the anji_2_00/ directory.
3) Type "evolve.sh ttt.properties" and press Enter.


ANJI will first display copyright and version, then print all the properties for the run. Then, for each generation, information such as the following will be displayed:

INFO Run: start
INFO Generation 0: start
INFO match. 109 vs TTT Best Player: 0-100-0: 0 vs 100-0-0: 078 ms
INFO match. 109 vs TTT Bad Player: 70-22-8: 0 vs 22-70-8: 063 ms
INFO match. 110 vs TTT Bad Player: 53-47-0: 0 vs 47-53-0: 031 ms
INFO match. 110 vs TTT Best Player: 0-100-0: 0 vs 100-0-0: 063 ms

ANJI logs the results at the match level. Win-Loss-Tie records are displayed, along with time elapsed. In this case, Chromosome 109 lost every game to the Best player, but had 70 wins, 22 losses, and 8 ties against Bad. Chromosome 110 performed even worse against Bad and lost every game against Best.

At the end of each generation the following information will be displayed:

INFO connection->neuron id map size == 15
INFO neurons->connection id map size == 192
INFO species count: 1
INFO # chromosomes with max fitness: 0
INFO champ: id=163 score=0.625 size=109
INFO Generation 0: end [09:55:49 - 09:55:55] [5469]

The size of the neuron and connection id maps are displayed to give an idea of how much new topology is being added. The number of species in the population is displayed, along with the number of chromosomes to reach max fitness. The fittest individual is listed, along with its score (which is a percentage of the maximum possible fitness of 1), and its size, or number of neurons and connections, is listed. The start and end time and total elapsed time are all shown for the generation.

In the above example, the champion chromosome had ID 163. To evaluate the performance of the chromosome using the settings in the properties file:

Type "evaluate.bat ttt.properties 163" and press Enter.

Type "evaluate.sh ttt.properties 163" and press Enter.


After ANJI displays the properties for the evaluation, you should see output similar to the following:

INFO match. 163 vs TTT Best Player: 0-42-58: 0 vs 42-0-58: 0109 ms
INFO match. 163 vs TTT Bad Player: 97-2-1: 0 vs 2-97-1: 063 ms
INFO opponent 1: TTT Best Player: 42-0-58: 0: 42.0
INFO opponent 2: TTT Bad Player: 2-97-1: 0: -95.0
INFO Chromosome 163: fitness = 63250/100000

This individual has already evolved to a point where it can tie Best about half the time and beat Bad consistently. Its fitness is 63.25% of the maximum.

If you wanted to evaluate the chromosomes against other hand-coded players, simply add or change the tournament.direct.opponents property.