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. The files to look at are:


You can use either 3dttt.lisp or TTTPlayer.java as a basis for your own player, or you can make your own. You may find it easier to work in a dynamically typed --- rather than statically typed --- language (try for instance Python).

Manual

General

A server will sit on cycle1 at port 6666 waiting for TicTacToe players. If the server seems to be down, please email us (prof or TAs) 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/TTTPlayer.java provides utilities to interact with the server. If you use the given code, all you need to do to create a player is create a (new-game) and (make-move last-move board) function (there are analogues in the Java version) . 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:

Due to package updates, the provided Python programs will not be working properly until at least 1/19/10. However, they are not necessary to using the server (or writing or testing your own agents); this can be done via telnet.

The Java examples are based on the Lisp, and are commented.

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.