TIC-TAC-TOE: introducing expert systems to middle school students

Machines that play simple games have been a part of the development and promotion of computers for years. Charles Babbage conceived of a machine to play tic-tac-toe in an effort to obtain funding for his Analytical Engine. As part of the Summer Computer Science Workshop, participants design and implement a rule base for an expert system that plays the game of X's and O's (tic-tac-toe). This simple game was selected because most middle school age students are already domain experts. The participant has to select and order six or fewer rules with a seventh catch-all rule, “Take any available position.” The designers debug their own expert systems by playing the game and modifying their rule bases. Once they are satisfied with thier own design, they play against each other's expert systems in a round-robin tournament. The development environment, written in Pascal to run under MS-DOS, displays the current state of the game board and lists the rules with the most recently “fired” rule being highlighted. This program is far from a complete expert system, but it does illustrate a number of principles of expert systems design. Like most expert systems, a reasonable solution to the tic-tac-toe problem can be embodied in a surprisingly small rule base. No more than seven rules are needed to play a perfect game of tic-tac-toe, and the same rule base is valid whether the opponent or the computer makes the first move.