I ID'd the classes for each of the actions listed in notes and explained how

the actions were accomplished.

Checkpoint 1:
I think it was actually a little easier this time than it was looking at the
code in the Dice Lab. This time I thought more about the what was being imported
from a library and called versus was the "invisible" parts of the code controlling
the interactions between the classes and methods that are just like built into the
language itself I guess? Don't know if that is a strategy, but I feel like it
helps to make a distinction between what I should actually try to understand right
now, and what is deeper / not the focus at this point.
This commit is contained in:
root 2024-12-12 10:59:27 -05:00
parent 1b09d1ad71
commit ecadbc41cf
1 changed files with 18 additions and 0 deletions

View File

@ -6,12 +6,30 @@ 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