Homework 2
Game Playing using MiniMax
Due: Wednesday, February 25th, 1:00 PM
Introduction
Consider the following variation to tic-tac-toe
- Players alternate taking turns placing a piece on a standard tic-tac-toe
board
- Player 1 is always X, player 2 is always O.
- The first player to cause the board to get three pieces in a row LOSES.
- If all nine spaces become filled without obtaining 3 in a row the game is
a draw.
Instructions
For this homework you should write a program that fits the following requirements
- Your code must provide an easy way for me to indicate the current state of
the board as a single String. You may assume that the string will be of
length 9 and consist of the characters X, O, and - (meaning that position is
empty)
- You must devise a solution which uses minimax to search for the optimal
move for the current player. The definition of optimal here is a little
squishy. The base definition is
- a move which makes the win NOW if
possible
- a move which makes the win in the future if possible
- a move which avoids losing if possible (a draw)
- a move which causes a lose some time in the future
- a move which causes the game to be lost NOW
- When an optimal move is found your code needs to print out the specific
move to take and an indication of whether this move will eventually lead to a
win, a lose, or a draw. (eg "X in cell 9 will result in a win")
You must also produce a short "read me" file (readme.txt) which explains to
me, the tester, how to use your program. This includes:
- How do I provide the input? (command line during execution, command
line on invocation, hardcoded in the code, etc)
- How are you numbering the board? (0-8 or 1-9).
- How are you "scoring" the outcomes (1/0/-1, -100 to +100, etc)
Some assumptions you may make to assist with the assignment (although
you are not required to do so)
- Player 1 is always X and is max
- Player 2 is always O and is min
- You can determine whose turn it is by considering the state of the board
("XXO------" clearly is a board where it is now min's turn)
Submitting Your Work
Prior to the deadline, use the homework submission system (http://math-cs.cns.uni.edu/~schafer/submit/which_course.cgi)
to upload a zip file of all files you have produced. Make sure you submit all of the
files needed to use your code.
In addition to online copies, please submit hard copies of this assignment at the start of class on the day
it is due.