Question
Using the Python code provided below, write the statements of the following functions; printBoard(board): Function to print the TIC-TAC-TOE board checkRow(row,player): Function to check the
Using the Python code provided below, write the statements of the following functions;
printBoard(board): Function to print the TIC-TAC-TOE board
checkRow(row,player): Function to check the elements in the row of the current play. Returns True if all the elements of the studied row are equal to the player's symbol.
checkColumn(col,player): Function to check the elements in the column of the current play. Returns True if all the elements of the studied column are equal to the player's symbol
checkDiag(row,col,player): Function to check the elements in the diagonal of the current play (only if the current position has to consider the diagonals). Returns True if all of the elements in the studied diagonal are equal to the player's symbol
Note: allowed to change the template (write a comment explaining each change to the original code).
board = [[,-, for i 1n range (3)] for i 1n range (3)] def printBoard (board): # Function to print the board def checkRow (row, player) # Function t check the elements in the row of the current play. Returns True if all the elements of the studied row e equal to the pleyer's symbol def checkColumn(col,player): # unction to check the elements in the column of the currenc play. Returns True if all the elements of the studied column are equal to the player's symbol def checkDiag (row, col,player # Eunction to check the elements in the diagonal of the current play (only if the current position has to consider the diagonals) . Returns True if all of the elements def winGame (posx, posY,player if checkRow (poax,player) True: elir checkColumn (posY,player) True: elif checkDiag (posX, posY,player)True: else: return 1 retuzn recurn 1 return 0 def makePlay (posx, posY,player): if board [posx] [pos elae: return -1 # invalid option board [poeX] [post] player if winGame (posX, posY,player) -1: return 1 # game ends else: return 0 # game continues Dlay 0 printBoard (board) while play 9: f play 2-0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started