AI代写:CS213 Tie-Tac-Toe



For this assignment you are asked to comment a provided program in Java for playing the Tic-Tac-Toe game on a 3x3 grid and then extend the provided program for playing Tic-Tac-Toe on a 5x5 grid. Tic-Tac-Toe is also called Noughts and Crosses. For details about the game, visit

Task 1: Commenting the Provided Code

The provided code is available. Your comments on the provided code should clearly demonstrate your understanding of the program, in particular the minimax search method. It may be a good idea for you to compile and run the provided code in the first place to get a better understanding about what the program can do.

The general guidelines for commenting are as follows:

There are two types of comments: documentation comments and implementation comments. Documentation comments describe the semantics of a class or method. Good documentation comments should allow someone to use the class and its methods without having to read any source code. In contrast, implementation comments are used to clarify how a particular piece of code operates. You write implementation comments when you feel they are necessary (e.g., for this assignment, it is necessary to comment on the important steps and heuristics in the minimax search method).

For this assignment, you should comment the whole provided program following the above guidelines. In particular, you need to comment on every line of the code for the minimax method so as to demonstrate your understanding of the minimax search algorithm and its implementation in the program.

Task 2: Extending the Provided Code for playing Tic-Tac-Toe on a 5x5 grid:

The wining criterion for playing Tic-Tac-Toe on a 5x5 grid is 5 in a line (row, column, or diagonal line).

For playing the game on a 5x5 grid, returning values of the endgame positions in the minimax search may be unrealistic because the endgame positions are too deep. In order for your extended program for playing TicTac-Toe on a 5x5 grid to be able to make a good move within a reasonable time, effective heuristics for evaluating non-endgame positions would be needed and an appropriate depth for minimax search needs to be chosen as well, which are not implemented in the provided code. To further speed up the game, you are encouraged (not compulsory) to implement the alpha-beta pruning algorithm, which will be credited to the mark for the quality of the program (see Assessment Criteria below).

In one of the Friday classes, we will discuss how to evaluate non-endgame positions with heuristic functions.


The assignment should be submitted through the online coursework submission system (FASER). You should submit a single zip file, containing the following:

  1. A folder containing the provided code with your comments added.
  2. A folder with source files for all the Java classes that comprise your extended program for playing Tic-Tac-Toe on a 5x5 grid, with sufficient comments.


See the marking sheet in the Appendix.