def get_move(state: othello_logic.OthelloGameState) -> None: ''' Asks the user to specify a move and places the appropriate piece on the specified cell ''' full_name = {state._BLACK: 'BLACK', state._WHITE: 'WHITE'} if not state.check_valid(): print("\n{} passes\n".format(full_name[state.pass_turn()])) print("\n\nIt is {}'s turn".format(full_name[state._turn])) ALPHABET = 'abcdefghijklmnopqrstuvwxyz' while True: move = input("Please specify a cell - {letter}{number}: ").strip().lower() try: column = ALPHABET.index(move[0]) row = int(move[1:].strip())-1 return state.place_piece(row, column) except: print("\n'{}' is an invalid move.\n".format(move))
def get_move(state: othello_logic.OthelloGameState) -> None: ''' Asks the user to specify a move and places the appropriate piece on the specified cell ''' full_name = {state._BLACK: 'BLACK', state._WHITE: 'WHITE'} if not state.check_valid(): print("\n{} passes\n".format(full_name[state.pass_turn()])) print("\n\nIt is {}'s turn".format(full_name[state._turn])) ALPHABET = 'abcdefghijklmnopqrstuvwxyz' while True: move = input( "Please specify a cell - {letter}{number}: ").strip().lower() try: column = ALPHABET.index(move[0]) row = int(move[1:].strip()) - 1 return state.place_piece(row, column) except: print("\n'{}' is an invalid move.\n".format(move))