Inteligentna_smieciarka/bfs.py

16 lines
402 B
Python
Raw Normal View History

2023-04-19 22:12:02 +02:00
from succ import succ as successors
def bfs(istate, goalstate):
fringe = [istate]
explored = []
while(fringe):
state = fringe.pop(0)
if state == goalstate :
return
element = successors(state)
explored.append(state)
for value in element :
if value not in explored :
fringe.append(value)
return False