generated from mwc/lab_tic_tac_toe
Kathryn Odell-Hamilton
All the Checkpoints answered within the notes.md file.
This commit is contained in:
BIN
ttt/.DS_Store
vendored
Normal file
BIN
ttt/.DS_Store
vendored
Normal file
Binary file not shown.
23
ttt/game.py
23
ttt/game.py
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user