Question: REVISE MY PROLOG CODE ========================= enter(b). exit(e). cheese(d). d(b,c). d(b,e). d(c,d). d(d,e). d(e,f). connected(X,Y):- d(X,Y);d(Y,X). path(A,B,Path):- go(A,B,[A],Q), reverse(Q,Path). go(A,B,P,[B|P]):- connected(A,B). go(A,B,Visited,Path):- connected(A,C), C==B, not(member(C,Visited)), go(C,B,[C|Visited],Path).
REVISE MY PROLOG CODE
=========================
enter(b). exit(e). cheese(d).
d(b,c). d(b,e). d(c,d). d(d,e). d(e,f).
connected(X,Y):- d(X,Y);d(Y,X).
path(A,B,Path):- go(A,B,[A],Q), reverse(Q,Path).
go(A,B,P,[B|P]):- connected(A,B). go(A,B,Visited,Path):- connected(A,C), C\==B, not(member(C,Visited)), go(C,B,[C|Visited],Path).
===========================
The Revised Code MUST INCLUDE the following rules:
-Some mice do not reach the exit because they become weak with hunger after visiting more than 3 rooms.
-Add a predicate cheese/1 that specifies which rooms have food (i.e., cheese), e.g., cheese(d) is true if and only if room d contains cheese.
-Change the program so that a mouse eats some cheese at least once every 3 rooms traversed. In other words, the mouse eats a little bit of cheese in any room that contains cheese,but if the mouse visits more than 3 rooms without eating cheese then that mouse must backtrack and try another path through the maze.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
