Reference no: EM13161265
Fill in the Python code to play Tic Tac Toe. I won't award points unless it runs succesfully. # Tic-Tac-Toe Game def drawBoard(board): # Draws the board using the list of numbers print(" ") print(" ",board[0]," | ",board[1]," | ", board[2]) print("----------------") print(" ",board[3]," | ",board[4]," | ", board[5]) print("----------------") print(" ", board[6]," | ",board[7]," | ", board[8]) print(" ") return def nextMove(turn,bd): # Asks the player whose turn it is to choose a spot on the board # The turn parameter represents the player ("O" or "X") # Replace the spot on the board with the right symbol # Return the board return bd def isWinner(bd): # Determines if there is a winner # If X is the winner, return "X" # If O is the winner, return "O" # If there is no winner, return "none" return "X" def moreMoves(bd): # Determines if there are any moves left # if any spaces are left to play # return 1 if there are any moves left # return 0 if there are no moves left return 0 def nextTurn(turn): # Determines whose turn it is based on whose turn # just finished return turn # Main code # # Initialize the board with position numbers # Start out with X going first # Set the winner to 'none' to start # As long as there is no winner and there are still moves to make, loop through the game # Each time through the loop # Draw the board # Make the next move # Determine if there is a winner # Set the turn to the next player # # Once the loop is complete, display the board one more time and print the winner def main(): bd = [0,1,2,3,4,5,6,7,8] turn = 'X' winner = 'none' while winner == 'none' and moreMoves(bd)==1: drawBoard(bd) bd = nextMove(turn,bd) winner = isWinner(bd) turn = nextTurn(turn) drawBoard(bd) print("Player ",winner," is the winner")
An iterative algorithm to traverse an arbitrary number
: An iterative algorithm to traverse an arbitrary number of nested subdirectories in a file system.
|
Creating a hashing function
: Suppose you are creating a hashing function to use for storing string data in hashtable. One Candidate hasing function would be to sum the ASCII or Unicode values for each character, and that result as the hashcode.
|
A calculator application that allows prefix, infix and postf
: A calculator application that allows prefix, infix, and postfix expressions to be evaluated (i.e., allows all 3 types of expressions
|
Professional full-time employees and volunteers
: How can you as a manager suppress the natural tensions that exist between professional full-time employees and volunteers?
|
Fill in the python code
: Fill in the Python code to play Tic Tac Toe. I won't award points unless it runs succesfully. # Tic-Tac-Toe Game def drawBoard(board): # Draws the board using the list of numbers print(" ") print(" ",board[0]," | ",board[1]," | ", board[2]) print("--..
|
Difference between the two following statements
: What exactly is the difference between the two following statements and which is preferred, please provide details: 1) frame.setSize(400, 300); // Set JFrame Size
|
A deck of playing cards in a card game
: A deck of playing cards in a card game where cards may be drawn from, or discarded to, either the top or the bottom of the deck, but no access to cards in the middle of the deck is permitted.
|
Health care firms merge
: Health care firms merge together to gain power and lessen competition, yet they do not realize that competition will still exist regardless of them merging? 20-50 words please.
|
Quality of health care
: Based on your research and experience regarding mergers, do you feel they contribute to improved quality of health care? If so why? If not, why? 20-50 words please.
|