This commit is contained in:
lfitchlee
2025-11-18 09:25:31 -05:00
parent 4fc2e95a3d
commit 3c6f1d8e4a

View File

@@ -7,12 +7,24 @@ For each, explain how the behavior is accomplished.
### Checking to see whether the game is over ### Checking to see whether the game is over
Responsible class: `TTTGame`, method `is_over`.
Explanation: `TTTGame.is_over` determines whether play should stop. It returns True when the board is full or when either player has three in a row using `check_winner`. The game logic and win/draw detection are implemented on the `TTTGame` class.
### Determining which actions are available at a particular state ### Determining which actions are available at a particular state
Responsible class: `TTTGame`, method `get_actions`.
Explanation: `TTTGame.get_actions` inspects `state["board"]` and returns a list of indices for empty spaces (those containing `'-'`). The game class encapsulates available-move generation for the current board state.
### Showing the board ### Showing the board
Responsible class: `TTTView`, primarily `print_board`, `format_row`, and `format_value`.
Explanation: `TTTView` handles all screen display. `print_board(state)` arranges rows and separators, `format_row` formats a single row, and `format_value` prints an `X`, `O`, or the index for an empty spot. The view is responsible for how the board is presented.
### Choosing which action to play on a turn ### Choosing which action to play on a turn
Responsible classes: `TTTHumanPlayer` and `TTTComputerPlayer`.
Explanation: Players decide moves. `TTTHumanPlayer.choose_action(state)` prompts the user and returns the selected index. `TTTComputerPlayer.choose_action(state)` to use a strategy (here `RandomStrategy`) and returns the chosen move. So the player classes and any strategy objects they use are responsible for selecting the action to play on a turn.
## Checkpoint 2 Notes ## Checkpoint 2 Notes