% nacteni:
/* ['3.5_15.pl']. */

solution(Node,Solution) :- depth_first_search_limit(Node,Solution,999).

depth_first_search_limit(Node,[Node], _) :- goal(Node).
depth_first_search_limit(Node,[Node|Sol],MaxDepth) :- MaxDepth>0, move(Node,Node1),
    Max1 is MaxDepth-1,depth_first_search_limit(Node1,Sol,Max1).

% vzorova data
goal(e).
move(a,b). move(a,e). move(a,f).
move(b,c). move(f,c). move(c,d). move(d,e).

% demonstracni vypis

start:- 
    write('depth_first_search_limit'),nl,
    write('Prvni reseni solution(a,Solution):'),nl,
    solution(a,Solution),write(Solution),nl.
?-start.

