我的书中有以下伪代码用于广度优先搜索:
function breadth_first_search:
begin
open := [Start]
closed := [];
while open != [] do
begin
remove leftmost state from open, call it X;
if X is a goal then return SUCCESS
else begin
generate children of X;
put X on closed;
discard children of X if already on open or closed;
put remaining children on right end of open;
end
end
return FAIL;
end
我自己按照这些伪代码指令实现了一个类似的算法。我的问题是,修改它以保持解决方案路径的最简单方法是什么?
仅仅知道我可以找到解决方案并没有获得解决方案的转换列表那么有用。