domains
node = symbol
path=symbol*
database
edge(node,node)
final(node)
predicates
solve(node,path)
depth(path,node,path)
member(node,path)
go
clauses
member(X,[X|_]).
member(X,[_|T]):-
member(X,T).
solve(Node,Solution):-
depth([],Node,Solution).
depth(Path,Node,[Node|Path]):-
final(Node).
depth(Path,Node,Solution):-
edge(Node,Node1),
not(member(Node1,Path)),
depth([Node|Path],Node1,Solution).
go:-
write("enter node1"),nl,
readln(N1),nl,
write("enter node2"),nl,
readln(N2),nl,
assert(edge(N1,N2)),
write("enter y to continue or press n"),nl,
readchar(S),S='y',
go.
go:-
write("enter final node "),nl,
readln(F),nl,
assert(final(F)),nl,
write("Enter node from which to traverse"),nl,
readln(T),nl,
solve(T,Path),
write(Path),nl.
goal
go.
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)
Tuesday, July 3, 2007
Subscribe to:
Post Comments (Atom)
1 comment:
hay buddy its really nice thnks
Post a Comment