forked from daomingAU/MontezumaRevenge_SDRL
-
Notifications
You must be signed in to change notification settings - Fork 1
/
montezuma_basic.lp
54 lines (32 loc) · 1.16 KB
/
montezuma_basic.lp
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
36
37
38
39
40
41
42
43
44
45
#include <incmode>.
#const istop = "SAT".
#const imin = 1.
#const imax = 50.
#const maxgrid = 4.
#program base.
loc(lower_right_ladder).
loc(lower_left_ladder).
loc(key).
loc(right_door).
loc(plat1).
loc(devilleft).
at(plat1,1).
cost(0,1).
cost(0,0).
#program step(k).
{move(L,k)} :- loc(L), at(L1,k),L1!=L.
at(L,k) :- at(L1,k-1),move(L,k-1).
cost(C+50,k) :- move(L,k-1), at(L1,k-1), #count{Z:ro(at(L1),move(L),Z)}=0, not picked(key,k-1), cost(C,k-1).
cost(C+50,k) :- move(L,k-1), at(L1,k-1), #count{Z:ro((at(L1),picked(key)),move(L),Z)}=0, picked(key,k-1), cost(C,k-1).
cost(C+Z,k) :- move(L,k-1), at(L1,k-1), not picked(key,k-1), ro(at(L1),move(L),Z), cost(C,k-1).
cost(C+Z,k) :- move(L,k-1), at(L1,k-1), picked(key,k-1), ro((at(L1),picked(key)),move(L),Z), cost(C,k-1).
picked(key,k) :- at(key,k).
:- picked(key,k),at(right_door,k),move(L,k).
:- at(lower_right_ladder,k),picked(key,k), move(devilleft,k).
:- at(devilleft,k),move(plat1,k).
:- at(plat1,k), not picked(key,k), move(right_door,k).
{at(L,k)} :- at(L,k-1).
cost(Q,k) :- cost(Q,k-1), not move(L,k-1):loc(L).
picked(key,k) :- picked(key,k-1).
:- #count{Q:cost(Q,k)}!=1.
:- #count{L:at(L,k)}!=1.