CS 171 Introduction to Artificial Intelligence

First Programming Project

Your assignment is to write a computer program that plays Dots and Boxes, which we will call Dox. If you haven't played this game a hundred times on napkins at restaurants while waiting for your dinner, you might want to get in some practice. The program can be written in any language that can be run on the Windows computers in the ICS 364 lab. (If your language isn't Java, C, C++, C#, or Python, you should check first with Prof. Frost, just to be safe.) The program will run from the command line, and will not have a graphical user interface. The program will use minimax and will be able to use alpha-beta pruning.

Command line interface

We will run your program on the command line, e.g.
java Dox 3x3 A XXXX..X.XXX. AB.. 3 Y 1
for a Java program, or
Dox 3x3 A XXXX..X.XXX. AB.. 3 Y 1
for a C program.

Your program should read in seven parameters from the command line, separated by spaces:

  1. 3x3 — the number of rows (first) and columns (second) of dots, with an x inbetween.
  2. A — the player whose turn it is, A or B
  3. XXXX..X.XXX. — a string in which X indicates a line that has been drawn, and . indicates a space between two dots. The locations are indicated in the following order: horizontal locations, top to bottom, left to right, then vertical locations, left to right, top to bottom. For instance, with a 3 x 3 board, with asterisks indicating dots, the line locations are
    *0*1*
    6 8 10
    *2*3*
    7 9 11
    *4*5*
  4. AB.. — a string indicating which boxes belong to which player, A, B, or . meaning the box's walls are not complete. For instance, with a 3 x 3 board, with asterisks indicating dots, the box locations are
    * * *
     0 1
    * * *
     2 3 
    * * *
  5. 3 — a number indicating the maximum number of plies the algorithm should look ahead.
  6. YY indicates that alpha-beta pruning should be used, N means don't use alpha-beta
  7. 1 — indicates which board evaluation heuristic shold be used. 1 is a supplied simpleBoardEval method, and 2 is one that you write.
Using these parameters, your Dox program should select a move and print it on the console (standard output). (Your program doesn't have to play a full game, it need only select a move.)

Your program

The programming assignment is:

  1. Implement a minimax-based routine that employs alpha-beta pruning when (and only when) instructed to do so on the command line. Note that your AI should always return the same move with and without alpha-beta pruning. The method should use either simpleBoardEval() or customBoardEval(), as indicated on the command line. The method should do minimax search to the specified depth (or perhaps less, when a final state is reached).
  2. Write a customBoardEval() that is superior to simpleBoardEval().
Starter code, in Java, is provided in Dox.java and DoxBoard.java. If you are not programming in Java, you may still find this code worth utilizing.

Later in the quarter, we will have a tournament, in which all the Dox programs compete. (You can update your code for the tournament.)

Your report

You will also write a report, the quality of which will be a significant factor in your score for the project. It should contain the following information:


How to turn in the project

The project is due at 11:55 pm on Sunday, Feb. 10. The project will be turned in by uploading it to the EEE DropBox "CS 171 - Proj 1".

  1. Source code: turn in all your source code. Your source code should be at the top level, not, for instance, in a src/ subdirectory.
  2. Executable: Dox.class, Dox.exe, or whatever. At the top level.
  3. Project report: a .doc, .docx, .txt, or .pdf file.
Put all your files in a zip file called Dox.zip.

To evaluate your implementation, we will log onto an ICS lab Windows computer, open a command prompt window, cd to a folder containing your .unzipped files, and enter

java Dox parameters
or whatever is appropriate for your programming language. It is strongly recommended that you test your system using this same technique. Projects that work "on your machine" or "only in Eclipse" or "only if you enter something special on the command line" will not receive full credit. Projects that have missing files, or files in subfolders, will be penalized.