def _start_game(self) -> None: """ This method starts the game. """ self._clear_intro() self._game = Othello.Game(self._rows, self._columns, self._black_plays_first, self._white_in_top_left, self._win_with_most) self._last_move = '' self._last_player = 'black' self._draw_game()
def play_game() -> None: """ This function runs the othello game on the console. :rtype : None """ while True: _banner() while True: try: game = Othello.Game(_get_rows(), _get_columns(), _black_plays_first(), _white_in_top_left(), _win_with_most()) break except Othello.IncorrectNumberOfRows: print("\nNumber of rows is incorrect, please try again.") except Othello.IncorrectNumberOfColumns: print("\nNumber of columns is incorrect, please try again.") black_ai = _yes_no_to_bool( 'Would you like the computer to control Black? ') white_ai = _yes_no_to_bool( 'Would you like the computer to control White? ') while game.win_result() == "": _score_board(game) _board(game) if black_ai and game.current_player() == Othello.BLACK: move = othello_ai.move(game) game.move(move[0], move[1]) print("Black plays Row {}, Column {}.".format( move[0], move[1])) elif white_ai and game.current_player() == Othello.WHITE: move = othello_ai.move(game) game.move(move[0], move[1]) print("White plays Row {}, Column {}.".format( move[0], move[1])) else: try: game.move(_play_row(), _play_column()) except Othello.InvalidMove: print('\nInvalid selection, please try again.') _win_board(game) _board(game) if not _yes_no_to_bool('Would you like to play again?'): break