project1_search/search/search.py
def breadthFirstSearch(problem):
    """Search the shallowest nodes in the search tree first."""
    fringe = util.Queue()
    start = [problem.getStartState(), 0, []]
    fringe.push(start)
    closed = []
    while not fringe.isEmpty():
        [node, cost, path] = fringe.pop()
        if problem.isGoalState(node):
            return path
        if not node in closed:
            closed.append(node)
            for child_node, child_action, child_cost in problem.getSuccessors(
                    node):
                new_cost = cost + child_cost
                new_path = path + [child_action]
                fringe.push([child_node, new_cost, new_path])
    util.raiseNotDefined()
Search the shallowest nodes in the search tree first.
Search the shallowest nodes in the search tree first.
Search the shallowest nodes in the search tree first .
def breadthFirstSearch(problem):
    fringe = util.Queue()
    start = [problem.getStartState(), 0, []]
    fringe.push(start)
    closed = []
    while not fringe.isEmpty():
        [node, cost, path] = fringe.pop()
        if problem.isGoalState(node):
            return path
        if not node in closed:
            closed.append(node)
            for child_node, child_action, child_cost in problem.getSuccessors(
                    node):
                new_cost = cost + child_cost
                new_path = path + [child_action]
                fringe.push([child_node, new_cost, new_path])
    util.raiseNotDefined()
def breadthFirstSearch ( problem ) : fringe = util . Queue ( ) start = [ problem . getStartState ( ) , 0 , [ ] ] fringe . push ( start ) closed = [ ] while not fringe . isEmpty ( ) : [ node , cost , path ] = fringe . pop ( ) if problem . isGoalState ( node ) : return path if not node in closed : closed . append ( node ) for child_node , child_action , child_cost in problem . getSuccessors ( node ) : new_cost = cost + child_cost new_path = path + [ child_action ] fringe . push ( [ child_node , new_cost , new_path ] ) util . raiseNotDefined ( )
Search the shallowest nodes in the search tree first.
Search the shallowest nodes in the search tree first .
"""Search the shallowest nodes in the search tree first."""
problem