+class Board

This commit is contained in:
Paulina Nowak 2020-12-20 21:46:22 +01:00
parent 89c4a92d72
commit 9644a51f9f

27
main.py
View File

@ -6,6 +6,9 @@
| | | |
""" """
from random import randint
from random import choice
class TicTacToe: class TicTacToe:
def __init__(self): def __init__(self):
@ -23,12 +26,34 @@ class TicTacToe:
else: else:
print("This field's taken.") print("This field's taken.")
class Player:
def __init__(self, token):
self.token = token
def make_random_move(self, state):
sequence = ["X", "O"]
emptyField = True
while emptyField:
field = state[randint(0,8)]
if field == " ":
state[field] = choice(sequence)
emptyField = False
player = Player("X")
player1 = Player("O")
game = TicTacToe() game = TicTacToe()
game.print() game.print()
game.make_move("X", 0) for x in range(1,10):
player.make_random_move(game.state)
game.print() game.print()
player1.make_random_move(game.state)
game.print()
# make_move(state, "X", 0) # make_move(state, "X", 0)
# print_board(state) # print_board(state)