car(berlin, munich). car(berlin, stuttgart). car(mainz, munich). bus(augsburg, berlin). bus(köln, dortmund). bus(dortmund, stuttgart).
My task is to find if there is a path between a 'Start' and 'End Location', which has been resolved but now comes the "hard" part. We have to find a path that changes max ONE time between bus and car. Also if I'm in a bus I have to get to my end location just within buses or change one time the bus with a car(of course we can then change between cars, but not back to bus).
Also I've found a way to find the path but just for bus paths, not cars and it looks like this.
isPath(from, to) :- isPath(from, to, ). isPath(from, to, _) :- bus(from, to). isPath(from, to, visited) :- \+ member(from, visited), bus(from, X), isPath(X, to, [from|visited]).
I'm sure it is not that hard, I just have to save somehow the fact that the bus/car has been changed with the other one.
Can someone help me?
isPath(From, To) :- isPath(From, To, ).
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.