diff options
-rw-r--r-- | search.py | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -168,7 +168,7 @@ def breadthFirstSearch(problem): def uniformCostSearch(problem): """Search the node of least total cost first.""" - "*** YOUR CODE HERE ***" + # The only differences between the search functions: # 1. Cost: Lambda function to get the total cost of a node # 2. Nodes: Data structure to store the nodes @@ -186,7 +186,7 @@ def uniformCostSearch(problem): node = nodes.pop() # If the node has been traversed by a cheaper path, skip it - if visited.has_key(node[0]) and visited[node[0]] < cost(node): + if visited.has_key(node[0]) and visited[node[0]] <= cost(node): continue # Add set the value at the nodes index to the cost |