"git@mygit.th-deg.de:ns29110/thd-uni-app-mit2023.git" did not exist on "d28d1abd85c0e8766b3ea1053ef5ec00ab917779"
Newer
Older
import queue
from collections import deque
def BreadthFirstSearch(state, successor, isgoal):
"""accepts start state, Please do not change this function"""
toDo = queue.Queue()
toDo.put([state])
explored = {state}
while not toDo.empty():
path = toDo.get()
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.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}
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]