Skip to content

Commit 4e46eab

Browse files
committed
tic-tac-toe: add beginnings of "if not over" game loop
1 parent da26b48 commit 4e46eab

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tic_tac_toe/play.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ def offer_choices(self) -> list[Coordinate]:
7171
if square.value == " "
7272
]
7373

74+
def play(self):
75+
"""
76+
TODO: https://www.youtube.com/watch?v=Q6CCdCBVypg
77+
repeat
78+
Initialise board
79+
while not game over
80+
player 1 turn
81+
check for game over
82+
if not game over
83+
player 2 turn
84+
check for game over
85+
end if
86+
end while
87+
calculate winner
88+
display winner
89+
another game ?
90+
until exit selected
91+
"""
92+
while self.winner is None:
93+
choice = input(f"Player {self.current_player.symbol} enter your choice: ")
94+
print(self.board.render())
95+
pass
96+
pass
97+
7498

7599
@dataclass(frozen=True)
76100
class TicTacToe:
@@ -86,7 +110,7 @@ def load_game(self, board: Board) -> Game:
86110

87111
def main() -> None:
88112
game = TicTacToe().new_game()
89-
print(game.board.render())
113+
game.play()
90114

91115

92116
if __name__ == "__main__":

0 commit comments

Comments
 (0)