generated from mwc/lab_tic_tac_toe
i did it
This commit is contained in:
12
notes.md
12
notes.md
@@ -7,12 +7,24 @@ For each, explain how the behavior is accomplished.
|
||||
|
||||
### 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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user