generated from mwc/lab_tic_tac_toe
61 lines
3.0 KiB
Markdown
61 lines
3.0 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
|
|
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 | | | |
|
|
|
|
In the first state shown, I would put an X in spot 5 to get a winning combo.
|
|
In the second state shown, I would put an X in spot 5 to prevent 0 from winning next turn.
|
|
In the third state shown, I would put an X in spot 0 because it will make it possible to get a winning combo on X's next turn regardless of where O plays.
|
|
In the fourth state shown, I would put an X in spot 4 to have more possible ways to win. Half of the winning combos contain spot 4.
|
|
|
|
### 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 state = {"board": ['-','O','O','X','X','-','-','-','-'], "player_x": True} is 1. This means that X will win. X can play spot 5 and win.
|
|
|
|
The initial state is:
|
|
{'board': ['-', '-', '-', '-', '-', '-', '-', '-', '-'], 'player_x': True}
|
|
For the initial state, the current and future reward is 0. That means it is equally likely for either player to win or lose. |