Re: about a prolog breadth-first exercises
- From: Cesar Rabak <csrabak@xxxxxxxxxxxx>
- Date: Thu, 12 Jul 2007 18:34:06 -0300
Btsw escreveu:
hello, this is my exercises about a prolog breadth-first, i fill the[snipped]
places, but it doesn't work, anybody can help me?
thanks.
[Exercises]Fill out places blank:
[My Answers]
/*breadth first sarch*/
breadthfirst(Startnode,Solution_path) :-
bdsearch([Startnode],Solution_path).
bdsearch([Node|Path|_],[Node|Path]) :- goalnode(Node).
bdsearch([Node|Path],Solution_path) :-
expand(Node,New_paths), %expand the leftmost node
append(Path,New_paths,New_paths), %add the children node to list
bdsearch(New_paths,Solution_path). %call bdsearch recursively
%define predicate expand
expand([Node|Path],New_paths):- bagof([X,Node|Path],
(successor(Node,X),not(member(X,[Node|Path]))),New_paths),!.
expand(_,[]).
Did you try to write what expand had to perform in plain text language
and then implement the specification in Prolog?
.
- Follow-Ups:
- Re: about a prolog breadth-first exercises
- From: Btsw
- Re: about a prolog breadth-first exercises
- From: Btsw
- Re: about a prolog breadth-first exercises
- References:
- about a prolog breadth-first exercises
- From: Btsw
- about a prolog breadth-first exercises
- Prev by Date: Re: Floyd warshall
- Next by Date: To eliminate duplicated clauses
- Previous by thread: about a prolog breadth-first exercises
- Next by thread: Re: about a prolog breadth-first exercises
- Index(es):
Relevant Pages
|
|