develop #2
5
main.py
5
main.py
@ -13,9 +13,9 @@ class TicTacToe:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.player1 = Player("X", "Player 1")
|
self.player1 = Player("X", "Player 1")
|
||||||
self.player2 = Player("O", "Player 2")
|
self.player2 = Player("O", "Player 2")
|
||||||
self.board = Board()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|||||||
|
self.board = Board()
|
||||||
while True:
|
while True:
|
||||||
self.board.make_move(self.player1.token, self.player1.choose_random_field(self.board.empty_fields))
|
self.board.make_move(self.player1.token, self.player1.choose_random_field(self.board.empty_fields))
|
||||||
self.board.print()
|
self.board.print()
|
||||||
@ -54,6 +54,9 @@ class Board:
|
|||||||
(self.state[6] == token and self.state[7] == token and self.state[8] == token)):
|
(self.state[6] == token and self.state[7] == token and self.state[8] == token)):
|
||||||
print(name + " has won.")
|
print(name + " has won.")
|
||||||
return True
|
return True
|
||||||
|
if len(self.empty_fields) == 0:
|
||||||
|
print("It's a draw.")
|
||||||
swarga
commented
Board sam z siebie nie powinien nam niczego printować, póki go o to nie poprosimy. Myślę, że informację o wygranym można przecieść do Tic-Tac-Toe. Board sam z siebie nie powinien nam niczego printować, póki go o to nie poprosimy. Myślę, że informację o wygranym można przecieść do Tic-Tac-Toe.
|
|||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_state():
|
def get_state():
|
||||||
swarga
commented
No napisz to! No napisz to!
|
|||||||
|
Loading…
Reference in New Issue
Block a user
Ten cały blok kodu możnaby sprowadzić do: