16 lines
402 B
Python
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
|