Yinsh

An advanced YINSH player

7.1 Heuristics

Some simple AI examples were shown during the previous chapters. To create a more advanced AI player which could perform well on the tournament, a good evaluation function was necessary.
In an attempt to create an interesting AI, the following factors were concidered when giving an heuristic value to a gameboard:

This returns in a total of 14 parameters which were trained using the evoluation algorithm. To speed up training, the first parameter (difference in won rings) was set to a very high value and not being adjustable for training, meaning that having one ring more than the opponent would always be more important than any other feature. All the other parameters were initialized on 1.0, and trained to a value between [0.0,10.0[.

Also, a distance calculator was created to calculate distances between several locations on the gameboard (in order to determine p3 & p4).
Since we are dealing with points in a space where only movement along axes is possible, the manhattan distance was used. However, due to the choice of representation of the gameboard a special implementation was needed for correctly calculating the distance between two datapoints.
The Manhattan distance calculates the distance between two points measured along axes at right angles. In a plane with p1 at (x1 , y1) and p2 at (x 2, y2), it is |x1 - x2| + |y1 - y2|. Since our axes are actually not equally set up as in the YINSH gameboard, we get the following errors:

Figure 7.1

 

Figure 7.2 illustrates the technique used to calculate the Manhattan distance.

Figure 7.2
Figure 7.2 - : when you want to know the distance between 2 locations, gradually move towards the other location first along the X-axis, and when that is equal, then along the Y-axis. Every move increases the total distance with 1

This results into the following AI:

 

7.2 Evolution

To train the weights of the heuristics, an evolution was started using 30 chromosomes (5 default, 25 randomized) during 30 generations which lasted around 6 hours. Fitness was calculated simulating 50 games on white and 50 games on black. The fitness score is calculated as follows: every win provides 3 points and every draw 1 point. The points are then added up and squared to strengthen small differences in win results. During this evolution, the tree search was set off and the move that lead to the board with the highest heuristic value was returned. Figure 7.3 illustrates the perceived evolution.

Figure 7.3
Figure 7.3 - The perceived evolution

It is clear that there is an evolution in the weights and the fitness, although the evolution of the fittest chromosome goes quite slowly. The variance in the fittest chromosome is due to the randomized play of the opponent in combination with the fitness function which strenghtens the difference in the amount of won games (since only 100 games are played for calculating the fitness). As an estimation, training for at least 400 generations is needed to evolve towards an optimal solution.

The learned weights however prove that the difference in amount of markers is indeed not an important feature and prove the importance of having rings close to enemy markers or markers that can be switched to form a row.

Figure 7.4

When matching up the advanced AI (playing the move leading into the board with the highest heuristics) against the basic AI, 500 games lead into 405 wins (and 3 draws).

 

7.3 AI Behaviour

The advanced AI's behaviour has 2 different stages:

  1. ring placement
  2. ring movement

Since the placement of the rings takes in total 10 turns, it is very hard to use tree search to define the best moves. Therefore, a ruleset was written to place the 5 rings on the board which uses the following tactic:
Since the center of the board is very important, the AI will try to put as many rings in the center, avoiding putting markers on the same line (since that might block his movement). This is achieved by following a spiral web around the center. When such a move is no longer possible, the AI will try to place his rings as close to an opponents ring and still close to the center.

During the ring movement stage, the AI performs a tree search with a fixed depth of 3 plies, combined with the trained heuristics for defining the best move.

Although the AI proved to be very powerful during the tournament (esp since the low depth search compared to other competitors), some flaws in the behiaviour showed up:

When this advanced YINSH player is matched up against the random player for 20 games, 2 conclusions can be made. Firstly, the advanced AI beats the random AI very quickly: on average, 28.9 turns are needed. Secondly, the number of expanded nodes decreases very fast and its averages rawly take the shape of a reciprocal function (cfr figure 7.5). Note that measuring was started at turn 10, since the placement of the rings doesn't use tree search for deciding the move.

Figure 7.5
Figure 7.5

 

<<< Previous | Index | Next >>>