def every_move(board, symbol, row, column):
    '''Ask user to put in number and check the number
       if there is a valid place. Otherwise, ask again.'''

    number=['1','2','3','4','5','6','7','8','9','10']
    while True:
        move_column = input("Please enter the column of your move into the grid:")
        move_row = input('Please enter the row of your move into the grid:')
        if len(move_column) > 2 and len(move_row) > 2:
            print("The length of your input has to be 2. Please try again.")
            continue
        try:
            x = int(move_column)
            y = int(move_row)
        except:
            print('The type of the inputs have to be (int).')
            continue

        if not move_column in number or not move_row in number:
            print('Please enter input as number within your column and row. Please try again.')
            continue

        if int(move_column) > column or int(move_row) > row:
            print('Both (XY)in input should should not greater than the column or row. Please try again.')
            continue
        try:
            x = x-1
            y = y-1
            if state.can_move(board, symbol, x, y, row, column) == False:
                raise Error
        except:
            print("Not a valid move, please try again.")
            continue
        break
    return [x,y]
def every_move(board, symbol, row, column):
    '''Ask user to put in number and check the number
       if there is a valid place. Otherwise, ask again.'''

    number = ['1', '2', '3', '4', '5', '6', '7', '8']
    while True:
        move = input("Please enter your move as 'XY' on the grid:")
        if len(move) != 2:
            print("The length of your input has to be 2. Please try again.")
            continue

        if not move[0] in number or not move[1] in number:
            print('Please enter input as number. Please try again.')
            continue

        if int(move[0]) > column or int(move[1]) > row:
            print(
                'Both (XY)in input should should not greater than the column or row. Please try again.'
            )
            continue
        try:
            x = int(move[0]) - 1
            y = int(move[1]) - 1
            if state.can_move(board, symbol, x, y, row, column) == False:
                raise Error
        except:
            print("Not a valid move, please try again.")
            continue
        break
    return [x, y]
def every_move(board, symbol, row, column):
    '''Ask user to put in number and check the number
       if there is a valid place. Otherwise, ask again.'''

    number=['1','2','3','4','5','6','7','8']
    while True:
        move = input("Please enter your move as 'XY' on the grid:")
        if len(move) != 2:
            print("The length of your input has to be 2. Please try again.")
            continue

        if not move[0] in number or not move[1] in number:
            print('Please enter input as number. Please try again.')
            continue

        if int(move[0]) > column or int(move[1]) > row:
            print('Both (XY)in input should should not greater than the column or row. Please try again.')
            continue
        try:
            x = int(move[0])-1
            y = int(move[1])-1
            if state.can_move(board, symbol, x, y, row, column) == False:
                raise Error
##            else:
##                print(state.can_move(board, symbol, x, y, row, column))
        except:
            print("Not a valid move, please try again.")
            continue
        break
    return [x,y]
Ejemplo n.º 4
0
def every_move(board, symbol, row, column, top):
    '''Ask user to put in number and check the number
       if there is a valid place. Otherwise, ask again.'''

    ##    number=['1','2','3','4','5','6','7','8','9','10']
    while True:
        ##        move_column = input("Please enter the column of your move into the grid:")
        ##        move_row = input('Please enter the row of your move into the grid:')
        ##        if len(move_column) > 2 and len(move_row) > 2:
        ##            print("The length of your input has to be 2. Please try again.")
        ##            continue
        ##        try:
        ##            x = int(move_column)
        ##            y = int(move_row)
        ##        except:
        ##            print('The type of the inputs have to be (int).')
        ##            continue
        ##
        ##        if not move_column in number or not move_row in number:
        ##            print('Please enter input as number within your column and row. Please try again.')
        ##            continue
        ##
        ##        if int(move_column) > column or int(move_row) > row:
        ##            print('Both (XY)in input should should not greater than the column or row. Please try again.')
        ##            continue
        get_x_y = BoardCopy.BoardApplication(column, row, top)._pass_xandy()
        x = get_x_y[0]
        y = get_x_y[1]
        try:
            x = x - 1
            y = y - 1
            if state.can_move(board, symbol, x, y, row, column) == False:
                raise Error
        except:
            print("Not a valid move, please try again.")
            continue
        break
    return [x, y]
def every_move(board, symbol, row, column, top):
    '''Ask user to put in number and check the number
       if there is a valid place. Otherwise, ask again.'''

##    number=['1','2','3','4','5','6','7','8','9','10']
    while True:
##        move_column = input("Please enter the column of your move into the grid:")
##        move_row = input('Please enter the row of your move into the grid:')
##        if len(move_column) > 2 and len(move_row) > 2:
##            print("The length of your input has to be 2. Please try again.")
##            continue
##        try:
##            x = int(move_column)
##            y = int(move_row)
##        except:
##            print('The type of the inputs have to be (int).')
##            continue
##
##        if not move_column in number or not move_row in number:
##            print('Please enter input as number within your column and row. Please try again.')
##            continue
##  
##        if int(move_column) > column or int(move_row) > row:
##            print('Both (XY)in input should should not greater than the column or row. Please try again.')
##            continue
        get_x_y = BoardCopy.BoardApplication(column,row, top)._pass_xandy()
        x= get_x_y[0]
        y= get_x_y[1]
        try:
            x = x-1
            y = y-1
            if state.can_move(board, symbol, x, y, row, column) == False:
                raise Error
        except:
            print("Not a valid move, please try again.")
            continue
        break
    return [x,y]