Kathryn Odell-Hamilton

All the Checkpoints answered within the notes.md file.
This commit is contained in:
kathrynoh23
2024-04-02 12:56:06 -04:00
parent 71df2cf2b8
commit 0929ab7173
8 changed files with 111 additions and 7 deletions

BIN
ttt/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -58,4 +58,27 @@ class TTTGame:
def check_winner(self, state, symbol):
"Checks whether the player with `symbol` has won the game."
"""Seems to be an issue because the code looks incomplete.
In the View, it shows the Player's choice/symbol placed on the Tic Tac Toe
board as a winner, but doesn't announce the Player as the winner, the Game
keeps playing as though there is no winner. The Game doesn't recognize that the
Player has "3 symbols in a row," this should stop the game to determine the winner.
The Game doesn't state in the "View" that the current Player is the winner.
"""
board = state["board"]
for row in range(3):
if all(board[row * 3 + col] == symbol for col in range(3)):
return True
for col in range(3):
if all(board[row + col * 3] == symbol for row in range(3)):
return True
if board[0] == board[4] == board[8] == symbol or board[2] == board[4] == board[6] == symbol:
return True
return False
"""I played the game.
Message
Well, that's a wrap.
Congratulations to Player 1.
"""

View File

@@ -9,6 +9,8 @@ class TTTView:
x_color = "red"
o_color = "blue"
option_color = "bright_black"
"""Added winner. Not sure if correct."""
winner = "You have won the game!"
def __init__(self, playerX, playerO):
self.game = TTTGame()