1#program base.
2dir(-1,0;1,0;0,-1;0,1).
3
4stop( DX, DY,X,   Y   ) :- barrier(X,Y,DX,DY).
5stop(-DX,-DY,X+DX,Y+DY) :- stop(DX,DY,X,Y).
6
7#external target(R,X,Y) : available_target(R,M,X,Y).
8#external pos(R,X,Y,0) : dim(X), dim(Y), robot(R).
9
10#program trans(t).
11
121 { move(R,DX,DY,t) : robot(R), dir(DX,DY) } 1.
13
14halt(DX,DY,X-DX,Y-DY,t) :- pos(_,X,Y,t-1), dir(DX,DY), dim(X-DX), dim(Y-DY), not stop(-DX,-DY,X,Y).
15
16goto(R,DX,DY,X,Y,t) :- pos(R,X,Y,t-1), dir(DX,DY).
17goto(R,DX,DY,X+DX,Y+DY,t) :- goto(R,DX,DY,X,Y,t), dim(X+DX), dim(Y+DY), not stop(DX,DY,X,Y), not halt(DX,DY,X,Y,t).
18
19pos(R,X,Y,t) :- move(R,DX,DY,t), goto(R,DX,DY,X,Y,t), not goto(R,DX,DY,X+DX,Y+DY,t).
20pos(R,X,Y,t) :- pos(R,X,Y,t-1), not move(R,_,_,t).
21
22:- move(R,DX,DY,t-1), not goon(t-1), not move(R,DX,DY,t).
23
24#program state(t).
25
26goon(t) :- target(R,X,Y), not pos(R,X,Y,t).
27#minimize{ 1,t : goon(t) }.
28
29#program check(t).
30
31#external horizon(t).
32
33:- goon(t), horizon(t).
34
35#show move/4.
36