Industrial Applications of Genetic Algorithms:Genetic Algorithms for Game Playing

Previous | Table of Contents | Next

RESULTS

First, consider the on-line and off-line performance of the GA population. The on-line performance measures the average fitness of all individuals through the generations. The off-line performance is the average of the best individuals over generations. Since the GA is a stochastic method, it was run ten times to help dampen out any probabilistic errors. Figure 17.1 shows that the on-line performance starts out around 80, which is fairly weak (about 20 wins over 50 games). But then it starts improving rather quickly, up to 140 just after 30 generations, and increases all the way to 165 after 70 generations. After 100 generations, it is past 170 which is very good, considering the optimum is 200.

Figure 17.1 On-line performance of the genetic algorithm.

Figure 17.2 is a plot of the off-line performance. The off-line performance starts out around 130, and begins to converge rather quickly. After 40 generations, it is around 180, and after 100 generations the off-line performance is almost 195. The best-ever string has a fitness value of 200, which means that it won every one of its games.

Figure 17.2 Off-line performance of the genetic algorithm.

An issue that needs to be considered is random moves made by the GA. Recall that in the strings, an invalid move is replaced by a randomly generated move. This random move is then put back in the string. Figure 17.3 shows the percentage of moves that were made randomly over the generations. The GA starts out by making almost 20% of the moves randomly, but as generations progress, the percentage starts to drop. After 100 generations, the number of moves made randomly is only around 3%. This indicates that as the GA begins to play the games “better” (as shown on the performance graphs), the strings also rely less and less on random moves. This is a good example of exploration versus exploitation.

Figure 17.3 Percentage of random moves made by the genetic algorithm.

The on-line and off-line performance plots might not tell the whole story. A few games were played with the strings in the GA that have top fitness values to see if they have really mastered the game as their fitness measures indicate. The results are documented in the next section.

Sample Games

Game 1

X wins the game. As one can see, X plays a very aggressive game (as the opening player should). X does not just make moves aimlessly, but it actually tries to set up its plays, the O player failed to make the right first move and X player took advantage of that.

Game 2

X wins the game. Again, X tried to set the human up and the human failed to make the right response for X’s opening move. There was no way the X player could have been prevented from winning the game after the first “O” move was selected.

Game 3

X wins the game. This time a different opening was used, but as before, the GA strategy indicates an attempt to set up its human counterpart.

Execution Performance

One popular concern with GAs seems to be execution time. When an algorithm is computing the effectiveness of 100 possible solutions in each generation, and then being run for numerous generations, the number of possible solutions evaluated can become significant. Thus, it is important to consider the amount of computational time associated with determining a solution. The GA code the current effort was run on is a SUN SPARCstation 20. On average, each generation took approximately 3.8 seconds, so over 100 generations, the program ran for just under 8 minutes.

CONCLUSION

Learning Classifier System

It turns out that the current effort is basically a simplified version of the “Pittsburgh” approach to the learning classifier system. The positions of the bits in the strings are the conditions. The actions are the contents of the strings. Here, all the possible states have been encoded into the strings. The selection process is basically a reward mechanism. Strings with good fitness values are allowed on to the next generation while the poorly fit strings are eliminated.

GA Versus Traditional AI Approach

In the early version of the GA program, the GA was allowed to make all of the decisions regarding a game, even the simple obvious moves. This resulted in longer strings, 618 bits each. With strings this long, it took the GA a very long time to develop an effective strategy. Even after 500 generations, the results were still not suitable. After the program was modified to make simple decisions by making winning moves and preventing the opponent from winning, the string length was reduced to 104 bits. This reduced the number of generations significantly. Just after 100 generations, the GA was able to play the game at “expert” level. Therefore, by incorporating traditional AI search methods (simple searches that do not take a lot of computation power) into the GA, the program was much more effective. This lends credence to the old axiom: “If you have domain knowledge, then use it.”

One of the most difficult problems in AI is the credit assignment and evaluation definition. To decide how much credit to assign to different situations is not a trivial task. Most of the time, to one extent or another, it is a trial and error process. By using GAs, the amount of work required for these problems seems to be substantially reduced. As seen from this effort, the GA does not replace the traditional AI search methods, rather, they complement each other.

Previous | Table of Contents | Next

Copyright © CRC Press LLC