try 1 cannibal rows west to east alone 3 2 0 1
Moved to 3 2 0 1 e
try 1 cannibal rows east to west alone 3 3 0 0
BACKTRACK from:3 2 0 1
try 2 cannibals row west to east 3 1 0 2
Moved to 3 1 0 2 e
...
plus a listing of the solution path, as follows:
Solution path is state(3,3,0,0,w) state(2,2,1,1,e) state(2,3,1,0,w) state(2,1,1,2,e) state(2,2,1,1,w) state(1,1,2,2,e) state(1,2,2,1,w) state(1,0,2,3,e) state(1,1,2,2,w) state(0,0,3,3,e)For this problem you might want to consult the sample program, cannibals.pro, which provides a partial implementation of the solution.
PROLOG FTP LIBRARY: PROLOG does not contain a built-in "member" predicate, so you will have to include one in your database. You can ftp a file with some useful PROLOG predicates from the CPSC 352 FTP Site. There are several PROLOG sample programs available there as well. Feel free to have a look there and borrow whatever is helpful.
HANDIN DIRECTIONS:
To make a copy of your PROLOG sessions, you use the Unix script command:
$ script sfilename // a copy of your session will be saved bash$ prolog // script changes the unix prompt ?- // Do your PROLOG thing. ?- ... ?- ^D // exit PROLOG bash$ ^D // control-D exits from script Script done. File is sfilename. $lpr sfilename // print your script and annotate it