Esempio n. 1
0
def main():
    game = TicTacToeGame()
    while not game.is_over():
        try:
            display_board(game.board)
            row = int(input('Enter row: '))
            column = int(input('Enter column: '))
            try:
                game.make_move(row, column)
            except GameError as error:
                print(error)
        except ValueError:
            print('Invalid input.Try again.')
    display_board(game.board)
Esempio n. 2
0
 def __init__(self, **kwargs):
     super(TicTacToe, self).__init__(**kwargs)
     self.game = TicTacToeGame()
 def __init__(self, **kwargs):
     # super().__init__(**kwargs)
     # Python 2 version below:
     super(TicTacToe, self).__init__(**kwargs)
     self.game = TicTacToeGame()
Esempio n. 4
0
# Using the "model" class Game to play via the console "view"

from board_game import TicTacToeGame, GameError

game = TicTacToeGame()
while not game.is_over():
    try:
        print(game)
        row = int(input('Enter row: '))
        column = int(input('Enter column: '))
        try:
            game.make_move(row, column)
        except GameError as error:
            print(error)
    except ValueError:
        print('invalid input, try again')
print(game)