From 0929ab7173b42a4c92d52d76105f457e631f6a10 Mon Sep 17 00:00:00 2001 From: kathrynoh23 <126970932+kathrynoh23@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:56:06 -0400 Subject: [PATCH] Kathryn Odell-Hamilton All the Checkpoints answered within the notes.md file. --- .DS_Store | Bin 0 -> 6148 bytes notes.md | 77 +++++++++++++++++++++++++++++++++++++++++++++ play_ttt.py | 6 +++- poetry.lock | 10 +++--- strategy/.DS_Store | Bin 0 -> 6148 bytes ttt/.DS_Store | Bin 0 -> 6148 bytes ttt/game.py | 23 ++++++++++++++ ttt/view.py | 2 ++ 8 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 .DS_Store create mode 100644 strategy/.DS_Store create mode 100644 ttt/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..bda659fda86d541d712336b452df7d340b643894 GIT binary patch literal 6148 zcmeHKJ8nWj3>*iFC#9iGxmVx@D@0C^3*#UBHgPvSB{qPCrIcKDNPzQM)vH^ zvv>8Tc*X#1^|4t33jhP%5l0VG^XKjpyD7%e;*0}c@rKXM{$)GKzD#)SfISX)#}nhJ z{&~0C@=(l3^5;kXP?t{%J-UZkBAkOEhwfX&wr>lI(Adh6unyw^7RBi(bp=x$s` o2}87FVzgs!ydB>~Qsy;Z^LZ~E6Qi7bloR!5z;%&Hf&W(E8$IoK8-JB(O1gIxb zd=m5q(-aZieP6aBYY|z(4drgb)NJ2;Vs9ByARK3$tC`N@F;svGyp96)eJF6lnm7ddrvrnx0Kf)e zH_W}402T`XYvK@y2uy*H-`E;s5miV-i=h6bQ#VPI7>M$h&m2>c}_IdtuEgkdX>d0V;4;z`hR!Zden?K>u_g_y_=8 zBJGB?&l13531Cee1CfDgP=P_!95FQL$d|0EiDO{UMRWMjJXv!>Q9m8;FJ3NM0~x6R z6__fpi0#_?{~P?t{68geM+KA!1r*gxx&q`b_#;GW1zQV hY^)t`yeR65t?|4jj)6``-swR8445u7D)83|+yF)|6_)@2 literal 0 HcmV?d00001 diff --git a/ttt/game.py b/ttt/game.py index 2f0e302..b56a844 100644 --- a/ttt/game.py +++ b/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. +""" diff --git a/ttt/view.py b/ttt/view.py index 30df0fd..46f9b84 100644 --- a/ttt/view.py +++ b/ttt/view.py @@ -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()