%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% parallelkono
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% metadata
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
role(red)
role(black)
base(cell(B,M,N,Mark)) :- board(B) & index(M) & index(N) & mark(Mark)
base(played(B)) :- board(B)
base(score(R,0)) :- role(R)
base(score(R,N)) :- role(R) & incr(M,N)
base(step(1))
base(step(N)) :- succ(M,N)
base(control(R)) :- role(R)
action(move(B,U,V,X,Y)) :- board(B) & doublet(U,V,X,Y)
action(jump(B,U,V,W,X,Y,Z)) :- board(B) & triplet(U,V,W,X,Y,Z)
action(tick)
board(a)
board(b)
mark(red)
mark(black)
mark(blank)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% init
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init(cell(a,1,1,black))
init(cell(a,1,2,black))
init(cell(a,1,3,black))
init(cell(a,1,4,black))
init(cell(a,2,1,black))
init(cell(a,2,2,black))
init(cell(a,2,3,black))
init(cell(a,2,4,black))
init(cell(a,3,1,red))
init(cell(a,3,2,red))
init(cell(a,3,3,red))
init(cell(a,3,4,red))
init(cell(a,4,1,red))
init(cell(a,4,2,red))
init(cell(a,4,3,red))
init(cell(a,4,4,red))
init(cell(b,1,1,black))
init(cell(b,1,2,black))
init(cell(b,1,3,black))
init(cell(b,1,4,black))
init(cell(b,2,1,black))
init(cell(b,2,2,black))
init(cell(b,2,3,black))
init(cell(b,2,4,black))
init(cell(b,3,1,red))
init(cell(b,3,2,red))
init(cell(b,3,3,red))
init(cell(b,3,4,red))
init(cell(b,4,1,red))
init(cell(b,4,2,red))
init(cell(b,4,3,red))
init(cell(b,4,4,red))
init(score(red,0))
init(score(black,0))
init(step(1))
init(control(red))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% legal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
legal(move(B,U,V,X,Y)) :-
control(R) & cell(B,U,V,R) & ~played(B) & doublet(U,V,X,Y) & cell(B,X,Y,blank)
legal(jump(B,U,V,W,X,Y,Z)) :-
control(red) & cell(B,U,V,red) & ~played(B) & triplet(U,V,W,X,Y,Z) & cell(B,W,X,red) & cell(B,Y,Z,black)
legal(jump(B,U,V,W,X,Y,Z)) :-
control(black) & cell(B,U,V,black) & ~played(B) & triplet(U,V,W,X,Y,Z) & cell(B,W,X,black) & cell(B,Y,Z,red)
legal(tick)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% operations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
move(B,U,V,X,Y) :: cell(B,U,V,R) ==> ~cell(B,U,V,R) & cell(B,U,V,blank)
move(B,U,V,X,Y) :: cell(B,U,V,R) ==> ~cell(B,X,Y,blank) & cell(B,X,Y,R)
move(B,U,V,X,Y) :: played(B)
jump(B,U,V,W,X,Y,Z) :: cell(B,U,V,R) ==> ~cell(B,U,V,R) & cell(B,U,V,blank)
jump(B,U,V,W,X,Y,Z) :: cell(B,U,V,R) & cell(B,Y,Z,S) ==> ~cell(B,Y,Z,S) & cell(B,Y,Z,R)
jump(a,U,V,W,X,Y,Z) :: control(red) & score(red,M) & incr(M,N) ==> ~score(red,M) & score(red,N)
jump(b,U,V,W,X,Y,Z) :: control(black) & score(black,M) & incr(M,N) ==> ~score(black,M) & score(black,N)
jump(B,U,V,W,X,Y,Z) :: played(B)
tick :: ~played(a) & ~played(b)
tick :: step(M) & succ(M,N) ==> ~step(M) & step(N)
tick :: control(black) ==> ~control(black) & control(red)
tick :: control(red) ==> ~control(red) & control(black)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% goal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
goal(R,N) :- score(R,N)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% terminal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
terminal :- step(30)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Views
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
doublet(U,V,X,Y) :- horizontal(U,V,X,Y)
doublet(U,V,X,Y) :- horizontal(X,Y,U,V)
doublet(U,V,X,Y) :- vertical(U,V,X,Y)
doublet(U,V,X,Y) :- vertical(X,Y,U,V)
triplet(U,V,W,X,Y,Z) :- horizontal(U,V,W,X) & horizontal(W,X,Y,Z)
triplet(U,V,W,X,Y,Z) :- horizontal(Y,Z,W,X) & horizontal(W,X,U,V)
triplet(U,V,W,X,Y,Z) :- vertical(U,V,W,X) & vertical(W,X,Y,Z)
triplet(U,V,W,X,Y,Z) :- vertical(Y,Z,W,X) & vertical(W,X,U,V)
horizontal(U,V,X,V) :- nextspot(U,X) & index(V)
vertical(U,V,U,Y) :- nextspot(V,Y) & index(U)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Facts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index(1)
index(2)
index(3)
index(4)
nextspot(1,2)
nextspot(2,3)
nextspot(3,4)
incr(0,12)
incr(12,25)
incr(25,37)
incr(37,50)
incr(50,62)
incr(62,75)
incr(75,87)
incr(87,100)
succ(1,2)
succ(2,3)
succ(3,4)
succ(4,5)
succ(5,6)
succ(6,7)
succ(7,8)
succ(8,9)
succ(9,10)
succ(10,11)
succ(11,12)
succ(12,13)
succ(13,14)
succ(14,15)
succ(15,16)
succ(16,17)
succ(17,18)
succ(18,19)
succ(19,20)
succ(20,21)
succ(21,22)
succ(22,23)
succ(23,24)
succ(24,25)
succ(25,26)
succ(26,27)
succ(27,28)
succ(28,29)
succ(29,30)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%