develop #1

Merged
swarga merged 3 commits from develop into master 2020-12-23 23:44:42 +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.")
break
class Board:
def __init__(self):
@ -43,6 +48,18 @@ class Board:
else:
print("This field's taken.")
def isWin(self, token):
Review

Ta funkcja byłaby dużo bardziej użyteczna, gdyby informowała nas który z graczy jest zwycięzcą (zostaw sobie ToDo w kodzie do przemyślenia na później).

Ta funkcja byłaby dużo bardziej użyteczna, gdyby informowała nas który z graczy jest zwycięzcą (zostaw sobie ToDo w kodzie do przemyślenia na później).
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
(self.state[6] == token and self.state[7] == token and self.state[8] == token)):
return True
return False
def get_state():
Review

Do zaktualizowania.

Do zaktualizowania.
pass