Question: Python 3.6 an x on a random square. Question: imagine that two players play Tic-Thc-Toe randomly. Specifically, X goes first, placing Then O goes, placing
an x on a random square. Question: imagine that two players play Tic-Thc-Toe randomly. Specifically, X goes first, placing Then O goes, placing an o on one of the eight remaining squares. Then X goes again, placing an x on one of the seven remaning squares randomly. Then wins this random game of Tio-Thc-Toe? O goes again, ete., until one player gets three in a row. What is the probability that X Create a class called TTTBoard whose objects represent Tic-Tac-Toe boards. The underlying data will be 3 x 3 lists of strs, each of whose entries will be either "z", "o" or " ". The first two should be LOWERCASE, the last one, which will represent an unused square, is two single quotes with a space between them (the space character) Specifically, you should implement your class to the following specifications. I suggest you deal with the attributes and methods in the order I write them. Remember that attributes and methods that begin with an underscore (.board, row.full, etc.) should only be used in the class definition- not in your client code! You are also free to add additional attributes and methods, if you wish. Each object in the class should have the following attribute variable: ..board, which is a 3x3 list of strings. This will represent the state of the board at any given time. The class should contain the following methods: init..). This should sinnply initialize all of the entries of self.-board to be " "-that is, the entries should be the space character, which is two single quotes with a space between them. (So, the board starts out as blank.) This initializer should have no parameters, other than self 1. 2. .displayO, which should take no outside inputs and return nothing. This should print out the values held in board in a reasonably pretty way, with an extra newline after the board is printed. 3. .set O, which should take two ints and a atr as outside inputs, and change the entry at the given position to the given character (and return nothing). For instance, if I have a TTTBoard object named myGame, then aydane.set (O,2, will set the entry in the upper right corner to be x (because the upper right corner is the first row, third column, which corresponds to aydase. .board Co] (2] with zero-based indexing) 4 .occupied), which should take two ints as outside inputs and return a bool. This function should check if the given position has already been played. For example, val-eyGane . occupied (0,2) set val to True if ayGane..board to] [2) is either "x" or "o", and it should set val to False if
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
