Exemplo n.º 1
0
class BasicTicTacToe:
    def __init__(self):
        self._board = TicTacToeBoard()
        self._board._current_player_turn = "X"
        return

    def play(self):
        while not (self._board.check_win_condition() is not None or self._board.check_win_condition() == "draw"):
            print("Please make your move:" + "/n")
            self._board.draw()
            location = int(raw_input("Choose a number(1-9): "))
            self._board.move(location)
            self._board.draw()
        if self._board.check_win_condition() != "draw":
            print("Player " + self._board.check_win_condition() + " wins!")
        else:
            print("Game draw!")
Exemplo n.º 2
0
from ttt_board import TicTacToeBoard

# get a TicTacToeBoard object
board = TicTacToeBoard()

while not board.game_over():
    print('\n')
    board.show()

    # read a number
    tile = input('Player ' + board.marker[board.current_player] + ': ')

    board.set(tile, board.current_player)

    # switch to the next player, hehe
    board.current_player = 3 - board.current_player

print('\n')
board.show()

winner = board.get_winner()
if board.get_winner() > 0:
    print('Yaaaay, Player ' + board.marker[winner] + ' won.')
else:
    print('Everyone lost.')
Exemplo n.º 3
0
 def __init__(self):
     self._board = TicTacToeBoard()
     self._board._current_player_turn = "X"
     return