#final.print_path()
      solved += 1
    else:
      unsolved.append(i)

  print("\n*************************************")
  print("Of {} initial problems, {} were solved in less than {} seconds by this solver.".format(len(PROBLEMS), solved, timebound))
  print("Problems that remain unsolved in the set are Problems: {}".format(unsolved))
  print("The benchmark implementation solved {} out of {} practice problems given {} seconds.".format(benchmark,len(PROBLEMS),timebound))
  print("*************************************\n")
  ##############################################################


if test_fval_function:

  test_state = LunarLockoutState("START", 0, None, 5, ((0, 0), (1, 0),(2,2),(4,2),(0,4),(4,4)),((0, 1)))

  correct_fvals = [0, 5, 10]

  ##############################################################
  # TEST fval_function
  print("*************************************")
  print('Testing fval_function')

  solved = 0
  weights = [0., .5, 1.]
  for i in range(len(weights)):

    test_node = sNode(test_state, hval=10, fval_function=fval_function)

    fval = fval_function(test_node, weights[i])
Ejemplo n.º 2
0

def anytime_gbfs(initial_state, heur_fn, timebound=2):
    #OPTIONAL
    '''Provides an implementation of anytime greedy best-first search.  This iteratively uses greedy best first search,'''
    '''At each iteration, however, a cost bound is enforced.  At each iteration the cost of the current "best" solution'''
    '''is used to set the cost bound for the next iteration.  Only paths within the cost bound are considered at each iteration.'''
    '''INPUT: a lunar lockout state that represents the start state and a timebound (number of seconds)'''
    '''OUTPUT: A goal state (if a goal is found), else False'''
    return 0


PROBLEMS = (
    #5x5 boards: all are solveable
    LunarLockoutState("START", 0, None, 5,
                      ((0, 0), (1, 0), (2, 2), (4, 2), (0, 4), (4, 4)),
                      ((0, 1), )),
    LunarLockoutState("START", 0, None, 5,
                      ((0, 0), (1, 0), (2, 2), (4, 2), (0, 4), (4, 4)),
                      ((0, 2), )),
    LunarLockoutState("START", 0, None, 5,
                      ((0, 0), (1, 0), (2, 2), (4, 2), (0, 4), (4, 4)),
                      ((0, 3), )),
    LunarLockoutState("START", 0, None, 5,
                      ((0, 0), (1, 0), (2, 2), (4, 2), (0, 4), (4, 4)),
                      ((1, 1), )),
    LunarLockoutState("START", 0, None, 5,
                      ((0, 0), (1, 0), (2, 2), (4, 2), (0, 4), (4, 4)),
                      ((1, 2), )),
    LunarLockoutState("START", 0, None, 5,
                      ((0, 0), (1, 0), (2, 2), (4, 2), (0, 4), (4, 4)),