develop #2
21
main.py
21
main.py
@ -7,8 +7,6 @@
|
||||
|
||||
"""
|
||||
from random import randint
|
||||
from random import choice
|
||||
|
||||
|
||||
class TicTacToe:
|
||||
"""
|
||||
@ -25,8 +23,15 @@ class TicTacToe:
|
||||
for x in range(1,10):
|
||||
board.make_move(player1.token, player1.make_random_move(board.state))
|
||||
board.print()
|
||||
if board.isWin(player1.token):
|
||||
print("Player 1 has won.")
|
||||
break
|
||||
|
||||
board.make_move(player2.token, player2.make_random_move(board.state))
|
||||
board.print()
|
||||
if board.isWin(player2.token):
|
||||
print("Player 2 has won.")
|
||||
|
||||
break
|
||||
|
||||
class Board:
|
||||
def __init__(self):
|
||||
@ -43,6 +48,18 @@ class Board:
|
||||
else:
|
||||
print("This field's taken.")
|
||||
|
||||
def isWin(self, token):
|
||||
if((self.state[0] == token and self.state[1] == token and self.state[2] == token) or
|
||||
(self.state[0] == token and self.state[4] == token and self.state[8] == token) or
|
||||
(self.state[0] == token and self.state[3] == token and self.state[6] == token) or
|
||||
(self.state[1] == token and self.state[4] == token and self.state[7] == token) or
|
||||
(self.state[2] == token and self.state[5] == token and self.state[8] == token) or
|
||||
(self.state[2] == token and self.state[4] == token and self.state[6] == token) or
|
||||
(self.state[3] == token and self.state[4] == token and self.state[5] == token) or
|
||||
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.
|
||||
(self.state[6] == token and self.state[7] == token and self.state[8] == token)):
|
||||
return True
|
||||
return False
|
||||
|
||||
swarga
commented
No napisz to! No napisz to!
|
||||
def get_state():
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
To możemy zastąpić generacją listy.