-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel2
35 lines (29 loc) · 1.74 KB
/
level2
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
27
28
29
30
31
32
33
34
35
% Simple first level file
% (Maximize the cell of eat on a movement)
% Facts generated by software:
% enemy(I,J).
% computer(P,I,J).
% free(I,J).
% Guess
move(P, I, J) | notMove(P, I, J) :- canMove(P, I, J).
% Can move in one of four possible directions
canMove(P, I, J) :- canMoveInDirection1(P, I, J).
canMove(P, I, J) :- canMoveInDirection2(P, I, J).
canMove(P, I, J) :- canMoveInDirection3(P, I, J).
canMove(P, I, J) :- canMoveInDirection4(P, I, J).
canMoveInDirection1(P, I, J) :- computer(P, I1 , J1), free(I,J), I1=I+2, J1=J.
canMoveInDirection2(P, I, J) :- computer(P, I1 , J1), free(I,J), I1=I-2, J1=J.
canMoveInDirection3(P, I, J) :- computer(P, I1 , J1), free(I,J), I1=I, J1=J+2.
canMoveInDirection4(P, I, J) :- computer(P, I1 , J1), free(I,J), I1=I, J1=J-2.
canMoveInDirection4(P, I, J) :- computer(P, I1 , J1), free(I,J), I1=I, J1=J-3.
% The number of eatable enemies
nearEatableEnemyes(N,P,I,J) :- canMoveInDirection1(P,I,J), #count{I,J1 : enemy(I,J1), J1=J-1} = N.
nearEatableEnemyes(N,P,I,J) :- canMoveInDirection1(P,I,J), #count{I,J1 : enemy(I,J1), J1=J+1} = N.
nearEatableEnemyes(N,P,I,J) :- canMoveInDirection3(P,I,J), #count{I,J1 : enemy(I,J1), J1=J-1} = N.
nearEatableEnemyes(N,P,I,J) :- canMoveInDirection3(P,I,J), #count{I,J1 : enemy(I,J1), J1=J+1} = N.
nearEatableEnemyes(N,P,I,J) :- canMoveInDirection2(P,I,J), #count{I1,J : enemy(I1,J), I1=I-1} = N.
nearEatableEnemyes(N,P,I,J) :- canMoveInDirection2(P,I,J), #count{I1,J : enemy(I1,J), I1=I+1} = N.
nearEatableEnemyes(N,P,I,J) :- canMoveInDirection4(P,I,J), #count{I1,J : enemy(I1,J), I1=I-1} = N.
nearEatableEnemyes(N,P,I,J) :- canMoveInDirection4(P,I,J), #count{I1,J : enemy(I1,J), I1=I+1} = N.
% Mazimize near eatale enemies
:~ notMove(P,I,J), nearEatableEnemyes(N,P,I,J). [N@1,I,J]