subject

Write a class named tictactoe that has two private data members: the board, which will be a list of lists that represent a 3x3 board, and the current state. it should have a get method named get_current_state. the class should have an init method that initializes the board to a list of three lists that each contain three empty strings (where each represents an empty square), and initializes the current_state to "unfinished". it should have a method named make_move that takes three parameters, a row and a column (in that order) where each is an integer in the range 0-2, and either 'x' or 'o' to indicate the player who is making the move. if the row or column are out of bounds, or if that square is already occupied, or if the game has already been won or drawn, make_move should return false. otherwise, it should record the move, update current_state to the appropriate value, and return true. the possible values of current_state are: "x_won", "o_won", "draw", or "unfinished". it's possible for multiple moves to be made in a row for the same player. a game is drawn when all of the squares are filled, but neither player has won. it's not required, but you'll probably find it useful for testing and debugging to have a method that prints out the board. whether you think of the array indices as being [row][column] or [column][row] doesn't matter as long as you're consistent. code must be in python, not c++ or java.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
Consider the following function main: int main() { int alpha[20]; int beta[20]; int matrix[10][4]; . . } a. write the definition of the function inputarray that prompts the user to input 20 numbers and stores the numbers into alpha. b. write the definition of the function doublearray that initializes the elements of beta to two times the corresponding elements in alpha. make sure that you prevent the function from modifying the elements of alpha. c. write the definition of the function copyalphabeta that stores alpha into the first five rows of matrix and beta into the last five rows of matrix. make sure that you prevent the function from modifying the elements of alpha and beta. d. write the definition of the function printarray that prints any onedimensional array of type int. print 15 elements per line. e. write a c11 program that tests the function main and the functions discussed in parts a through d. (add additional functions, such as printing a two-dimensional array, as needed.)
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
The first screen you see when you open word2016 what is called?
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
How can the temperature of a room be raised by 5degreesf?
Answers: 1
You know the right answer?
Write a class named tictactoe that has two private data members: the board, which will be a list of...
Questions
question
Mathematics, 05.12.2019 19:31
Questions on the website: 13722359