I have this labyrinth:
and I need to make a navigation mechanism (on SWI-Prolog) through the rooms of the labyrinth. The prerequisites of the navigation mechanism are the following:
- The navigation has to support the start from ANY room and the end to ANY room as well.
- The user has to enter the starting room and the ending room.
- Check if the starting room is simultaneously the ending room and if it is,print the appropriate message and terminate the program.
- To find the accessible room of the current room.
- Check if the candidate room for selection has been reused again and if it has,then this room is rejected and it continues with other room.
- When a route is found from the starting room to the finish room, then this route is printed.
- The mechanism is repeated until all possible routes are found.
- The printing of possible paths should be of the form: a-->b-->j-->i-->h-->g-->k-->d-->e-->I am in room e.
- The program will start with the go/2 predicate with the two parameters of the starting and the ending room.
How can I make the Knowledge Base on this program??
I started with this:
room(a).
room(b).
room(c).
room(d).
room(e).
room(f).
room(g).
room(h).
room(i).
room(j).
room(k).
I am not sure but I think I need to use the following helping predicates:
member(X,[X|L]):- !.
member(X,[Y|L]):- member(X,L).
writelist([]).
writelist([L|Lt]):- write(L),write('-->'),writelist(Lt).