CS4341 Introduction to Artificial Intelligence. A97

Department of Computer Science
Worcester Polytechnic Institute


This term project consists of developing and implementing a Lisp program that plays Go-moku. Go-moku, also known as "five in a row", is a board game similar to tic-tac-toe but on a larger board.


(For simplicity, the following game description will use "he" to refer to a player, even though "he/she/it" would have been more appropriate.)

Go-moku is a two player game (one of them being your computer program). The two players take turns putting marks ("stones") on a board. The player who first gets 5 of his marks in a row wins.


A game will consist of a sequence of the following actions:
  1. It is selected at random which player will use the white stones and which player will use the black stones. In what follows, the player that gets to use the white stones is called player 1 and the player that gets to use the black stones is called player 2.

  2. Player 1 gets to play first.

  3. After player 1 has made his first move, player 2 is given the chance to change the color of the stone on the board to black. This is done to limit the advantages of playing first.

    For example, if the first move is (white E 7) and player 2 decides that he wants that position, then player 2's first move can be (black E 7).

    This is the only time during the game that a player is allowed to put a stone in an already occupied intersection.

  4. After that, player 1 and 2 take turns making moves. A move (color column row) should satisfy the following constraints:
    1. Time Limit There is a 2 minute time limit for a player to make his move. (2 min. user time, not CPU time.)
    2. Move preconditions
      1. color is white if it is player 1's turn and black if it is player 2's turn.
      2. The intersection of column and row on the board is empty. (The only exception to this precondition is during player 2's first move as described above.)
    3. Move postconditions
      1. After the move, the intersection of column and row on the board will be occupied by a color stone.
      2. It will be the other player's turn.

  5. The game ends when either of the following two cases:
    1. one of the players gets five of his stones in a row (vertically, horizontally, or diagonally). This player wins the game, and the other loses the game.
    2. all the intersections on the board are occupied. In this case, both players lose .


The project assigment consists of the following:
  1. Your group should implement a Lisp program that plays Go-moku.
  2. Your program should use a game strategy:
    • Use a static evaluation of your choice
    • Use a heuristic of your choice
    The better your static evaluator and your heuristic, the better your grade in the project.
  3. Your program and its opponent will communicate ONLY through a file called "move_file". During its turn, your program should write its move in the file; and during its opponent's turn, your program should read the move of the other player from the file. Assume that this file "move_file" is located in the same directory where your program is.
  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.
  7. If you want, you may implement a graphical interface for your program, that displays the configuration of the board during the game. Such interface is NOT required.



One partial and one final project report are required. Report I is due on Monday, Sept. 22. Report II is due on Friday, Oct. 10. Code documentation must follow the Departmental Documentation Standard (see
  1. Report I
    Due on Monday, Sept. 22 at 1:30 pm.

    In this report your group should specify:

    1. the static evaluation your program will use,
    2. the heuristic you plan to employ, and
    3. a discussion of why the proposed evaluation function and the proposed heuristic are good choices.

    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 Go-moku 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.

  2. Project and Final Report
    Due on Wednesday, Oct. 15 at noon.


A referee program will be provided. This referee program will be in charge of deciding which program goes first, giving turns to the programs, displaying the board configuration, detecting faulty moves, and enforcing time limits.

This referee program is being written by a group of 3 BS/MS students, who are taking CS4341 for graduate credit. They also participated on establishing the following set of rules and conventions for the tournament.

Rules and Set of Conventions for the Tournament.

  1. Each group needs to pick a one-word name for its program. We'll refer to that name as groupname in what follows.
  2. Each group should submit the Lisp code of its program [groupname]. lsp and the compiled file [groupname].o Lisp compilation can be done via:

    (compile-file "[groupname].lsp")
    (load "[groupname].o")

    in gcl (on alpha machines)

  3. During a game, the two playing programs will be run in parallel on separate Lisp environments.
  4. Each program will have two interface files:


    The program will read input from [groupname].in and output its moves to [groupname].out

    1. At the beginning of the game, the file [groupname].in will contain the letter W, if the corresponding program should play with the white stones, and the letter B otherwise. The referee program will take care of creating this files making this assignment at random. After reading its color, the program must DELETE the [groupname].in file, so the referee program knows that the player knows its color. In what follows, the program that gets to use the white stones is called groupname1 and the program that gets to use the black stones is called groupname2.
    2. Groupname1 writes its first move, say (W C 9), to the file [groupname1].out Then, the referee will copy this move into [groupname2].in so the second program can read the move. After reading this move, groupname2 must DELETE the [groupname2].in file, and before exceeding its time limit, write its move to [groupname2].out, say (B A 6). The referee program will read this file and copy it into [groupname1].in, and the whole process is repeated until the game is over. Note that a program will know that it is its turn by the presence of a [groupname].in file. After reading that file, the program must delete it. Also, the program should CLOSE (not delete) [groupname].out at the end of its turn and re-create it on its following turn.
  5. The referee program will be in charge of:
    1. Assigning which program goes first, as described above.
    2. Displaying the board configuration after each move.
    3. Giving turns to each of the playing programs. By creating the file [groupname].in, the referee program is giving the turn to groupname.
    4. Timing each of the players. It starts measuring the time for groupname's move just after creating groupname.in If a program exceeds its time limit, the referee program will stop the game, announcing that the offending program has lost. (Note that a program should not time its opponent.)
    5. Detecting invalid moves. If the referee program finds an invalid move, it will stop the game, announcing that the offending program has lost.
    6. Ending the game when all positions on the board are occupied, announcing a draw.
    7. Ending the game when one of the programs completes 5 marks in a row, announcing the winner.


There are several web pages where you can find more information about Go-moku and/or where you can play Go-moku. Some 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 GO-MOKU 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 abot Go-moku, please let me know and I'll add it to the previous list.