diff --git a/main.py b/main.py index c312c81..3ad5f86 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,9 @@ | | """ +from random import randint +from random import choice + class TicTacToe: def __init__(self): @@ -23,12 +26,34 @@ class TicTacToe: else: 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.print() -game.make_move("X", 0) -game.print() +for x in range(1,10): + player.make_random_move(game.state) + game.print() + player1.make_random_move(game.state) + game.print() + + # make_move(state, "X", 0) # print_board(state)