ECS 170- Introduction to Artificial Intelligence; Homework Assignment #2
(70 points) – A third problem, discussed in the class, has been added at the end
Assigned: 21 January 2003
Due: 28 January 2003
(1) (25 points, 5 pts for each part) Consider the game of Tic-tac-toe. The game involves playing on a board with 9 squares arranged in a 3 x 3 grid. Two players take turns; one player puts a token (a cross) and the other puts another token (a circle) in one of the available empty squares of the game board. The play continues until one of the players gets all three of his/her tokens in a row, column or along a diagonal.
(a) Make an estimate of the number of states of this game. Do not just give a number. Show how you got it.
(b) Show the whole game tree starting from an empty board down to a depth 2 (i.e., one X and one O on the board, taking symmetry into account (you should have 3 positions at level 1 and 12 at level 2)
(c) Using the evaluation function
mark on the tree the evaluation of each board at level 2. Here defines the number of rows, columns and diagonals with exactly n X’s no O’s. Similarly, is the number of rows, columns and diagonals with exactly n O’s.
(a) Mark on your tree the backed-up values for the positions at levels 1 and 0, using the minimax algorithm and then use them to choose the best move.
(b) Circle the nodes that at level 2 that would not be evaluated if alpha-beta pruning were applied, assuming that the nodes are generated in the optimal order for alpha-beta pruning.
(2) (25 points, 8/8/9 points for the parts) Let us continue with the tic-tac-toe problem. Now we are interested in looking at the programming aspects of this problem. One of the first issues we have to tackle is the representation issue. Toward this goal let us make a few attempts.
(a) First attempt: TTT1: Let us define a data structure as shown below.
· | 1 | 2 | 3 |
· | 4 | 5 | 6 |
· | 7 | 8 | 9 |
Each element contains the values
Make brief comments on this method by identifying at least two advantages and two disadvantages. If you see more than two advantages/disadvantages, pl. mention them. (You should consider issues like efficiency, ease in programming, ease in understanding the strategy and the ability to change the strategy, time and space complexities, any bugs in the algorithm, generalizability to higher dimensions, and issues of that nature).
(b) Second attempt: TTT2: Let us define a data structure as shown below.
· value 2 === blank
· value 3 === X
· value 5 === O
· turn = 1 first move
· turn = 9 last move
· if player p cannot win in the next move
· Return 0
· Returns the number of square that
· constitutes a winning move
We first call posswin(us), if we can win
we make the winning move. If we cannot win we call posswin(opponent) and block
opponents move if he/she can win.
posswin checks each row, column, and diagonal
That is, Scan row/column/diag to find blank space to move to.
Algorithm in more detail:
· if(board is blank)
· if(board is blank)
· if(posswin(X) != 0 )
· go(posswin(X)) /*block opponent*/
Make brief comments on this method by identifying at least two advantages and two disadvantages. If you see more than two advantages/disadvantages, pl. mention them. (you should consider issues like efficiency, ease in programming, ease in understanding the strategy and ability to change the strategy, time and space complexities, any bugs in the algorithm, generalizability to higher dimensions, and issues of that nature).
(c) Third attempt: TTT3: Suggest an alternative formulation and an alternate algorithm (just state the algorithm in a few steps, each step in informal English) and its advantages and disadvantages.
(3) (20 points, you will lose one point for each error) In the class, I drew a tree on the board and demonstrated how to do the alpha-beta pruning. Complete that procedure for the rest of the tree and show the best move sequence for the maximizing player.