WPI Worcester Polytechnic Institute

Computer Science Department

CS4341 Introduction to Artificial Intelligence 
PROJECT 1 - C 2000


Due Date: Tuesday, February 8, 2000 at 6 pm. 


This project consists of developing and implementing a computer program that plays tic-tac-toe against another player.


Tic-tac-toe is a two player game (one of them being your computer program). The two players take turns putting marks on a 3x3 board. The player who first gets 3 of his/her marks in a row (vertically, horizontally, or diagonally) wins the game, and the other loses the game.

Game Rules

A game will consist of a sequence of the following actions:
  1. Initially, your program should ask the user which marks the user prefers ("X" or "O"). The player that gets to play with the "X" marks will play first (we call him/her player 1) and the player that gets to play with the "O" marks will play second (we call him/her player 2).

  2. Player 1 and 2 take turns making moves. A move (mark row column) should satisfy the following constraints:
    1. Time Limit There is a 1 minute time limit for a player to make his/her move. (1 min. user time, not CPU time.)
    2. Move preconditions
      1. mark is "X" if it is player 1's turn and "O" if it is player 2's turn.
      2. The position (row, column) on the board is empty.
    3. Move postconditions
      1. After the move, the position (row, column) on the board will be occupied by a mark .
      2. It will be the other player's turn.

  3. The game ends when either:
    1. one of the players wins the game, i.e. this player gets three of his/her marks in a row (vertically, horizontally, or diagonally).
    2. all the positions on the board are occupied. In this case, the game ends in a draw.


The project assignment consists of the following:
  1. You should implement a computer program that plays tic-tac-toe following the rules described above.
  2. Your program should use:
    • minimax with alpha-beta pruning, and
    • a game strategy:
      • Use utility and evaluation functions of your choice
      • Use a heuristic of your choice
    The better your game strategy, the better your grade in the project.

    (Finding a good static evaluation function and a good heuristic depends heavily on the experience you have with the game. I recommend you start playing the game and getting the flavor of what a good tic-tac-toe strategy is. Also, research the strategies that other people have used for this and other games. Lots of information can be found in the references listed in your syllabus, the web, and magazine articles.)

  3. You can design the program-user interface as you like, but make sure that your program is *easy* to use (avoid having complicated input codes). Shortly state the interface conventions to the user at the beginning of the game, and display the configuration of the board after each move.
  4. Your program should produce only valid moves.
  5. Your program should verify that each of the opponent's moves is valid, and should execute them.
  6. Your program should detect if the game has come to an end, and if so, it should print a message stating who wan.


Project 1 is due on Tuesday, Feb. 8 at 6:00 pm. Code documentation should follow the
Departmental Documentation Standard. One (and only one) member of each group should submit the following files using the turnin program.


There are several web pages where you can find more information about tic-tac-toe and/or where you can play tic-tac-toe. Just a couple of this web pages are listed below. I encourage you to find more sites about the game using a net search engine. You may benefit from seeing other implementations of the game, BUT YOU MUST DEVELOP YOUR OWN TIC-TAC-TOE PROGRAM. Beware: some programs on line may use a set of rules different to the one describe above.

If you find a web page with useful information about tic-tac-toe, please let me know and I'll add it to the previous list.