Starting from:

$30

COM1001 Lab 9 -Solved

In this lab, you are expected to create a TicTacToe game using the graphics.py module, which you can download from the course page. In Figure 1, we provide the design of the TicTacToe; you will try to create your user interface similar to the provided image. The metrics in the image are pixels. Your program should not get any run-time errors, under any circumstances. For this reason, you need to consider all possible conditions.   

                                                                 Figure 1: Simple TicTacToe GUI 

 Specification details: 

1.      The game is played on a grid that's 3 squares by 3 squares. 

2.       You are X, the computer is O. Players take turns putting their marks in empty squares.  

3.       Firstly, you will start the game and put 'X' by clicking on the empty squares with the mouse. Then the computer randomly selects an empty square and puts an 'O'. This goes on until the game is over. 

4.       The player who brings 3 letters together up, down, or diagonally first wins and the game is over (Figure 1a, Figure1b). When all 9 squares are full and if no player has 3 marks in a row, column or diagonal, the game ends in a draw (Figure 1c). 

5.       You have to check if the clicked square is empty. If player X clicks on a filled square (on X or 

O), you must print a warning message: “You cannot click the filled squares!” and you must wait until a valid move. As seen in Figure 2, when the player clicks on X or O, the warning message is printed. Then, when the user clicks on an empty square, the warning message is deleted and the game continues. 

6.       When someone wins the game, new moves will not be allowed, e.g., new clicks on remaining empty squares will be ignored. 

7.       The GUI name will be your student id. So you should write your id where it is written TicTacToe in Figure 1. 

8.       When someone wins the game or ends a draw, pressing 'q' closes the window. 

 Fig

 

More products