
go:-hra(l-l-l-l,p-p-p-p).
hra(V-K-Z-L,V1-K1-Z1-L1):-cesta(V-K-Z-L,V1-K1-Z1-L1,[V-K-Z-L],Acc),reverse(Acc,Seznam),writeln(Seznam).

cesta(V-K-Z-L,V-K-Z-L,Acc,Acc).
cesta(V-K-Z-L,V1-K1-Z1-L1,Acc,Cesta):-tah(V-K-Z-L,V2-K2-Z2-L2),\+ member(V2-K2-Z2-L2,Acc), cesta(V2-K2-Z2-L2,V1-K1-Z1-L1,[V2-K2-Z2-L2 | Acc],Cesta).


tah(V-K-L-L,V-K-L1-L1):-opak(L,L1),nezere(V-K-L1-L1).
tah(V-L-Z-L,V-L1-Z-L1):-opak(L,L1),nezere(V-L1-Z-L1).
tah(L-K-Z-L,L1-K-Z-L1):-opak(L,L1),nezere(L1-K-Z-L1).

tah(V-K-Z-L,V-K-Z-L1):-opak(L,L1),nezere(V-K-Z-L1).

opak(l,p).
opak(p,l).

nezere(V-K-Z-L):-(V\=K;V=L),
	(Z\=K;Z=L).
	
	
