generated from mwc/lab_tic_tac_toe
47 lines
2.5 KiB
Markdown
47 lines
2.5 KiB
Markdown
# 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
|
|
The game class is responsible for checking to see if the game is over. The method is_over checks the current
|
|
state of the game to see if the board is full or if either X or O has won. If any of these three things are true,
|
|
the game is over.
|
|
### Determining which actions are available at a particular state
|
|
The game class is responsible for determining which actions are available at a particular state. The get_actions
|
|
method returns a list of the indices of open spaces. These are the actions that are available at that state.
|
|
### Showing the board
|
|
The view class is responsible for showing the board. The format_row and format_value methods are responsible for formatting, and the print_board method displays the board to the user. The board is actually shown when the get_action method is called.
|
|
### Choosing which action to play on a turn
|
|
The player class is responsible for choosing which action to play on a turn. The choose_action method prompts the player to choose the action.
|
|
|
|
## Checkpoint 2 Notes
|
|
|
|
For Checkpoint 2, I just programmed the method to check every possible winning combination in the game.
|
|
|
|
### 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 | | | |
|
|
|
|
For the first board I would choose the middle row right column because that would result in a win.
|
|
For the second board, I would choose the middle row right column to prevent the other player from winning next turn.
|
|
For the third board, I would choose the top row left column because it would guarantee a win on my next turn.
|
|
For the last board, I would choose the middle space. That would force my opponent to take the bottom right. Then I could take the bottom left and win on my next turn.
|
|
|
|
### 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?
|
|
|
|
The current and future reward for this state is 0. That means that if both players play optimally, the game will result in a tie.
|
|
|