Homework 3
Game Playing using MiniMax
Due: Friday, October 5th, 11: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
- When it is their turn, players may place either an X or an O.
- First player to cause the board to get three of any single pieces in a
row, wins.
Thus, in theory, the shortest game is 3 moves since both players could place
Xs (although that would mean that player two played very foolishly).
Instructions
For this homework you should write a Java program (other language POSSIBLE
upon pre-approval) that fits the following requirements
- Your code must provide an easy way for me to indicate the current state of
the board.
- 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 first, a move which makes the win if
possible, second, a move which avoids losing if possible, and finally, a move
which keeps the game going. The more advanced definition of optimal
states that when there are multiple ways to keep the game going, you pick the
move which keeps the game going the longest.
- When an optimal move is found your code needs to print out the specific
move to take ("X in cell 9") and an indication of whether this move will
eventually lead to a win, a lose, or a draw..
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 do I indicate the pieces (X and O, 1 and 0, 1 and -1, etc)
- How are you numbering the board? (0-8, 1-9, a-i, etc).
- How are you "scoring" the outcomes (1/0/-1, -100 to +100, etc)
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 any 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 lab at the start of class on the day
this lab is due.