project1_search/search/search.py
def depthFirstSearch(problem):
    """
    Search the deepest nodes in the search tree first.

    Your search algorithm needs to return a list of actions that reaches the
    goal. Make sure to implement a graph search algorithm.

    To get started, you might want to try some of these simple commands to
    understand the search problem that is being passed in:

    print("Start:", problem.getStartState())
    print("Is the start a goal?", problem.isGoalState(problem.getStartState()))
    print("Start's successors:", problem.getSuccessors(problem.getStartState()))
    """
    fringe = util.Stack()
    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 deepest nodes in the search tree first.

    Your search algorithm needs to return a list of actions that reaches the
    goal. Make sure to implement a graph search algorithm.

    To get started, you might want to try some of these simple commands to
    understand the search problem that is being passed in:

    print("Start:", problem.getStartState())
    print("Is the start a goal?", problem.isGoalState(problem.getStartState()))
    print("Start's successors:", problem.getSuccessors(problem.getStartState()))
    
Search the deepest nodes in the search tree first.
Your search algorithm needs to return a list of actions that reaches the
goal. Make sure to implement a graph search algorithm.

To get started, you might want to try some of these simple commands to
understand the search problem that is being passed in.


Search the deepest nodes in the search tree first . Your search algorithm needs to return a list of actions that reaches the goal . Make sure to implement a graph search algorithm . To get started you might want to try some of these simple commands to understand the search problem that is being passed in .
def depthFirstSearch(problem):
    fringe = util.Stack()
    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 depthFirstSearch ( problem ) : fringe = util . Stack ( ) 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 deepest nodes in the search tree first.
Search the deepest nodes in the search tree first .
"""
    Search the deepest nodes in the search tree first.

    Your search algorithm needs to return a list of actions that reaches the
    goal. Make sure to implement a graph search algorithm.

    To get started, you might want to try some of these simple commands to
    understand the search problem that is being passed in:

    print("Start:", problem.getStartState())
    print("Is the start a goal?", problem.isGoalState(problem.getStartState()))
    print("Start's successors:", problem.getSuccessors(problem.getStartState()))
    """
problem