Помогите исправить код... Прога работает, но не выдает полный ответ, а только Yes.
Задача: Три миссионера и три каннибала хотят переправиться с левого берега на правый. Как это сделать за минимальное число шагов, если в их распоряжении имеется трехместная лодка и ни при каких обстоятельствах (в лодке или на берегу) миссионеры не должны оставаться в меньшинстве.
/*1 kannibal*/
move(state(X,K2,K3,M1,M2,M3),state(Y,K2,K3,M1,M2,M3)):-opposite(X,Y).
move(state(K1,X,K3,M1,M2,M3),state(K1,Y,K3,M1,M2,M3)):-opposite(X,Y).
move(state(K1,K2,X,M1,M2,M3),state(K1,K2,Y,M1,M2,M3)):-opposite(X,Y).
/*2 kannibala*/
move(state(X,X,K3,M1,M2,M3),state(Y,Y,K3,M1,M2,M3)):-opposite(X,Y).
move(state(X,K2,X,M1,M2,M3),state(Y,K2,Y,M1,M2,M3)):-opposite(X,Y).
move(state(K1,X,X,M1,M2,M3),state(K1,Y,Y,M1,M2,M3)):-opposite(X,Y).
/*3 kannibala*/
move(state(X,X,X,M1,M2,M3),state(Y,Y,Y,M1,M2,M3)):-opposite(X,Y).
/*1 missioner*/
move(state(K1,K2,K3,X,M2,M3),state(K1,K2,K3,Y,M2,M3)):-opposite(X,Y).
move(state(K1,K2,K3,M1,X,M3),state(K1,K2,K3,M1,Y,M3)):-opposite(X,Y).
move(state(K1,K2,K3,M1,M2,X),state(K1,K2,K3,M1,M2,Y)):-opposite(X,Y).
/*2 missionera*/
move(state(K1,K2,K3,X,X,M3),state(K1,K2,K3,Y,Y,M3)):-opposite(X,Y).
move(state(K1,K2,K3,M1,X,X),state(K1,K2,K3,M1,Y,Y)):-opposite(X,Y).
move(state(K1,K2,K3,X,M2,X),state(K1,K2,K3,Y,M2,Y)):-opposite(X,Y).
/*3 missionera*/
move(state(K1,K2,K3,X,X,X),state(K1,K2,K3,Y,Y,Y)):-opposite(X,Y).
/*1 kannibal, 1 missioner*/
move(state(X,K2,K3,X,M2,M3),state(Y,K2,K3,Y,M2,M3)):-opposite(X,Y).
move(state(K1,X,K3,X,M2,M3),state(K1,Y,K3,Y,M2,M3)):-opposite(X,Y).
move(state(K1,K2,X,X,M2,M3),state(K1,K2,Y,Y,M2,M3)):-opposite(X,Y).
move(state(X,K2,K3,M1,X,M3),state(Y,K2,K3,M1,Y,M3)):-opposite(X,Y).
move(state(K1,X,K3,M1,X,M3),state(K1,Y,K3,M1,Y,M3)):-opposite(X,Y).
move(state(K1,K2,X,M1,X,M3),state(K1,K2,Y,M1,Y,M3)):-opposite(X,Y).
move(state(X,K2,K3,M1,M2,X),state(Y,K2,K3,M1,M2,Y)):-opposite(X,Y).
move(state(K1,X,K3,M1,M2,X),state(K1,Y,K3,M1,M2,Y)):-opposite(X,Y).
move(state(K1,K2,X,M1,M2,X),state(K1,K2,Y,M1,M2,Y)):-opposite(X,Y).
/*1 kannibal, 2 missionera*/
move(state(X,K2,K3,X,X,M3),state(Y,K2,K3,Y,Y,M3)):-opposite(X,Y).
move(state(X,K2,K3,M1,X,X),state(Y,K2,K3,M1,Y,Y)):-opposite(X,Y).
move(state(X,K2,K3,X,M2,X),state(Y,K2,K3,Y,M2,Y)):-opposite(X,Y).
move(state(K1,X,K3,X,X,M3),state(Y,K2,K3,Y,Y,M3)):-opposite(X,Y).
move(state(K1,X,K3,M1,X,X),state(K1,Y,K3,M1,Y,Y)):-opposite(X,Y).
move(state(K1,X,K3,X,M2,X),state(K1,Y,K3,Y,M2,Y)):-opposite(X,Y).
move(state(K1,K2,X,X,X,M3),state(K1,K2,Y,Y,Y,M3)):-opposite(X,Y).
move(state(K1,K2,X,M1,X,X),state(K1,K2,Y,M1,Y,Y)):-opposite(X,Y).
move(state(K1,K2,X,X,M2,X),state(K1,K2,Y,Y,M2,Y)):-opposite(X,Y).
opposite(east,west).
opposite(west,east).
/*2 kannibala, 1 missioner*/
unsafe(state(X1,X2,X3,Y1,Y2,Y3)):-
X1 = east,X2 = east,Y1 = east;
X1 = east,X3 = east,Y1 = east;
X2 = east,X3 = east,Y1 = east;
X1 = east,X2 = east,Y2 = east;
X1 = east,X3 = east,Y2 = east;
X2 = east,X3 = east,Y2 = east;
X1 = east,X2 = east,Y3 = east;
X1 = east,X3 = east,Y3 = east;
X2 = east,X3 = east,Y3 = east;
X1 = west,X2 = west,Y1 = west;
X1 = west,X3 = west,Y1 = west;
X2 = west,X3 = west,Y1 = west;
X1 = west,X2 = west,Y2 = west;
X1 = west,X3 = west,Y2 = west;
X2 = west,X3 = west,Y2 = west;
X1 = west,X2 = west,Y3 = west;
X1 = west,X3 = west,Y3 = west;
X2 = west,X3 = west,Y3 = west;
X1 = east,X2 = east,X3 = east,Y1 = east;
X1 = east,X2 = east,X3 = east,Y2 = east;
X1 = east,X2 = east,X3 = east,Y3 = east;
X1 = west,X2 = west,X3 = west,Y1 = west;
X1 = west,X2 = west,X3 = west,Y2 = west;
X1 = west,X2 = west,X3 = west,Y3 = west;
X1 = east,X2 = east,X3 = east,Y1 = east,Y2 = east;
X1 = east,X2 = east,X3 = east,Y1 = east,Y3 = east;
X1 = east,X2 = east,X3 = east,Y2 = east,Y3 = east;
X1 = west,X2 = west,X3 = west,Y1 = west,Y2 = west;
X1 = west,X2 = west,X3 = west,Y1 = west,Y3 = west;
X1 = west,X2 = west,X3 = west,Y2 = west,Y3 = west.
path(Start,Finish,L,L1):-
move(Start,S1),
not(unsafe(S1)),
not(member(S1,L)),
path(S1,Finish,[S1|L],L1),!.
path(Finish,Finish,T,T):-!. /* The final state is reached */
go:-go(state(east,east,east,east,east,east),state(west,west,west,west,west,west)).
go(Start,Finish):-
path(Start,Finish,[Start],L),
nl,write("A solution is:"),nl,
write_path(L),
fail.
go(_,_).
member(X,[X|_]).
member(X,[_|L]):-member(X,L).
/*1 kannibal*/
write_move(state(X,K2,K3,M1,M2,M3),state(Y,K2,K3,M1,M2,M3)):-!,
write("1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,X,K3,M1,M2,M3),state(K1,Y,K3,M1,M2,M3)):-!,
write("1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,X,M1,M2,M3),state(K1,K2,Y,M1,M2,M3)):-!,
write("1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
/*2 kannibala */
write_move(state(X,X,K3,M1,M2,M3),state(Y,Y,K3,M1,M2,M3)):-!,
write("2 kannibala goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(X,K2,X,M1,M2,M3),state(Y,K2,Y,M1,M2,M3)):-!,
write("2 kannibala goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,X,X,M1,M2,M3),state(K1,Y,Y,M1,M2,M3)):-!,
write("2 kannibala goes from"),
write(X),
write(" to "),
write(Y),nl.
/*3 kannibala*/
write_move(state(X,X,X,M1,M2,M3),state(Y,Y,Y,M1,M2,M3)):-!,
write("3 kannibala goes from"),
write(X),
write(" to "),
write(Y),nl.
/*1 missioner*/
write_move(state(K1,K2,K3,X,M2,M3),state(K1,K2,K3,Y,M2,M3)):-!,
write("1 missioner goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,K3,M1,X,M3),state(K1,K2,K3,M1,Y,M3)):-!,
write("1 missioner goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,K3,M1,M2,X),state(K1,K2,K3,M1,M2,Y)):-!,
write("1 missioner goes from"),
write(X),
write(" to "),
write(Y),nl.
/*2 missionera*/
write_move(state(K1,K2,K3,X,X,M3),state(K1,K2,K3,Y,Y,M3)):-!,
write("2 missionera goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,K3,M1,X,X),state(K1,K2,K3,M1,Y,Y)):-!,
write("2 missionera goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,K3,X,M2,X),state(K1,K2,K3,Y,M2,Y)):-!,
write("2 missionera goes from"),
write(X),
write(" to "),
write(Y),nl.
/*3 missionera*/
write_move(state(K1,K2,K3,X,X,X),state(K1,K2,K3,Y,Y,Y)):-!,
write("3 missionera goes from"),
write(X),
write(" to "),
write(Y),nl.
/*1 kannibal, 1 missioner*/
write_move(state(X,K2,K3,X,M2,M3),state(Y,K2,K3,Y,M2,M3)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,X,K3,X,M2,M3),state(K1,Y,K3,Y,M2,M3)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,X,X,M2,M3),state(K1,K2,Y,Y,M2,M3)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(X,K2,K3,M1,X,M3),state(Y,K2,K3,M1,Y,M3)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,X,K3,M1,X,M3),state(K1,Y,K3,M1,Y,M3)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,X,M1,X,M3),state(K1,K2,Y,M1,Y,M3)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(X,K2,K3,M1,M2,X),state(Y,K2,K3,M1,M2,Y)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,X,K3,M1,M2,X),state(K1,Y,K3,M1,M2,Y)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,X,M1,M2,X),state(K1,K2,Y,M1,M2,Y)):-!,
write("1 missioner, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
/*1 kannibal, 2 missionera*/
write_move(state(X,K2,K3,X,X,M3),state(Y,K2,K3,Y,Y,M3)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(X,K2,K3,M1,X,X),state(Y,K2,K3,M1,Y,Y)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(X,K2,K3,X,M2,X),state(Y,K2,K3,Y,M2,Y)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,X,K3,X,X,M3),state(Y,K2,K3,Y,Y,M3)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,X,K3,M1,X,X),state(K1,Y,K3,M1,Y,Y)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,X,K3,X,M2,X),state(K1,Y,K3,Y,M2,Y)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,X,X,X,M3),state(K1,K2,Y,Y,Y,M3)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,X,M1,X,X),state(K1,K2,Y,M1,Y,Y)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_move(state(K1,K2,X,X,M2,X),state(K1,K2,Y,Y,M2,Y)):-!,
write("2 missionera, 1 kannibal goes from"),
write(X),
write(" to "),
write(Y),nl.
write_path([H1,H2|T]):-!,
write_move(H1,H2),write_path([H2|T]).
write_path(_).
?-go.