I'm currently working on a recursive Prolog program to link routes together to create a basic GPS of the Birmingham area. At the moment I can get output as so:
Input
routeplan(selly_oak, aston, P).
Output
P = [selly_oak, edgbaston, ... , aston]
What I would like to do is have my program provide some sort of interface, so if I were to type in something along the lines of:
Route from selly_oak to aston
It would provide me with:
Go from selly_oak to edgbaston
Go from edgbaston to ...
Finally, Go from ... to aston.
Prolog is a powerful language so I assume this is easily possible, however many of the books I've taken out seem to skip over this part. As far as I am aware I have to use something along the lines of write() and read() although the details are unknown to me.
Could anyone here a Prolog novice out with some basic examples or links to further information?
EDIT: A lot of these answers seem very complicated, where the solution should only be around 5-10 lines of code. Reading in a value isn't a problem as I can do something along the lines of:
find:- write('Where are you? '), read(X), nl, write('Where do you want to go? '), read(Y), loopForRoute(X,Y).
I'd prefer it if the output could be written out using write() so a new line (nl) can be used, so that it displays like the output above.
If this were my input, how would I then arrange the top routeplan() to work with these inputs? Also, if I were to add the Lines for these stations as an extra parameter how would this then be implemented? All links are defined at the beginning of the file like so:
rlinks(selly_oak, edgbaston, uob_line).
rlinks(edgbaston, bham_new_street, main_line).
Therefore, with this information, it'd be good to be able to read the line as so.
Go from selly_oak to edgbaston using the uob_line
Go from edgbaston to ... using the ...
Finally, go from ... to aston using the astuni_line