[F,W,G,C]
go :- initial_state(X), % boat(X,Y), % safestate(Y), rivercross(X,[X],Crossings,1), write('Start: '), write(X), write(' to: '), write(Crossings), nl. rivercross([s,s,s,s],FinalCrossings,FinalCrossings, _). rivercross(X,Crossings,FinalCrossings,Count) :- THIS IS ONLY PARTIALLY DONE Count < 20, Here "COUNT" is used to stop after boat(X,NewState), 20 moves, if recursion was stack overflowing safestate(NewState), write('Newstate: '),write(NewState),nl, Count2 is Count + 1, rivercross([s,s,s,s],Crossings, FinalCrossings,Count2). %THIS IS NOT CORRECT initial_state([n,n,n,n]). % each entity is on the north side. final_state([s,s,s,s]). % each is on the south side. boat([F,W,C,G],[F1,W,C,G]) :- cross(F,F1). % Farmer boats alone boat([F,F,C,G],[F1,F1,C,G]) :- cross(F,F1). % Farmer and wolf cross in boat boat([F,W,F,G],[F1,W,F1,G]) :- cross(F,F1). % Farmer and cabbage cross in boat boat([F,W,C,F],[F1,W,C,F1]) :- cross(F,F1). % Farmer and goat cross in boat cross(s,n). cross(n,s). safestate([n,n,n,n]). % All on one side of river safestate([s,s,s,s]). safestate([n,_,_,n]). % Farmer with goat safestate([s,_,_,s]). safestate([n,n,n,_]). % Farmer with wolf and cabbage safestate([s,s,s,_]). % Other safe states? member_state(S, [S|_]). member_state(X, [_|T]) :- member_state(X,T).