Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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).

image text in transcribedimage text in transcribed

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-0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Is money the best motivator?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago