Blame view

code/asp/tohE.lp 645 Bytes
808facfe   Francisco Coelho   Main text adapted...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
%   generating

% Only one move per "move"
% Also, restrict the "Disk" and "Peg" 
1 { move(D, P, T) : disk(D) , peg(P) } 1 :- T = 1 .. moves.

%   defining
move(D, T) :- move(D, _, T).

on(D, P, 0) :- init_on(D, P).
on(D, P, T) :- move(D, P, T).
on(D, P, T + 1) :- on(D, P, T), not move(D, T + 1), T < moves.

blocked(D - 1, P, T + 1) :- on(D, P, T), T < moves.
blocked(D - 1, P, T) :- blocked(D, P, T), disk(D).

%   testing
:- move(D, P, T), blocked(D - 1, P, T).
:- move(D, T), on(D, P, T - 1), blocked(D, P, T).
:- not 1 { on(D, P, T) } 1, disk(D), T = 1..moves.

:- goal_on(D, P), not on(D, P, moves).

%   displaying
% #hide
#show move/3.