Computers and Technology

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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 00:30, alex7078
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
image
Computers and Technology, 24.06.2019 00:40, sierravick123owr441
Use a software program or a graphing utility with matrix capabilities to solve the system of linear equations using an inverse matrix. x1 + 2x2 โˆ’ x3 + 3x4 โˆ’ x5 = 6 x1 โˆ’ 3x2 + x3 + 2x4 โˆ’ x5 = โˆ’6 2x1 + x2 + x3 โˆ’ 3x4 + x5 = 3 x1 โˆ’ x2 + 2x3 + x4 โˆ’ x5 = โˆ’3 2x1 + x2 โˆ’ x3 + 2x4 + x5 = 5
Answers: 3
image
Computers and Technology, 24.06.2019 20:30, anonymous1813
โญ๏ธโญ๏ธโญ๏ธ what network is larger in size? man or wan? you โญ๏ธโญ๏ธโญ๏ธ
Answers: 2
image
Computers and Technology, 24.06.2019 23:00, person76
Systolic pressure is a measure of blood pressure when the ventricles relax and fil with blood ture or false
Answers: 1
Do you know the correct answer?
Write a class named tictactoe that has two private data members: the board, which will be a list of...

Questions in other subjects:

Konu
History, 22.04.2021 21:20