Checkpoint 1

The docstrings (along with the video) really helped me to make sense of
the code. I'm finding myself more familiar with how to read the code, but
it still takes some searching to find the different functions that certain
parts of each class refer back to. Having all of the different programs
open in different tabs also helped me to make sense of the program, as I
could look from class to class to see where the function I may have been
looking for could be found.
This commit is contained in:
Chris Mekelburg 2024-11-16 20:37:01 -05:00
parent b02699b581
commit 18ceeb60b7
1 changed files with 4 additions and 1 deletions

View File

@ -6,13 +6,16 @@ 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
TTTGame is the class that checks if the game is over. The function is is_over and it operates by checking a series of other functions (with an or) based on the game's state. These other functions are board_is_full which checks each space and if there is an empty space (-) returns false and if there are no empty spaces returns true (and the game is over). If this is False, the is_over function will check for a winner for x and then for y. These functions will be written in checkpoint 2.
### Determining which actions are available at a particular state
TTTGame also checks which actions are available at a particular state using get_actions which returns the board with a list of the unused spaces. It checks each space in the game and returns a list of any empty spaces (value of - instead of x or o). These values are then printed in TTTView.
### Showing the board
TTTView is the class that shows the board. Print_board is the function in the class that most direclty prints the board. The class works by greeting the user greet(self) and then asks the user where they would like to put their X or O with get_action which also prints the board based on the printing directions in print_board. Print_board relies on format_row and format_value to decide where to put each x,o, or blank space.
### Choosing which action to play on a turn
TTTHumanPlayer or TTTComputerPlayer select the action. TTTHumanPlayer allows the player to input a choice after seeing the baord, and then checks the choice to make sure it is an open space. If yes, it proceeds by returning the action which is then used in TTTGame. If the action is not permitted, such as when the space is already occupied or a non 1-9 vlaue is entered, the user is prompted again (although I can't find the code that specifically prints that error message!)
## Checkpoint 2 Notes