Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1.     from game import Directions
  2.  
  3.     fringe = util.Stack()
  4.     expanded = []
  5.  
  6.     fringe.push(problem.getStartState())
  7.  
  8.     while (not fringe.isEmpty()):
  9.         toExpand = fringe.pop()
  10.  
  11.         if (toExpand in expanded):
  12.             print "NOTEXPANDING: ", toExpand, "lenToExpand:" , len(toExpand)
  13.             continue;
  14.         else:
  15.  
  16.             if len(toExpand) == 2:
  17.                 if (problem.isGoalState(toExpand)):
  18.                     print "GOAL STATE FOUND"
  19.                     break
  20.             else:
  21.                 if (problem.isGoalState(toExpand[0])):
  22.                     print "GOAL STATE FOUND"
  23.                     break
  24.  
  25.             expanded.append(toExpand)
  26.  
  27.             print "toExpand: ", toExpand, "lenToExpand:" , len(toExpand)
  28.             if len(toExpand) == 2:
  29.                 for i in reversed(problem.getSuccessors(toExpand)):
  30.                     fringe.push(i)
  31.             else:
  32.                 for i in reversed(problem.getSuccessors(toExpand[0])):
  33.                     fringe.push(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement