def backtracking_helper(board):
    """ Does the DFS and checks constraints while doing that"""

    if board.is_goal():
        global WINNING_BOARD
        import copy

        WINNING_BOARD = copy.deepcopy(board)
        return True

    import copy

    old_board = copy.deepcopy(board)
    cordinates = board.get_next_cell_fn()

    if cordinates is None:
        return False

    for value in range(1, board.size + 1):

        if board.insert(cordinates[0], cordinates[1], value):
            if backtracking_helper(board):
                return True
        board = copy.deepcopy(old_board)

    return False
Ejemplo n.º 2
0
def backtracking_mrv_cp_helper(board):
    """ Does the DFS and checks constraints while doing that"""
    if board.is_goal():
        global WINNING_BOARD
        import copy
        WINNING_BOARD = copy.deepcopy(board)
        return True
    import copy
    old_board = copy.deepcopy(board)
    result = board.get_next_cell_fn()

    if result is None:
        return False

    for value in result[1]:
        
        if board.insert(result[0][0],result[0][1],value):
            if backtracking_mrv_cp_helper(board):
                return True
        board = copy.deepcopy(old_board)

    return False
Ejemplo n.º 3
0
def backtracking_helper(board):
    """ Does the DFS and checks constraints while doing that"""

    if board.is_goal():
        global WINNING_BOARD
        import copy
        WINNING_BOARD = copy.deepcopy(board)
        return True

    import copy
    old_board = copy.deepcopy(board)
    cordinates = board.get_next_cell_fn()

    if cordinates is None:
        return False

    for value in range(1,board.size+1):
        
        if board.insert(cordinates[0],cordinates[1],value):
            if backtracking_helper(board):
                return True
        board = copy.deepcopy(old_board)

    return False
def backtracking_mrv_cp_helper(board):
    """ Does the DFS and checks constraints while doing that"""
    if board.is_goal():
        global WINNING_BOARD
        import copy

        WINNING_BOARD = copy.deepcopy(board)
        return True
    import copy

    old_board = copy.deepcopy(board)
    result = board.get_next_cell_fn()

    if result is None:
        return False

    for value in result[1]:

        if board.insert(result[0][0], result[0][1], value):
            if backtracking_mrv_cp_helper(board):
                return True
        board = copy.deepcopy(old_board)

    return False