Logic Programming

Nine Board Tic Tac Toe

Recall the game of Nine Board Tic Tac Toe introduced in the first lesson. Your goal in this assignment is to formalize these update rules for this game.

As our ontology, we use the symbols x, o, and blank to represent marks on the board (the two players and the "empty mark"), and we use the digits 1, 2, 3 as indices for row and columns of cells and rows and columns of sub-boards.

We use a single 5-place predicate location to represent the state of the board. For example, the sentence cell(1,2,3,1,x) means that the board in the first row and second column contains an x in its third row and first column. We use the binary predicate current to designate the current board. For example, the sentence current(2,3) means that the board in the second row and third column is current. We use the unary predicate control to describe whose turn it is to play. For example, the sentence control(x) means it is X's turn to play.

In addition to this basic vocabulary, we use the 4-ary operator mark to represent a move in the game. The action mark(1,2,3,1) refers to the action of placing the mark of the player in control in the third cell and first column of the board in the first row and second column.

Your task on this assignment is to define the effects of the mark operation on cell, current, and control.

To make things easier for you, we have created a specialized editor for game rules. Click here to load the editor. This one looks like the usual game, but it contains some additional features to help you with your work.

Below the sheet on the left is a box that shows the data corresponding to the current state of the game. As you move, the data in this box changes. Note that you cannot modify this data directly. You can change it only by checking and unchecking checkboxes.

Below the sheet on the right is a box containing the rules defining the mark operation (initially empty). Unlike the situation with the data box, you can modify the rules shown here. Simply click in the box and enter your rule set. Once you are happy with your rule set, click Save and the new rules will take effect.