Inteligentna_smieciarka/bfs.py
Maksymilian Mikołajczak bdb0ed2d3c basic bfs implementation
2023-04-19 22:12:02 +02:00

16 lines
402 B
Python

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