Question: Python 3 - Tic Tac Toe 2 Players. Will Thumbs up if the code runs The goal of this lab is to practice problem solving

Python 3 - Tic Tac Toe 2 Players. Will Thumbs up if the code runs

Python 3 - Tic Tac Toe 2 Players. Will Thumbs up if the code runs The goal of this lab is to practice problem solving by implementing the Tic Tac Toe game. Tic Tac Toe is

a game for two players who take turns to fill a 3

The goal of this lab is to practice problem solving by implementing the Tic Tac Toe game. Tic Tac Toe is a game for two players who take turns to fill a 3 X 3 grid with either o or x. Each player alternates choosing an open space in the grid to mark with either x for a player or o for the other player. The goal (to win) is to have three xs or 3 os in a row, column or diagonal. The game can also end with a draw if the grid is full but neither player has won. Some part of the Tic Tac Toe class has been provided to you in the file called Lab_TicTacToe. The initmethod in the given file is described below class TicTacToe: def init_(self): # board is a list of 10 strings representing the board (ignore index 0) self.board -[""j 10 self.board[0]-"" The constructor_init_creates a list of 10 objects of type string. Each of these string objects would have the empty space character inside it. The first one at index 0 will be ignored (initialized with some character but not space) and the other 9 represent the 9 cells of the 3 x 3 Tic Tac Toe gricd You have to complete the lab by completing the three tasks described below: Task 1 Implement the methods assignMove and drawBoard in TicTacToe class 1.1 The method assignMove (self,cell, symbol) requests the Tic Tac Toe object to assign the symbol to the cell of the grid. The parameter cell should be a valid integer value between 1 and 9 (both end points inclusive). The method must check the validity of the value of cell before proceeding to assign the symbol to it. For the second parameter symbol, you may assume that symbol is an object of type str and is always either 'x or 'o'. 1.2 The method drawBoard (self) would display the board as follows The first grid on the left represents the current state of the board while the grid on the right is static, and represents the index of each cell (like the numeric pad on the keyboard). The two grids are separated by a tab (It) Once you have completed Task 1, test your methods by creating an instance of TicTacToe by writing the following line of code in the main function that is provided in the given file myBoard-TicTacToe() th Fill some cells in the board using the assignMove method. For example to put an x in the 4" "cell write the following The goal of this lab is to practice problem solving by implementing the Tic Tac Toe game. Tic Tac Toe is a game for two players who take turns to fill a 3 X 3 grid with either o or x. Each player alternates choosing an open space in the grid to mark with either x for a player or o for the other player. The goal (to win) is to have three xs or 3 os in a row, column or diagonal. The game can also end with a draw if the grid is full but neither player has won. Some part of the Tic Tac Toe class has been provided to you in the file called Lab_TicTacToe. The initmethod in the given file is described below class TicTacToe: def init_(self): # board is a list of 10 strings representing the board (ignore index 0) self.board -[""j 10 self.board[0]-"" The constructor_init_creates a list of 10 objects of type string. Each of these string objects would have the empty space character inside it. The first one at index 0 will be ignored (initialized with some character but not space) and the other 9 represent the 9 cells of the 3 x 3 Tic Tac Toe gricd You have to complete the lab by completing the three tasks described below: Task 1 Implement the methods assignMove and drawBoard in TicTacToe class 1.1 The method assignMove (self,cell, symbol) requests the Tic Tac Toe object to assign the symbol to the cell of the grid. The parameter cell should be a valid integer value between 1 and 9 (both end points inclusive). The method must check the validity of the value of cell before proceeding to assign the symbol to it. For the second parameter symbol, you may assume that symbol is an object of type str and is always either 'x or 'o'. 1.2 The method drawBoard (self) would display the board as follows The first grid on the left represents the current state of the board while the grid on the right is static, and represents the index of each cell (like the numeric pad on the keyboard). The two grids are separated by a tab (It) Once you have completed Task 1, test your methods by creating an instance of TicTacToe by writing the following line of code in the main function that is provided in the given file myBoard-TicTacToe() th Fill some cells in the board using the assignMove method. For example to put an x in the 4" "cell write the following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!