Now define a predicate that begins
is_two_from( Cave1, Cave2 ) :-and which is true if there is one cave between Cave1 and Cave2, thus:
------- ------ ------- !Cave1!-----! !-----!Cave2! ------- ------ -------
Does your definition allow a cave to be two from itself? Why? What needs to be done to stop it happening?
Now, do the same for
is_three_from( Cave1, Cave2 ) :-There are two ways of doing this. One uses
is_two_fromafter the if; one does not. Try them both.
Finally, define a predicate
is_near( Cave1, Cave2 ) :-which is true if the caves are adjacent, or two apart, or three apart. You will certainly need more than one clause for this.