Skip to content
Snippets Groups Projects
Commit e1a7a4a5 authored by Michael Mutote's avatar Michael Mutote
Browse files

22202956

refactored
parent 4d147871
No related branches found
No related tags found
No related merge requests found
File moved
import queue
from collections import deque
def BreadthFirstSearch(state, successor, isgoal):
......@@ -17,3 +18,22 @@ def BreadthFirstSearch(state, successor, isgoal):
path2 = path + [next_state]
toDo.put(path2)
return "Error Path not found"
def DepthFirstSearch(state, successor, isgoal):
"""accepts start state, Please do not change this function"""
toDo = deque()
toDo.append([state])
explored = {state}
while not toDo:
path = toDo.pop()
current = path[-1]
if isgoal(current):
return path
for next_state in successor(current):
if next_state not in explored:
explored.add(next_state)
path2 = path + [next_state]
toDo.append(path2)
return "Error Path not found"
File moved
File moved
import breadth_first_search
import Search_Algorithms
import Sucessors
import is_goal
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment