2.2 KiB
Tic Tac Toe notes
Checkpoint 1 Notes
Which class is responsible for each of the following behaviors? For each, explain how the behavior is accomplished.
Checking to see whether the game is over
Class TTTGame is responsible for checking to see whether the game is over. To check if the game is over, the is_over method is called with the state as the argument. The is_over method calls board_is_full and check_winner for both players. To check if the board is full, True is returned if "-" is in the board still. To check if either player is a winnner, the code isn't finished, but True should be returned if the board has three of that players symbols in a row. All of these methods are in the TTTGame class.
Determining which actions are available at a particular state
Class TTTGame is responsible for determining which actions are available at a particular state. It returns a list of the index positions where there are empty spaces '-'.
Showing the board
Class TTTView is responsible for showing the board. The methods it uses include print_board, get_action, format_row, and format_value. The TTTView class attributes are greeting, goodbye, divider, x_color, o_color, and option color.
Choosing which action to play on a turn
Class TTTHumanPlayer is responsible for choosing which action to play on a turn. It gets possible actions (blank spaces)from class TTTGame method get_actions. Then, it converts each of the possible actions into a string and stores as a list in choices. Then, it converts input to the "> " prompt to integer and stores in action variable and returns action.
Checkpoint 2 Notes
TTT Strategy
For each of the following board states, if you are playing as X and it's your turn, which action would you take? Why?
| O | O | | O | X | X | O |
---+---+--- ---+---+--- ---+---+--- ---+---+---
X | X | | X | X | O | O | |
---+---+--- ---+---+--- ---+---+--- ---+---+---
| | | | O | | | |
Initial game state
You can get the inital game state using game.get_initial_state(). What is the current and future reward for this state? What does this mean?