Question: Assignment Specifications Problem : The Ultimate Meta Tic-Tac-Toe. Meta Tic Tac Toe is a board game composed of nine tic-tac-toe boards arranged in a 3-by-3

 Assignment Specifications Problem : The Ultimate Meta Tic-Tac-Toe. Meta Tic TacToe is a board game composed of nine tic-tac-toe boards arranged ina 3-by-3 grid. In other words, it is a Tic-Tac-Toe board with9 tic-tac-toe games. Players take turns playing in the smaller tic-tac-toe boardsuntil one of them wins in the larger tic-tac-toe board. Each small3-by-3 tic-tac-toe board is referred to as a local board, and thelarger 3-by-3 board is referred to as the global board. In ourultimate meta tic-tac-toe game, we have a mixture of tic-tac-toes. Each localboard can be either classical (XO) or numerical (see Lab3) tic tactoe. They are initialized at the beginning of the game based ona configuration file MetaTTTconfig.txt. There are two players for the game. Thegame starts with Player 1 choosing any local board from the globalboard to start, and makes a move on that local board. Player2 then makes a move on that same local board, then Player1, and so on. The next moves must all be in thatlocal board, until that local board finishes. A local board is finished

Assignment Specifications Problem : The Ultimate Meta Tic-Tac-Toe. Meta Tic Tac Toe is a board game composed of nine tic-tac-toe boards arranged in a 3-by-3 grid. In other words, it is a Tic-Tac-Toe board with 9 tic-tac-toe games. Players take turns playing in the smaller tic-tac-toe boards until one of them wins in the larger tic-tac-toe board. Each small 3-by-3 tic-tac-toe board is referred to as a local board, and the larger 3-by-3 board is referred to as the global board. In our ultimate meta tic-tac-toe game, we have a mixture of tic-tac-toes. Each local board can be either classical (XO) or numerical (see Lab3) tic tac toe. They are initialized at the beginning of the game based on a configuration file MetaTTTconfig.txt. There are two players for the game. The game starts with Player 1 choosing any local board from the global board to start, and makes a move on that local board. Player 2 then makes a move on that same local board, then Player 1, and so on. The next moves must all be in that local board, until that local board finishes. A local board is finished once it is won by a player, or it is filled completely without a winner (i.e. a draw). Then the next player chooses another non-played local board to play, and makes a move on that local board. After a local board is finished, the corresponding square on the global board will be marked as X (when Player 1 wins the local board), o (when Player 2 wins the local board) or D (the result of the local board is a draw). To win the whole game, a player needs to win the global board. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner. Moreover, a player may win the global game if the player is the last to play a draw for a local board which results in 3 draws on the horizontal, vertical, or diagonal of the global board. Game play ends when either a player wins the global board, or all 9 local boards have been finished without a global winner in which case the global game is a draw). The game starts with asking Player 1 to choose from the global board. In the global board, 'c' represents a non-played classical tic-tac-toe, 'n' represents a non-played numerical tic-tac-toe, 'X' represents a played tic-tac-toe won by Player 1, 'O' represents a played tic-tac-toe won by Player 2, and 'D' represents a played tic-tac-toe which was a draw. The configuration file MetaTTTconfig.txt just contains 3*3 letters which are either 'c' or 'n', separated by a single white space. An example of a configuration file can be like this: Can cnc nen Using the above configuration, a complete sample game is shown in SampleOut.txt. ***Notice that if Player 2 is the first player to make a move in a local Classical Tic Tac Toe game, Player 2's mark in that local board is 'X'. Similarly, if Player 2 is the first player to make a move in a local Numerical Tic Tac Toe game, Player 2 enters odd numbers on that local board. Tasks to do Task 1 Your task will be to write the two classes: NumTicTacToe and Classic Tic Tac Toe. Hint: these are very similar to your Lab 3 exercise, and you may reuse code that you wrote for that lab (just be sure to reference that with a comment at the top of your class). Each class must implement the following methods: - __init__(): initialize the local game board, so that it is initially "empty. You may represent empty squares however you like (e.g. using a zero, or empty string, or some other representation). - drawBoard(): displays the current state of the local game board, along with the column indices on top of the board, and the row indices to the left of the board. Should not change the contents of the local game board itself. - squarelsEmpty(row, col): returns True if the local board's square at the given row, column location is "empty"; returns False otherwise. - update(row, col, mark): attempts to update the local board's contents at the given row, column location, so that the specified square changes from being empty to containing the given mark. (The mark will be a string for the Classic version; it will be an int for the Numeric version.) Returns True if update is made successfully; False otherwise. - isWinner(); returns True if the local board contains a winning line of THREE squares (horizontal, vertical, diagonal); False otherwise. In the Classic version, a winning line consists of three of the same letters (either X or O). In the Numeric version, a winning line must have a line of three squares that add up to exactly 15. - boardFull(): returns True if there are no "empty" squares; False otherwise. - is Num(): returns True for Numeric boards; False for Classic boards. Do not forget to test your classes in isolation before you write the code of the game itself. Test your class methods, one by one. Include these tests (along with comments, as appropriate) under if name == "main ": at the bottom of your Ultimate MetaTTT.pyfile. You will lose marks if you do not include these tests for us to see. Task 2 Your task will be to design a MetaTic Tac Toe class, and use the class to play games. The class will store the state of the global game. We require the following methods to be implemented: - __init__(configFile): create the game state by initializing it from the configuration file. The name of that configuration file is provided as input. Note that we may test this using different file contents than what is provided as an example in this description. - drawBoard(): displays the current state of the global board (i.e. using 'n', 'c', 'X', 'O', or 'D'), along with the column indices on top of the board, and the row indices to the left of the board. Should not change the contents of the global game board itself. - squarelsEmpty(row, col): checks if a local board at the given row, column location has been played yet or not. Returns True if the local board has not been played; False otherwise. - update(row, col, result): attempts to update the global board at the given row, column location with the result ('X', 'O', or 'D') from the local board at that location. Returns True if that board was previously marked as unplayed and the update was made successfully; False otherwise - isWinner(): checks if the current player is a winner of the global game based on their most recent move (i.e. if their most recent move ended a local game, resulting in an update of the global game board). Returns True if the current player is a winner: False otherwise. -boardFull(); returns True if the global board has no unplayed local boards; returns False if there is any local board still to be played. - getLocalBoard(row, col): returns the instance of the local board at the specified row, column location (i.e. either Classic TicTac Toe or NumTicTacToe, based on initialization), if it hasn't been played. Returns None if the local board has already been played. Do not forget to test your class in isolation before you write the code of the game itself. Include your tests (along with comments, as appropriate) under if __name__ == "_main_": at the bottom of your Ultimate MetaTTT.py file. You will lose marks if you do not include these tests for us to see. The number of required methods may seem like a lot, but many of these methods are quite small, and are designed so that interacting with the class is easier. A skeleton template class has been provided with comments as to what is expected for each method, as well as a text file of sample output and input. Task 3 Write the main program that imports these three classes and interacts with the user to play the Ultimate Meta Tic-Tac-Toe. Your final output (all displayed on the terminal screen) should match up with what is shown in the sample output when the same input is entered. General Guidelines In addition to making sure that your code runs properly, we will also check that you follow good programming practices. For example, divide the problem into smaller sub-problems, and write functions to solve those sub-problems so that each function has a single purpose; use the most appropriate data structures for your algorithm; use concise but descriptive variable names: define constants instead of hardcoding literal values throughout your code; include meaningful comments to document your code, as well as docstrings for all functions; and be sure to acknowledge any collaborators/references in a header comment at the top of your Python file(s). Restrictions for this assignment: Do NOT change the method signatures for each class - implement your classes exactly as described in the ADTs. Do not use break/continue; do not import anything other than the 3 tic tac toe classes described. Assignment Deliverables You are to submit the implemented Ultimate MetaTTT.py class file with the three classes, and main.py which creates instances of the Meta TicTacToe class and handles the playing of games. Submission Instructions Please follow these instructions to correctly submit your solution. Name your files as indicated above Submit your program at the end of this page Note that late submissions will not be accepted. You are able to submit your work as often as you like and only the last submission will be marked. So submit early and submit often. MetaTTTconfig.txt + SampleOut.txt + Ultimate MetaTTT.py + MetaTTTconfig.txt v Ccn cnc non SampleOut.txt X Starting new Meta Tic Tac Toe game 5 1 2 6 0 ccn 8 i cinc 10 2ncin 11 Player 1, please enter a row: 1 Player 1, please enter a column: 1 13 14 This is a Numerical Tic Tac Toe. 15 19 i EE 21 22 23 2 Player 1, please enter an odd number (1-9): 1 Player 1, please enter a row: 1 Player 1, please enter a column: 1 0 1 2 27 0 29 i 1| 31 33 2 Player 2, please enter an even number (2-8): 8 Player 2, please enter a row: 0 Player 2, please enter a column: 0 1 2 i 081 | B 39 i 1| E 41 2 42 Player 1, please enter an odd number (1-9): 4 43 Error: entry not odd . Player 1, please enter an odd number (1-9): 9 44 Player 1, please enter a row: 2 45 Player 1, please enter a column: 2 46 47 0 1 2 48 0 8| T 49 --- - - 501 L11 Line 1 Column 1 !!! Tab Size: 4 Plain Text SampleOut.txt x 41 42 43 44 45 2 Player 1, please enter an odd number (1-9): 4 Error: entry not add . Player 1, please enter an odd number (1-9): 9 Player 1, please enter a row: 2 Player 1, please enter a column: 2 2 0 1 0 81 48 49 50 51 52 1 |1| 53 54 2 L | 9 Player 2, please enter an even number (2-8): 6 Player 2, please enter a row: 0 Player 2, please enter a column: 1 2 0 1 58 0 86 60 1 1 622 9 63 Player 1, please enter an odd number (1-9): 7 64 Player 1, please enter a row: 0 65 Player 1, please enter a column: 2 0 1 2 68 68 | 6 | 7 69 70 i |1| 72 73 74 75 2 9 Player 2, please enter an even number (2-8): 4 Player 2, please enter a row: 1 Player 2, please enter a column: 0 0 1 2 78 686 7 79 80 1 41 82 29 83 Player 1, please enter an odd number (1-9): 5 84 Player 1, please enter a row: 1 85 Player 1, please enter a column: 2 0 1 2 88 0 8 6 | 7 Line 1, Column 1 Tab Size: 4 Plain Text SampleOut.txt Player 1, please enter an odd number (1-9): 5 84 Player 1, please enter a rov: 1 85 Player 1, please enter a column: 2 86 87 @ 1 2 88 68 | 6 | 7 89 98 14 15 91 - 92 29 93 Player 2, please enter an even number (2-8): 2 94 Player 2, please enter a row: 2 95 Player 2, please enter a column: 0 96 97 6 1 2 98 8 | 6 | 7 99 - 108 14 | 15 101 102 2 279 103 Player 1, please enter an odd number (1-9): 7 104 Error: that number has already been entered. Player 1, please enter an odd number (1-9): 3 105 Player 1, please enter a row: 2 106 Player 1, please enter a column: 1 107 108 109 @ 1 2 8 | 6 7 110 111 1 415 113 2 2 | 3 | 9 114 It's a tie. 115 116 6 1 2 117 ccn 118 1191 CDC 120 121 2ncn 122 Player 2, please enter a row: 0 123 Player 2, please enter a column: 0 124 125 This is a Classical Tic Tac Toe. 126 127 1 2 128 TT 129 ----- 138 1 1 131 132 2 O Line 1 Column 1 Tab Size: 4 Plain Text SampleOut.txt 163 160 Player 1, please enter a row: 2 161 Player 1, please enter a column: 2 162 @ 1 2 164 0 TL 165 166 1 X 167 168 2X00 169 Player 2, please enter a row: 0 170 Player 2, please enter a column: 2 171 172 0 1 2 173 174 1751 XL 176 177 2X00 Congrats! EHBO 179 180 0 1 2 0cn 181 182 183 1 CDC 184 1852ncn 186 Player 1, please enter a row: 1 187 Player 1, please enter a column: 0 188 189 This is a Classical Tic Tac Toe. . 190 191 1 2 1920 LT 193 --- - 194 1 1 1 195 --- - 196 2 197 Player 1, please enter a row: 0 198 Player 1, please enter a column: 0 199 200 201 202 0 XL 203 1 L 204 2052 206 Player 2, please enter a row: 0 207 Player 2, please enter a column: 1 208 Line 1 Column 1 Tab Size: 4 Plain Text SampleOut.txt X 466 4622 463 Player 2, please enter a row: 2 464 Player 2, please enter a column: 0 465 @ 1 2 467 XOX 468 4691 X |0 | 470 471 201 472 Player 1, please enter a row: 1 473 Player 1, please enter a column: 2 474 475 0 1 2 476 XOX 478 1 X 0 X 479 480 201 481 Player 2, please enter a row: 2 Player 2, please enter a column: 2 483 484 0 1 2 485 @ XOX 486 487 1 X 0 X 488 489 2010 490 Player 1, please enter a row: 2 491 Player 1, please enter a column: 1 492 493 0 1 2 494 X 0 X 495 496 1 X 0 X 497 498 2 0X0 499 It's a tie. 500 0 1 2 502 00 | Dn 503 504 1 X | D C 501 505 506 2nDn 507 Player 1 wins the Meta Tic Tac Toe game. GOOD GAME! 508 Do you want to play another game? (Y/N) N 509 Thanks for playing! Goodbye. Line 1 Column 1 Tab Size: 4 Plain Text UltimateMetaTTT.py X 3 4 5 6 7 # Assignment 2: Tic Tac Toe classes # # Author: # Collaborators: # References: -- class NumTicTacToe: def _init__(self): Initializes an empty Numerical Tic Tac Toe board. Inputs: none Returns: None # TO DO: delete pass (and this comment) and complete method pass def drawBoard(self): Displays the current state of the board, formatted with column and row indices shown. Inputs: none Returns: None # TO DO: delete pass (and this comment) and complete method pass def squareIsEmpty(self, row, col): Checks if a given square is "empty", or if it already contains a number greater than 0. Inputs: row (int) - row index of square to check col (int) - column index of square to check Returns: True if square is "empty"; False otherwise # TO DO: delete pass (and this comment) and complete method pass def update(self, row, col, mark): Assigns the integer, mark, to the board at the provided row and column, but only if that square is empty. Inputs: row (int) - row index of square to update col incolunda A CARL to adat Line 1 Column 1 Spaces: 4 Python Ultimate MetaTTT.py X def update(self, row, col, mark): Assigns the integer, mark, to the board at the provided row and column, but only if that square is empty. Inputs: row (int) - row index of square to update col (int) - column index of square to update mark (int) - entry to place in square Returns: True if attempted update was successful; False otherwise # TO DO: delete pass (and this comment) and complete method pass def boardFull(self): Checks if the board has any remaining "empty" squares. Inputs: none Returns: True if the board has no "empty" squares (full); False otherwise # TO DO: delete pass (and this comment) and complete method pass def isWinner(self): Checks whether the current player has just made a winning move. In order to win, the player must have just completed a line (of 3 squares) that adds up to 15. That line can be horizontal, vertical, or diagonal. Inputs: none Returns: True if current player has won with their most recent move; False otherwise # TO DO: delete pass (and this comment) and complete method pass def isNum(self): Checks whether this is a Numerical Tic Tac Toe board or not Inputs: none Returns: True # TO DO: delete pass (and this comment) and complete method pass 90 class ClassicTicTacToe: def __init__(self): Line 1 Column 1 Spaces: 4 Python Ultimate MetaTTT.py . # TO DO: delete pass (and this comment) and complete method pass class ClassicTicTacToe: def __init__(self): Initializes an empty Classic Tic Tac Toe board. Inputs: none Returns: None # TO DO: delete pass (and this comment) and complete method pass 100 101 102 def drawBoard(self): 104 Displays the current state of the board, formatted with column and row indices shown. Inputs: none Returns: None 105 106 107 108 109 110 111 # TO DO: delete pass (and this comment) and complete method pass 112 114 115 117 118 def squareIsEmpty(self, row, col): Checks if a given square is "empty", or if it already contains an X or 0. Inputs: row (int) - row index of square to check col (int) - column index of square to check Returns: True if square is "empty"; False otherwise 116 # TO DO: delete pass (and this comment) and complete method pass def update(self, row, col, mark): 129 130 Assigns the string, mark, to the board at the provided row and column, but only if that square is "empty". Inputs: row (int) - row index of square to update col (int) - column index of square to update mark (str) - entry to place in square Returns: True if attempted update was successful; False otherwise # Tono: delete nase land this comment and complete method Line 1 Column 2 Spaces: 4 Python Ultimate MetaTTT.py . 123 124 def update(self, row, col, mark): 125 126 127 128 129 130 131 Assigns the string, mark, to the board at the provided row and column, but only if that square is "empty". Inputs: row (int) - row index of square to update col (int) - column index of square to update mark (str) entry to place in square Returns: True if attempted update was successful; False otherwise 132 133 134 135 # TO DO: delete pass (and this comment) and complete method pass 136 def boardFull(self): 137 138 139 140 141 Checks if the board has any remaining "empty" squares. Inputs: none Returns: True if the board has no "empty" squares (full); False otherwise 142 143 144 145 # TO DO: delete pass (and this comment) and complete method pass 146 147 148 def isWinner(self): 149 150 151 152 153 154 Checks whether the current player has just made a winning move. In order to win, the player must have just completed a line (of 3 squares) with matching marks (i.e. 3 X5 or 3 Os). That line can be horizontal, vertical, or diagonal. Inputs: none Returns: True if current player has won with their most recent move; False otherwise 155 156 157 158 159 # TO DO: delete pass (and this comment) and complete method pass 168 def isNum(self): 161 162 164 163 Checks whether this is a Numerical Tic Tac Toe board or not Inputs: none 165 Returns: False 166 167 # TO DO: delete pass (and this comment) and complete method 168 pass 169 170 171 class MetaTicTacToe: Line 1 Column 2 Spaces: 4 Python . UltimateMetaTTT.py pass pass 168 169 170 171 172 173 class MetaTicTacToe: def __init__(self, configFile): 174 175 176 Initializes an empty Meta Tic Tac Toe board, based on the contents of a configuration file. Inputs: configFile (str) - name of a text file containing configuration information Returns: None 177 178 179 181 # TO DO: delete pass (and this comment) and complete method pass 182 183 def drawBoard(self): 184 185 186 187 Displays the current state of the board, formatted with column and row indices shown. Inputs: none Returns: None 188 189 190 191 192 # TO DO: delete pass (and this comment) and complete method pass 193 194 def squareIsEmpty(self, row, col): 196 197 198 199 200 201 202 203 204 205 206 207 Checks if a given square contains a non-played local game board ("empty'), or the result of a played local game board (not "empty"). Inputs: row (int) - row index of square to check col (int) - column index of square to check Returns: True if square is "empty"; False otherwise # TO DO: delete pass (and this comment) and complete method pass def update(self, row, col, result): 212 Assigns the string, result, to the board at the provided row and column, but only if that square is "empty". Inputs: row (int) - row index of square to update col (int) - column index of square to update result (str) - entry to place in square Returns: True if attempted update was successful; False otherwise 214 217 Line 1 Column 2 Spaces: 4 Python UltimateMetaTTT.py . TUW LIILI - TOW M EX 0 syuare LU upua col (int) - column index of square to update result (str) - entry to place in square Returns: True if attempted update was successful; False otherwise 216 218 # TO DO: delete pass (and this comment) and complete method pass def boardFull(self): Checks if the board has any remaining "empty" squares (i.e. any un-played Local boards). Inputs: none Returns: True if the board has no "empty" squares (full); False otherwise # TO DO: delete pass (and this comment) and complete method pass def isWinner(self): Checks whether the current player has just made a winning move. In order to win, the player must have just completed a line (of 3 squares) of their mark (three Xs for Player 1, three Os for Player 2), or 3 draws. That line can be horizontal, vertical, or diagonal. Inputs: none Returns: True if current player has won with their most recent move; False otherwise 239 240 243 244 # TO DO: delete pass (and this comment) and complete method pass 246 def getLocalBoard(self, row, col): 248 250 Returns the instance of the empty local board at the specified row, col Location (i.e. either ClassicTicTacToe or NumTicTacToe). Inputs: row (int) - row index of square col (int) - column index of square Returns: instance of appropriate empty local board if un-played; None if local board has already been played 253 255 # TO DO: delete pass (and this comment) and complete method pass 256 257 258 259 260 261 if _name__ == "_main_": # TEST EACH CLASS THOROUGHLY HERE 262 Line 1 Column 2 Spaces: 4 Python Assignment Specifications Problem : The Ultimate Meta Tic-Tac-Toe. Meta Tic Tac Toe is a board game composed of nine tic-tac-toe boards arranged in a 3-by-3 grid. In other words, it is a Tic-Tac-Toe board with 9 tic-tac-toe games. Players take turns playing in the smaller tic-tac-toe boards until one of them wins in the larger tic-tac-toe board. Each small 3-by-3 tic-tac-toe board is referred to as a local board, and the larger 3-by-3 board is referred to as the global board. In our ultimate meta tic-tac-toe game, we have a mixture of tic-tac-toes. Each local board can be either classical (XO) or numerical (see Lab3) tic tac toe. They are initialized at the beginning of the game based on a configuration file MetaTTTconfig.txt. There are two players for the game. The game starts with Player 1 choosing any local board from the global board to start, and makes a move on that local board. Player 2 then makes a move on that same local board, then Player 1, and so on. The next moves must all be in that local board, until that local board finishes. A local board is finished once it is won by a player, or it is filled completely without a winner (i.e. a draw). Then the next player chooses another non-played local board to play, and makes a move on that local board. After a local board is finished, the corresponding square on the global board will be marked as X (when Player 1 wins the local board), o (when Player 2 wins the local board) or D (the result of the local board is a draw). To win the whole game, a player needs to win the global board. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner. Moreover, a player may win the global game if the player is the last to play a draw for a local board which results in 3 draws on the horizontal, vertical, or diagonal of the global board. Game play ends when either a player wins the global board, or all 9 local boards have been finished without a global winner in which case the global game is a draw). The game starts with asking Player 1 to choose from the global board. In the global board, 'c' represents a non-played classical tic-tac-toe, 'n' represents a non-played numerical tic-tac-toe, 'X' represents a played tic-tac-toe won by Player 1, 'O' represents a played tic-tac-toe won by Player 2, and 'D' represents a played tic-tac-toe which was a draw. The configuration file MetaTTTconfig.txt just contains 3*3 letters which are either 'c' or 'n', separated by a single white space. An example of a configuration file can be like this: Can cnc nen Using the above configuration, a complete sample game is shown in SampleOut.txt. ***Notice that if Player 2 is the first player to make a move in a local Classical Tic Tac Toe game, Player 2's mark in that local board is 'X'. Similarly, if Player 2 is the first player to make a move in a local Numerical Tic Tac Toe game, Player 2 enters odd numbers on that local board. Tasks to do Task 1 Your task will be to write the two classes: NumTicTacToe and Classic Tic Tac Toe. Hint: these are very similar to your Lab 3 exercise, and you may reuse code that you wrote for that lab (just be sure to reference that with a comment at the top of your class). Each class must implement the following methods: - __init__(): initialize the local game board, so that it is initially "empty. You may represent empty squares however you like (e.g. using a zero, or empty string, or some other representation). - drawBoard(): displays the current state of the local game board, along with the column indices on top of the board, and the row indices to the left of the board. Should not change the contents of the local game board itself. - squarelsEmpty(row, col): returns True if the local board's square at the given row, column location is "empty"; returns False otherwise. - update(row, col, mark): attempts to update the local board's contents at the given row, column location, so that the specified square changes from being empty to containing the given mark. (The mark will be a string for the Classic version; it will be an int for the Numeric version.) Returns True if update is made successfully; False otherwise. - isWinner(); returns True if the local board contains a winning line of THREE squares (horizontal, vertical, diagonal); False otherwise. In the Classic version, a winning line consists of three of the same letters (either X or O). In the Numeric version, a winning line must have a line of three squares that add up to exactly 15. - boardFull(): returns True if there are no "empty" squares; False otherwise. - is Num(): returns True for Numeric boards; False for Classic boards. Do not forget to test your classes in isolation before you write the code of the game itself. Test your class methods, one by one. Include these tests (along with comments, as appropriate) under if name == "main ": at the bottom of your Ultimate MetaTTT.pyfile. You will lose marks if you do not include these tests for us to see. Task 2 Your task will be to design a MetaTic Tac Toe class, and use the class to play games. The class will store the state of the global game. We require the following methods to be implemented: - __init__(configFile): create the game state by initializing it from the configuration file. The name of that configuration file is provided as input. Note that we may test this using different file contents than what is provided as an example in this description. - drawBoard(): displays the current state of the global board (i.e. using 'n', 'c', 'X', 'O', or 'D'), along with the column indices on top of the board, and the row indices to the left of the board. Should not change the contents of the global game board itself. - squarelsEmpty(row, col): checks if a local board at the given row, column location has been played yet or not. Returns True if the local board has not been played; False otherwise. - update(row, col, result): attempts to update the global board at the given row, column location with the result ('X', 'O', or 'D') from the local board at that location. Returns True if that board was previously marked as unplayed and the update was made successfully; False otherwise - isWinner(): checks if the current player is a winner of the global game based on their most recent move (i.e. if their most recent move ended a local game, resulting in an update of the global game board). Returns True if the current player is a winner: False otherwise. -boardFull(); returns True if the global board has no unplayed local boards; returns False if there is any local board still to be played. - getLocalBoard(row, col): returns the instance of the local board at the specified row, column location (i.e. either Classic TicTac Toe or NumTicTacToe, based on initialization), if it hasn't been played. Returns None if the local board has already been played. Do not forget to test your class in isolation before you write the code of the game itself. Include your tests (along with comments, as appropriate) under if __name__ == "_main_": at the bottom of your Ultimate MetaTTT.py file. You will lose marks if you do not include these tests for us to see. The number of required methods may seem like a lot, but many of these methods are quite small, and are designed so that interacting with the class is easier. A skeleton template class has been provided with comments as to what is expected for each method, as well as a text file of sample output and input. Task 3 Write the main program that imports these three classes and interacts with the user to play the Ultimate Meta Tic-Tac-Toe. Your final output (all displayed on the terminal screen) should match up with what is shown in the sample output when the same input is entered. General Guidelines In addition to making sure that your code runs properly, we will also check that you follow good programming practices. For example, divide the problem into smaller sub-problems, and write functions to solve those sub-problems so that each function has a single purpose; use the most appropriate data structures for your algorithm; use concise but descriptive variable names: define constants instead of hardcoding literal values throughout your code; include meaningful comments to document your code, as well as docstrings for all functions; and be sure to acknowledge any collaborators/references in a header comment at the top of your Python file(s). Restrictions for this assignment: Do NOT change the method signatures for each class - implement your classes exactly as described in the ADTs. Do not use break/continue; do not import anything other than the 3 tic tac toe classes described. Assignment Deliverables You are to submit the implemented Ultimate MetaTTT.py class file with the three classes, and main.py which creates instances of the Meta TicTacToe class and handles the playing of games. Submission Instructions Please follow these instructions to correctly submit your solution. Name your files as indicated above Submit your program at the end of this page Note that late submissions will not be accepted. You are able to submit your work as often as you like and only the last submission will be marked. So submit early and submit often. MetaTTTconfig.txt + SampleOut.txt + Ultimate MetaTTT.py + MetaTTTconfig.txt v Ccn cnc non SampleOut.txt X Starting new Meta Tic Tac Toe game 5 1 2 6 0 ccn 8 i cinc 10 2ncin 11 Player 1, please enter a row: 1 Player 1, please enter a column: 1 13 14 This is a Numerical Tic Tac Toe. 15 19 i EE 21 22 23 2 Player 1, please enter an odd number (1-9): 1 Player 1, please enter a row: 1 Player 1, please enter a column: 1 0 1 2 27 0 29 i 1| 31 33 2 Player 2, please enter an even number (2-8): 8 Player 2, please enter a row: 0 Player 2, please enter a column: 0 1 2 i 081 | B 39 i 1| E 41 2 42 Player 1, please enter an odd number (1-9): 4 43 Error: entry not odd . Player 1, please enter an odd number (1-9): 9 44 Player 1, please enter a row: 2 45 Player 1, please enter a column: 2 46 47 0 1 2 48 0 8| T 49 --- - - 501 L11 Line 1 Column 1 !!! Tab Size: 4 Plain Text SampleOut.txt x 41 42 43 44 45 2 Player 1, please enter an odd number (1-9): 4 Error: entry not add . Player 1, please enter an odd number (1-9): 9 Player 1, please enter a row: 2 Player 1, please enter a column: 2 2 0 1 0 81 48 49 50 51 52 1 |1| 53 54 2 L | 9 Player 2, please enter an even number (2-8): 6 Player 2, please enter a row: 0 Player 2, please enter a column: 1 2 0 1 58 0 86 60 1 1 622 9 63 Player 1, please enter an odd number (1-9): 7 64 Player 1, please enter a row: 0 65 Player 1, please enter a column: 2 0 1 2 68 68 | 6 | 7 69 70 i |1| 72 73 74 75 2 9 Player 2, please enter an even number (2-8): 4 Player 2, please enter a row: 1 Player 2, please enter a column: 0 0 1 2 78 686 7 79 80 1 41 82 29 83 Player 1, please enter an odd number (1-9): 5 84 Player 1, please enter a row: 1 85 Player 1, please enter a column: 2 0 1 2 88 0 8 6 | 7 Line 1, Column 1 Tab Size: 4 Plain Text SampleOut.txt Player 1, please enter an odd number (1-9): 5 84 Player 1, please enter a rov: 1 85 Player 1, please enter a column: 2 86 87 @ 1 2 88 68 | 6 | 7 89 98 14 15 91 - 92 29 93 Player 2, please enter an even number (2-8): 2 94 Player 2, please enter a row: 2 95 Player 2, please enter a column: 0 96 97 6 1 2 98 8 | 6 | 7 99 - 108 14 | 15 101 102 2 279 103 Player 1, please enter an odd number (1-9): 7 104 Error: that number has already been entered. Player 1, please enter an odd number (1-9): 3 105 Player 1, please enter a row: 2 106 Player 1, please enter a column: 1 107 108 109 @ 1 2 8 | 6 7 110 111 1 415 113 2 2 | 3 | 9 114 It's a tie. 115 116 6 1 2 117 ccn 118 1191 CDC 120 121 2ncn 122 Player 2, please enter a row: 0 123 Player 2, please enter a column: 0 124 125 This is a Classical Tic Tac Toe. 126 127 1 2 128 TT 129 ----- 138 1 1 131 132 2 O Line 1 Column 1 Tab Size: 4 Plain Text SampleOut.txt 163 160 Player 1, please enter a row: 2 161 Player 1, please enter a column: 2 162 @ 1 2 164 0 TL 165 166 1 X 167 168 2X00 169 Player 2, please enter a row: 0 170 Player 2, please enter a column: 2 171 172 0 1 2 173 174 1751 XL 176 177 2X00 Congrats! EHBO 179 180 0 1 2 0cn 181 182 183 1 CDC 184 1852ncn 186 Player 1, please enter a row: 1 187 Player 1, please enter a column: 0 188 189 This is a Classical Tic Tac Toe. . 190 191 1 2 1920 LT 193 --- - 194 1 1 1 195 --- - 196 2 197 Player 1, please enter a row: 0 198 Player 1, please enter a column: 0 199 200 201 202 0 XL 203 1 L 204 2052 206 Player 2, please enter a row: 0 207 Player 2, please enter a column: 1 208 Line 1 Column 1 Tab Size: 4 Plain Text SampleOut.txt X 466 4622 463 Player 2, please enter a row: 2 464 Player 2, please enter a column: 0 465 @ 1 2 467 XOX 468 4691 X |0 | 470 471 201 472 Player 1, please enter a row: 1 473 Player 1, please enter a column: 2 474 475 0 1 2 476 XOX 478 1 X 0 X 479 480 201 481 Player 2, please enter a row: 2 Player 2, please enter a column: 2 483 484 0 1 2 485 @ XOX 486 487 1 X 0 X 488 489 2010 490 Player 1, please enter a row: 2 491 Player 1, please enter a column: 1 492 493 0 1 2 494 X 0 X 495 496 1 X 0 X 497 498 2 0X0 499 It's a tie. 500 0 1 2 502 00 | Dn 503 504 1 X | D C 501 505 506 2nDn 507 Player 1 wins the Meta Tic Tac Toe game. GOOD GAME! 508 Do you want to play another game? (Y/N) N 509 Thanks for playing! Goodbye. Line 1 Column 1 Tab Size: 4 Plain Text UltimateMetaTTT.py X 3 4 5 6 7 # Assignment 2: Tic Tac Toe classes # # Author: # Collaborators: # References: -- class NumTicTacToe: def _init__(self): Initializes an empty Numerical Tic Tac Toe board. Inputs: none Returns: None # TO DO: delete pass (and this comment) and complete method pass def drawBoard(self): Displays the current state of the board, formatted with column and row indices shown. Inputs: none Returns: None # TO DO: delete pass (and this comment) and complete method pass def squareIsEmpty(self, row, col): Checks if a given square is "empty", or if it already contains a number greater than 0. Inputs: row (int) - row index of square to check col (int) - column index of square to check Returns: True if square is "empty"; False otherwise # TO DO: delete pass (and this comment) and complete method pass def update(self, row, col, mark): Assigns the integer, mark, to the board at the provided row and column, but only if that square is empty. Inputs: row (int) - row index of square to update col incolunda A CARL to adat Line 1 Column 1 Spaces: 4 Python Ultimate MetaTTT.py X def update(self, row, col, mark): Assigns the integer, mark, to the board at the provided row and column, but only if that square is empty. Inputs: row (int) - row index of square to update col (int) - column index of square to update mark (int) - entry to place in square Returns: True if attempted update was successful; False otherwise # TO DO: delete pass (and this comment) and complete method pass def boardFull(self): Checks if the board has any remaining "empty" squares. Inputs: none Returns: True if the board has no "empty" squares (full); False otherwise # TO DO: delete pass (and this comment) and complete method pass def isWinner(self): Checks whether the current player has just made a winning move. In order to win, the player must have just completed a line (of 3 squares) that adds up to 15. That line can be horizontal, vertical, or diagonal. Inputs: none Returns: True if current player has won with their most recent move; False otherwise # TO DO: delete pass (and this comment) and complete method pass def isNum(self): Checks whether this is a Numerical Tic Tac Toe board or not Inputs: none Returns: True # TO DO: delete pass (and this comment) and complete method pass 90 class ClassicTicTacToe: def __init__(self): Line 1 Column 1 Spaces: 4 Python Ultimate MetaTTT.py . # TO DO: delete pass (and this comment) and complete method pass class ClassicTicTacToe: def __init__(self): Initializes an empty Classic Tic Tac Toe board. Inputs: none Returns: None # TO DO: delete pass (and this comment) and complete method pass 100 101 102 def drawBoard(self): 104 Displays the current state of the board, formatted with column and row indices shown. Inputs: none Returns: None 105 106 107 108 109 110 111 # TO DO: delete pass (and this comment) and complete method pass 112 114 115 117 118 def squareIsEmpty(self, row, col): Checks if a given square is "empty", or if it already contains an X or 0. Inputs: row (int) - row index of square to check col (int) - column index of square to check Returns: True if square is "empty"; False otherwise 116 # TO DO: delete pass (and this comment) and complete method pass def update(self, row, col, mark): 129 130 Assigns the string, mark, to the board at the provided row and column, but only if that square is "empty". Inputs: row (int) - row index of square to update col (int) - column index of square to update mark (str) - entry to place in square Returns: True if attempted update was successful; False otherwise # Tono: delete nase land this comment and complete method Line 1 Column 2 Spaces: 4 Python Ultimate MetaTTT.py . 123 124 def update(self, row, col, mark): 125 126 127 128 129 130 131 Assigns the string, mark, to the board at the provided row and column, but only if that square is "empty". Inputs: row (int) - row index of square to update col (int) - column index of square to update mark (str) entry to place in square Returns: True if attempted update was successful; False otherwise 132 133 134 135 # TO DO: delete pass (and this comment) and complete method pass 136 def boardFull(self): 137 138 139 140 141 Checks if the board has any remaining "empty" squares. Inputs: none Returns: True if the board has no "empty" squares (full); False otherwise 142 143 144 145 # TO DO: delete pass (and this comment) and complete method pass 146 147 148 def isWinner(self): 149 150 151 152 153 154 Checks whether the current player has just made a winning move. In order to win, the player must have just completed a line (of 3 squares) with matching marks (i.e. 3 X5 or 3 Os). That line can be horizontal, vertical, or diagonal. Inputs: none Returns: True if current player has won with their most recent move; False otherwise 155 156 157 158 159 # TO DO: delete pass (and this comment) and complete method pass 168 def isNum(self): 161 162 164 163 Checks whether this is a Numerical Tic Tac Toe board or not Inputs: none 165 Returns: False 166 167 # TO DO: delete pass (and this comment) and complete method 168 pass 169 170 171 class MetaTicTacToe: Line 1 Column 2 Spaces: 4 Python . UltimateMetaTTT.py pass pass 168 169 170 171 172 173 class MetaTicTacToe: def __init__(self, configFile): 174 175 176 Initializes an empty Meta Tic Tac Toe board, based on the contents of a configuration file. Inputs: configFile (str) - name of a text file containing configuration information Returns: None 177 178 179 181 # TO DO: delete pass (and this comment) and complete method pass 182 183 def drawBoard(self): 184 185 186 187 Displays the current state of the board, formatted with column and row indices shown. Inputs: none Returns: None 188 189 190 191 192 # TO DO: delete pass (and this comment) and complete method pass 193 194 def squareIsEmpty(self, row, col): 196 197 198 199 200 201 202 203 204 205 206 207 Checks if a given square contains a non-played local game board ("empty'), or the result of a played local game board (not "empty"). Inputs: row (int) - row index of square to check col (int) - column index of square to check Returns: True if square is "empty"; False otherwise # TO DO: delete pass (and this comment) and complete method pass def update(self, row, col, result): 212 Assigns the string, result, to the board at the provided row and column, but only if that square is "empty". Inputs: row (int) - row index of square to update col (int) - column index of square to update result (str) - entry to place in square Returns: True if attempted update was successful; False otherwise 214 217 Line 1 Column 2 Spaces: 4 Python UltimateMetaTTT.py . TUW LIILI - TOW M EX 0 syuare LU upua col (int) - column index of square to update result (str) - entry to place in square Returns: True if attempted update was successful; False otherwise 216 218 # TO DO: delete pass (and this comment) and complete method pass def boardFull(self): Checks if the board has any remaining "empty" squares (i.e. any un-played Local boards). Inputs: none Returns: True if the board has no "empty" squares (full); False otherwise # TO DO: delete pass (and this comment) and complete method pass def isWinner(self): Checks whether the current player has just made a winning move. In order to win, the player must have just completed a line (of 3 squares) of their mark (three Xs for Player 1, three Os for Player 2), or 3 draws. That line can be horizontal, vertical, or diagonal. Inputs: none Returns: True if current player has won with their most recent move; False otherwise 239 240 243 244 # TO DO: delete pass (and this comment) and complete method pass 246 def getLocalBoard(self, row, col): 248 250 Returns the instance of the empty local board at the specified row, col Location (i.e. either ClassicTicTacToe or NumTicTacToe). Inputs: row (int) - row index of square col (int) - column index of square Returns: instance of appropriate empty local board if un-played; None if local board has already been played 253 255 # TO DO: delete pass (and this comment) and complete method pass 256 257 258 259 260 261 if _name__ == "_main_": # TEST EACH CLASS THOROUGHLY HERE 262 Line 1 Column 2 Spaces: 4 Python

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!