我希望你能帮助我。深度优先搜索算法序言
我想了解在Prolog的深度优先搜索算法和我所遇到下面的代码
go(Start, Goal) :-
empty_stack(Empty_been_list),
stack(Start, Empty_been_list, Been_list),
path(Start, Goal, Been_list).
% path implements a depth first search in PROLOG
% Current state = goal, print out been list
path(Goal, Goal, Been_list) :-
reverse_print_stack(Been_list).
path(State, Goal, Been_list) :-
mov(State, Next),
% not(unsafe(Next)),
not(member_stack(Next, Been_list)),
stack(Next, Been_list, New_been_list),
path(Next, Goal, New_been_list), !.
reverse_print_stack(S) :-
empty_stack(S).
reverse_print_stack(S) :-
stack(E, Rest, S),
reverse_print_stack(Rest),
write(E), nl.
我有点明白是怎么回事,但我不能为我的生活中找到或发明一些我可以使用的事实。
请帮忙。即使它的一个非常简单的事实中,我只需要在某处开始
预先感谢您
[这里](http://stackoverflow.com/q/26946133/772868)是一个通用的解决了这个问题。你简单地说'clos0(mov,Start,Finis)' – false 2014-11-21 16:20:14
请缩进'去'像其他谓词 – vmg 2014-11-21 16:22:42
我可能已经去提问错误的方式,因为我不明白假'回答 – 2014-11-21 16:27:23