Like the answer in How to define simple rule in prolog i define the following programm:
should(X, go_to(X, toilet)) :- full_bladder(X).
?- assert(full_bladder(bob)).
true.
?- should(bob, Action).
Action = go_to(bob, toilet)
I add now the facts:
?- assert(lastlocation(bob, floor)).
true.
?- assert(currentlocation(bob, toilet)).
true.
?- assert(empty_bladder(bob)).
true.
How can I now define the rule for:
"when currentlocation is toilet and empty_bladder then go to lastlocation"
This rule should ensure that for the following question
?- should(bob, Action).
the result should be
Action = go_to(bob, floor).
I hope, someone can help me, how to define the rule.