Due Thursday, April 22 at 11:59 PM via e-mail to BOTH vrastogi at u.northwestern.edu and ddowney at eecs.northwestern.edu. Use EECS 348 Homework 2 as the e-mail subject line. PDF format required. LATE ASSIGNMENTS WILL NOT BE GRADED.

Relevant Reading

Chapter 5, Sections 5.1 to 5.3.

Assignment

This assignment will be performed in teams of two to four, formed according to the 348 team-forming guidelines. The code for this assignment and the following one will be written by the team; however, each student must turn in their own homework write-up, so each team member is responsible for understanding all key pieces of the code (question 2 below) and for running the code (question 1b).
  1. Implement a tic-tac-toe program that uses Minimax and Alpha-Beta Pruning. See the implementation guidelines below. Include the following:
    1. (2 points) Your code
    2. (2 points) A output trace of your program in action, with the computer playing as the O player (moving second) in one game and the X player (moving first) in the other (each team member must do his or her own runs).
    3. (1 point) Describe who within your group performed which piece of the design/programming effort.
  2. Answer the following questions regarding your program. These answers should be succinct (two or three sentences each), but specific enough that we could almost re-implement your solution based on the answers.
    1. (2 points) How do you represent the board in your code?
    2. (2 points) Which part of your code generates the next ply, and how does it work?
    3. (2 points) What is your evaluation function, and why is it good?
  3. (2 points) How will you have to alter your code in order to play Othello? In about one paragraph, describe the changes you'll need to make and where these will occur in the code.
  4. Informed search. Consider Rubik's Cube as a search problem: the states are configurations of the six faces, operators are the standard 90 degree rotations of any nine cubes forming a face, the goal state has all six sides the same color, and the start state is random.
    1. (1 point) Design an admissable heuristic for this search problem, and state why it is admissable.
    2. (1 point) Which search algorithm would you use with your heuristic? Why?

Implementation Guidelines

You can use whichever programming language you like. Remember that a modular design for your Tic-Tac-Toe program will be helpful when you modify the code to play Othello. Thus, if you're careful about design, it will help you in answering question 3 above and make Homework #3 substantially easier.

There are lots of ways to design your program, and here's a summary of how I might do so (it's okay if you do something else). I'd work in an object-oriented language and create a Board class (which would store the game state and implement the successor function) and Player class, with subtypes of HumanPlayer (a simple command-line interface) and ComputerPlayer (an implementation of Minimax and Alpha-Beta pruning). I'd probably put the evaluation function in the Board class too, though I could see arguments for putting it elsewhere.

Minimax and Alpha-Beta pruning can be somewhat tricky to implement and debug. The reason we're starting with Tic-Tac-Toe is so teams can test their code on easy-to-understand examples. It will probably be helpful if you include test code to set your board to a particular state (i.e., one in which you know what Minimax should do) and check that the computer player returns the right moves.