-1

%three variants of actions. I have 3 animals and it can drive on plane, car or miss the %step. I know, that on the first step monkey ride on plane, wolf ride on car. On the second %step wolf ride on plane. We need to know accordance that remain. And each animal ride on %each vehicle only on time

action(plane).
action(car).
action(shift).

%I declare passenger iside my function solve

solve([passenger(monkey, [X1,X2,X3]), passenger(wolf, [Y1, Y2,Y3]),
passenger(hippo, [Z1, Z2, Z3])]):-
   action(X1), action(Y1), action(Z1), unique([X1, Y1, Z1]),
   action(X2), action(Y2), action(Z2), unique([X2, Y2, Z2]),
   action(X3), action(Y3), action(Z3), unique([X3, Y3, Z3]),

   unique([X1, X2, X3]), unique([Y1, Y2, Y3]), unique([Z1, Z2, Z3]),

   X1 = plane, Y1 = car,
   Y2 = plane.
false
  • 10,264
  • 13
  • 101
  • 209
Zakhar
  • 9
  • *Undefined procedure unique/1* means you haven't defined the `unique` predicate anywhere with one argument. – lurker Nov 27 '14 at 17:09

1 Answers1

2

Probably unique/1 is all different:

unique([]).
unique([E|Es]) :-
   maplist(dif(E), Es),
   unique(Es).
false
  • 10,264
  • 13
  • 101
  • 209