3D TicTacToe

Introduction

The official TTT assignment is here. The basic idea is to implement a 3D TicTacToe player for the 4x4x4 case. You will be required to implement the minimax and alpha-beta pruning algorithms. Grading will be based on the basic correctness of your code as well as the comparative performance of your program as determined by means of a tournament after the assignment is completed.

Quick Start

To jump right into the code, check out the code. There are four files:

Manual

General

A server will sit on cycle2 at port 6666 waiting for TicTacToe players. If the server seems to be down, please email me (jkramer@cs) right away. The server understands some basic commands. Please feel free to telnet to port 6666 of cycle1 and play with it by hand, as the interface is plain English. The commands are as follows:
  NAME  - set our name to  ( can be "ANY")
  PLAY  - play a game against  ( can be "ANY")
  MOVE  - make move 
  LIST - list available players
  WATCH  - watch 
  QUIT - exit
  
The player who joins a game second is X and goes first. Responses from the server are generally of the form "OKAY <...>" for a successful command and "ERROR <...>" for a failure. When playing, you will receive "MOVE <...>", "TIE <...>", and "WIN <...>" as well. When watching, you will receive "GAME O" or "GAME X" messages.

The interface for your code is simple. 3dttt.lisp provides utilities to interact with the server. All you need to do to create a player is create a (make-move last-move board) function. The first parameter will be the latest move in the game, and the second parameter will be a 64-element array where 0s are blank spaces, 1s are your spaces, and -1s are your opponent's. The return value of this function must be an integer between 0 and 63, as the board is represented as a one-dimensional array on the server and client alike. The reasoning for passing both the latest move and the board array to your function is that you may like to keep an internal board representation aside from the array, so this will allow you to update it. spot.lisp is a player that completely ignores the board array while keeping an internal representation.

A note about Python:

Because we seem to have an old version of Python installed on the CSUG network, the python programs ttthuman.py and tttwatch.py point to /u/jkramer/public/bin/python2.2 as their interpreter. I installed Python 2.2 on Linux only, so you will have to be logged into a Linux machine (in the lab or cycle1 2 or 3 etc. if working remotely). Of course, the lisp works fine with the public version.

3dttt.lisp

Everything in 3dttt.lisp resides within the 3DTTT package, so functions must be called appropriately, as in (3dttt:connect). See the code for the details of the implementation. The exported functions are as follows: See the code for additional functions that are not exported if you're curious, but the above is the extent of the interface you need deal with.

spot.lisp

This is a simple random player. See the code for details of the implementation. To use the player, do something like the following:
  (load "3dttt.lisp")
  (load "spot.lisp")
  (3dttt:connect)
  (3dttt:login 'spot)
  (3dttt:play-game 'fluffy)
  

ttthuman.py

Usage: "ttthuman.py" or "ttthuman.py <port>" or "ttthuman.py <host> <port>"

The program will then ask you for your name, attaching "[H]" to the end to indicate the player is human. Upon successful login, the program will then prompt you for a player name to play against. Players can be chosen from the provided list or typed in by hand. "ANY" is the default choice.

tttwatch.py

Usage: "tttwatch.py" or "tttwatch.py <port>" or "tttwatch.py <host> <port>"

The program will ask you for a currently logged-in player to watch. From then on, all games played by that player will be displayed as they happen.