Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :- consult('search.pl').
- child(a, b). child(a, c).
- child(b, d). child(b, e).
- child(c, f). child(c, g).
- move([A|State], [B|[A|State]]) :-
- child(A, B).
- move([A|State], [B|[A|State]]) :-
- anchestor(X, A),
- child(X, B),
- \+ member(B, [A|State]).
- anchestor(A, B) :- child(A, B).
- anchestor(A, B) :-
- child(A, X),
- anchestor(X, B).
- goal(State) :-
- member(a, State),
- member(b, State),
- member(c, State),
- member(d, State),
- member(e, State),
- member(f, State),
- member(g, State).
- depthfirst_traversal(X, List) :-
- solve_depthfirst_cyclefree([X], Path),
- last(Path, Result),
- reverse(Result, List).
Add Comment
Please, Sign In to add comment