完成附加实验

master
huangjielun 3 years ago
parent bb551fb0f1
commit 566a42c81f

@ -552,11 +552,11 @@ class ClosestDotSearchAgent(SearchAgent):
"*** YOUR CODE HERE ***" "*** YOUR CODE HERE ***"
Result = [] Result = []
Visited = [] Visited = []
Heap = util.PriorityQueue() Queue = util.PriorityQueue()
startState = (problem.getStartState(),[],0) startState = (problem.getStartState(),[],0)
Heap.push(startState,startState[2]) Queue.push(startState,startState[2])
while not Heap.isEmpty(): while not Queue.isEmpty():
(state,path,cost) = Heap.pop() (state,path,cost) = Queue.pop()
if problem.isGoalState(state): if problem.isGoalState(state):
Result = path Result = path
break break
@ -566,7 +566,7 @@ class ClosestDotSearchAgent(SearchAgent):
newPath = path + [currentPath] newPath = path + [currentPath]
newCost = cost + currentCost newCost = cost + currentCost
newState = (currentState,newPath,newCost) newState = (currentState,newPath,newCost)
Heap.push(newState,newCost) Queue.push(newState,newCost)
return Result return Result
util.raiseNotDefined() util.raiseNotDefined()

Binary file not shown.
Loading…
Cancel
Save