role(black)
role(red)
base(location(X,Y,Pawn)) :- evensquare(X,Y) & owns(Pawn,Player)
base(capturecount(Player,0)) :- role(Player)
base(capturecount(Player,N)) :- role(Player) & countplus(M,N)
base(control(Player)) :- role(Player)
base(step(1))
base(step(N)) :- pp(M,N)
input(Player,noop) :- role(Player)
input(red,move(X1,Y1,X2,Y2)) :- evensquare(X1,Y1) & redpawnmove(X1,Y1,X2,Y2)
input(black,move(X1,Y1,X2,Y2)) :- evensquare(X1,Y1) & blackpawnmove(X1,Y1,X2,Y2)
input(red,jump(X1,Y1,X3,Y3)) :- evensquare(X1,Y1) & redpawnmove(X1,Y1,X2,Y2) & redpawnmove(X2,Y2,X3,Y3) & distinct(X1,X3)
input(black,jump(X1,Y1,X3,Y3)) :- evensquare(X1,Y1) & blackpawnmove(X1,Y1,X2,Y2) & blackpawnmove(X2,Y2,X3,Y3) & distinct(X1,X3)
init(location(1,1,blackpawn))
init(location(3,1,blackpawn))
init(location(5,1,blackpawn))
init(location(7,1,blackpawn))
init(location(2,2,blackpawn))
init(location(4,2,blackpawn))
init(location(6,2,blackpawn))
init(location(8,2,blackpawn))
init(location(1,3,blackpawn))
init(location(3,3,blackpawn))
init(location(5,3,blackpawn))
init(location(7,3,blackpawn))
init(location(2,6,redpawn))
init(location(4,6,redpawn))
init(location(6,6,redpawn))
init(location(8,6,redpawn))
init(location(1,7,redpawn))
init(location(3,7,redpawn))
init(location(5,7,redpawn))
init(location(7,7,redpawn))
init(location(2,8,redpawn))
init(location(4,8,redpawn))
init(location(6,8,redpawn))
init(location(8,8,redpawn))
init(capturecount(black,0))
init(capturecount(red,0))
init(control(black))
init(step(1))
legal(Player,move(X1,Y1,X2,Y2)) :- true(control(Player)) & ~hasjump(Player) & celloccupiedby(X1,Y1,Player) & validmove(X1,Y1,X2,Y2) & cellempty(X2,Y2)
legal(Player,jump(X1,Y1,X2,Y2)) :- true(control(Player)) & celloccupiedby(X1,Y1,Player) & validjump(X1,Y1,X2,Y2) & cellempty(X2,Y2)
legal(Player,noop) :- role(Player) & ~true(control(Player))
next(location(X2,Y2,Piece)) :- does(black,move(X1,Y1,X2,Y2)) & true(location(X1,Y1,Piece))
next(location(X2,Y2,Piece)) :- does(black,jump(X1,Y1,X2,Y2)) & true(location(X1,Y1,Piece))
next(location(X2,Y2,Piece)) :- does(red,move(X1,Y1,X2,Y2)) & true(location(X1,Y1,Piece))
next(location(X2,Y2,Piece)) :- does(red,jump(X1,Y1,X2,Y2)) & true(location(X1,Y1,Piece))
next(location(X,Y,Piece)) :- true(location(X,Y,Piece)) & does(Player,move(X1,Y1,X2,Y2)) & distinctcell(X,Y,X1,Y1) & distinctcell(X,Y,X2,Y2)
next(location(X,Y,Piece)) :- true(location(X,Y,Piece)) & does(Player,jump(X1,Y1,X2,Y2)) & distinctcell(X,Y,X1,Y1) & distinctcell(X,Y,X2,Y2) & ~cellbetween(X1,Y1,X2,Y2,X,Y)
next(capturecount(Player,Count)) :- true(capturecount(Player,Count)) & ~true(control(Player))
next(capturecount(Player,Count)) :- true(capturecount(Player,Count)) & does(Player,move(X1,Y1,X2,Y2))
next(capturecount(Player,Count2)) :- true(capturecount(Player,Count1)) & does(Player,jump(X1,Y1,X2,Y2)) & countplus(Count1,Count2)
next(control(black)) :- true(control(red))
next(control(red)) :- true(control(black))
next(step(Tnext)) :- true(step(Tcurrent)) & pp(Tcurrent,Tnext)
goal(Player,Goal) :- true(capturecount(Player,Count)) & scoremap(Count,Goal)
terminal :- role(Player) & ~haspiece(Player)
terminal :- true(control(Player)) & ~hasmove(Player) & ~hasjump(Player)
terminal :- true(step(60))
validmove(X1,Y1,X2,Y2) :- true(location(X1,Y1,blackpawn)) & blackpawnmove(X1,Y1,X2,Y2)
validmove(X1,Y1,X2,Y2) :- true(location(X1,Y1,redpawn)) & redpawnmove(X1,Y1,X2,Y2)
validjump(X1,Y1,X2,Y2) :- true(location(X1,Y1,blackpawn)) & blackpawnjump(X1,Y1,X2,Y2)
validjump(X1,Y1,X2,Y2) :- true(location(X1,Y1,redpawn)) & redpawnjump(X1,Y1,X2,Y2)
blackpawnmove(X1,Y1,X2,Y2) :- plusx(1,X1,X2) & plusy(1,Y1,Y2)
blackpawnmove(X1,Y1,X2,Y2) :- plusx(1,X2,X1) & plusy(1,Y1,Y2)
redpawnmove(X1,Y1,X2,Y2) :- plusx(1,X1,X2) & plusy(1,Y2,Y1)
redpawnmove(X1,Y1,X2,Y2) :- plusx(1,X2,X1) & plusy(1,Y2,Y1)
blackpawnjump(X1,Y1,X3,Y3) :- plusx(1,X1,X2) & plusx(1,X2,X3) & plusy(1,Y1,Y2) & plusy(1,Y2,Y3) & celloccupiedby(X2,Y2,red)
blackpawnjump(X1,Y1,X3,Y3) :- plusx(1,X3,X2) & plusx(1,X2,X1) & plusy(1,Y1,Y2) & plusy(1,Y2,Y3) & celloccupiedby(X2,Y2,red)
redpawnjump(X1,Y1,X3,Y3) :- plusx(1,X1,X2) & plusx(1,X2,X3) & plusy(1,Y3,Y2) & plusy(1,Y2,Y1) & celloccupiedby(X2,Y2,black)
redpawnjump(X1,Y1,X3,Y3) :- plusx(1,X3,X2) & plusx(1,X2,X1) & plusy(1,Y3,Y2) & plusy(1,Y2,Y1) & celloccupiedby(X2,Y2,black)
haspiece(Player) :- true(location(X,Y,Piece)) & owns(Piece,Player)
hasjump(Player) :- celloccupiedby(X1,Y1,Player) & validjump(X1,Y1,X2,Y2) & cellempty(X2,Y2)
hasmove(Player) :- celloccupiedby(X1,Y1,Player) & validmove(X1,Y1,X2,Y2) & cellempty(X2,Y2)
distinctcell(X1,Y1,X2,Y2) :- cell(X1,Y1) & cell(X2,Y2) & distinct(X1,X2)
distinctcell(X1,Y1,X2,Y2) :- cell(X1,Y1) & cell(X2,Y2) & distinct(Y1,Y2)
cellbetween(X1,Y1,X3,Y3,X2,Y2) :- between(X1,X2,X3) & between(Y1,Y2,Y3)
celloccupiedby(X,Y,Player) :- true(location(X,Y,Piece)) & owns(Piece,Player)
cellempty(X,Y) :- cell(X,Y) & ~celloccupiedby(X,Y,black) & ~celloccupiedby(X,Y,red)
cell(X,Y) :- index(X) & index(Y)
index(1)
index(2)
index(3)
index(4)
index(5)
index(6)
index(7)
index(8)
plusx(1,1,2)
plusx(1,2,3)
plusx(1,3,4)
plusx(1,4,5)
plusx(1,5,6)
plusx(1,6,7)
plusx(1,7,8)
plusy(1,1,2)
plusy(1,2,3)
plusy(1,3,4)
plusy(1,4,5)
plusy(1,5,6)
plusy(1,6,7)
plusy(1,7,8)
plusy(1,8,1)
between(1,2,3)
between(2,3,4)
between(3,4,5)
between(4,5,6)
between(5,6,7)
between(6,7,8)
between(7,8,1)
between(8,1,2)
between(3,2,1)
between(4,3,2)
between(5,4,3)
between(6,5,4)
between(7,6,5)
between(8,7,6)
between(1,8,7)
between(2,1,8)
countplus(0,1)
countplus(1,2)
countplus(2,3)
countplus(3,4)
countplus(4,5)
countplus(5,6)
countplus(6,7)
countplus(7,8)
countplus(8,9)
countplus(9,10)
countplus(10,11)
countplus(11,12)
pp(1,2)
pp(2,3)
pp(3,4)
pp(4,5)
pp(5,6)
pp(6,7)
pp(7,8)
pp(8,9)
pp(9,10)
pp(10,11)
pp(11,12)
pp(12,13)
pp(13,14)
pp(14,15)
pp(15,16)
pp(16,17)
pp(17,18)
pp(18,19)
pp(19,20)
pp(20,21)
pp(21,22)
pp(22,23)
pp(23,24)
pp(24,25)
pp(25,26)
pp(26,27)
pp(27,28)
pp(28,29)
pp(29,30)
pp(30,31)
pp(31,32)
pp(32,33)
pp(33,34)
pp(34,35)
pp(35,36)
pp(36,37)
pp(37,38)
pp(38,39)
pp(39,40)
pp(40,41)
pp(41,42)
pp(42,43)
pp(43,44)
pp(44,45)
pp(45,46)
pp(46,47)
pp(47,48)
pp(48,49)
pp(49,50)
pp(50,51)
pp(51,52)
pp(52,53)
pp(53,54)
pp(54,55)
pp(55,56)
pp(56,57)
pp(57,58)
pp(58,59)
pp(59,60)
pp(60,61)
pp(61,62)
pp(62,63)
pp(63,64)
pp(64,65)
pp(65,66)
pp(66,67)
pp(67,68)
pp(68,69)
pp(69,70)
pp(70,71)
pp(71,72)
pp(72,73)
pp(73,74)
pp(74,75)
pp(75,76)
pp(76,77)
pp(77,78)
pp(78,79)
pp(79,80)
pp(80,81)
pp(81,82)
pp(82,83)
pp(83,84)
pp(84,85)
pp(85,86)
pp(86,87)
pp(87,88)
pp(88,89)
pp(89,90)
pp(90,91)
pp(91,92)
pp(92,93)
pp(93,94)
pp(94,95)
pp(95,96)
pp(96,97)
pp(97,98)
pp(98,99)
pp(99,100)
scoremap(0,0)
scoremap(1,8)
scoremap(2,16)
scoremap(3,24)
scoremap(4,32)
scoremap(5,40)
scoremap(6,48)
scoremap(7,56)
scoremap(8,64)
scoremap(9,72)
scoremap(10,80)
scoremap(11,90)
scoremap(12,100)
owns(blackpawn,black)
owns(redpawn,red)
odd(1)
even(2)
odd(3)
even(4)
odd(5)
even(6)
odd(7)
even(8)
evensquare(X,Y) :- odd(X) & odd(Y)
evensquare(X,Y) :- even(X) & even(Y)
