domains
list=symbol*
predicates
solve(symbol,list)
depthfirstsearch(list,symbol,list)
successor(symbol,symbol)
member(symbol,list)
final(symbol)
clauses
successor(a,b).
successor(b,d).
successor(b,e).
successor(a,c).
successor(c,f).
successor(c,g).
final(d).
final(e).
final(f).
final(g).
member(X,[X_]) .
member(X,[_T]) :-
member(X,T).
solve(Node,Solution) :-
depthfirstsearch([],Node,Solution).
depthfirstsearch(Path,Node,[NodePath]) :- final(Node).
depthfirstsearch(Path,Node,Solution) :- successor(Node,Node1),
not(member(Node1,Path)),
depthfirstsearch([NodePath],Node1,Solution).
goal solve(c,S).
Labels
- BFS (1)
- BNM (1)
- crypt arithmetic puzzle (1)
- depth first search (1)
- monkey banana problem (1)
- n-queen Problem (1)
- Tower of hanoi (1)
- water jug problem (1)
Friday, July 6, 2007
Subscribe to:
Post Comments (Atom)
1 comment:
Hello,
What is the Expected output of this code?
Post a Comment