develop #2

Merged
swarga merged 10 commits from develop into master 2020-12-25 04:59:51 +01:00
Showing only changes of commit b7b599e295 - Show all commits

21
main.py
View File

@ -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.")

To możemy zastąpić generacją listy.

To możemy zastąpić generacją listy.
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

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

No napisz to!

No napisz to!
def get_state():
pass