Home > Archive > Prolog > April 2005 > prolog help producing route finder
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
prolog help producing route finder
|
|
| chriszero7 2005-04-19, 12:36 pm |
| Hey any help is greatly appreciated complete newb to prolog, trying to produce a route finder, i'm given this program to start with;
% chicago.pl
:-use_module(library(lists)).
%road/3
road(bourt,chicago,5).
road(chicago,canter,30).
road(canter,gaton,30).
road(canter,idmouths,25).
road(staple,onbur,20).
road(staple,gaton,40).
road(staple,tiv,15).
road(gaton,tivworthy,30).
road(onbur,idmouths,10).
road(onbur,tiv,10).
What i need help with is i have to produce a predicate trip/3 which is a bi-directional version of the above road/3, i think it only involves writing 2 rules of which the comments are;
%trip/3
% rule 1
% you can make a trip of distance DIST from A to B
% if there is a road of distance DIST from A to B
% rule 2
% you can make a trip of distance DIST from A to B
% if there is a road of distance DIST from B to A
Any help with this would be appreciated. Thanks. | |
| chriszero7 2005-04-23, 3:01 pm |
| %trip/3
trip(A,B,DIST) :- road(A,B,DIST).
trip(A,B,DIST) :- road(B,A,DIST). |
|
|
|
|