update
authorMart Lubbers <mart@martlubbers.net>
Wed, 12 Nov 2014 08:48:04 +0000 (09:48 +0100)
committerMart Lubbers <mart@martlubbers.net>
Wed, 12 Nov 2014 08:48:04 +0000 (09:48 +0100)
report/ass1.tex
report/report.tex
report/src/domaintask6.pl [new file with mode: 0644]
report/src/instancetask6.pl [new file with mode: 0644]

index 7826f14..4fb5b57 100644 (file)
@@ -1,3 +1,4 @@
+\newpage
 \subsection{Part 1: Modelling Sokoban}
 \subsubsection{Task 1: Knowledge base}
 \begin{itemize}
                                        agent(x, s))\\
                                        crate(x, y, result(A, s)) & \rightarrow\\
                                & (\exists z,\alpha:
-                                       A = push(z, \alpha),
-                                       (\exists \beta:
-                                               connected(z, \beta, \alpha),
-                                               connected(\beta, y, \alpha),
-                                               crate(x, \beta, s)
+                                       A = push(z\wedge \alpha)\wedge\\
+                               &       (\exists \beta:
+                                               connected(z\wedge \beta\wedge \alpha)\wedge
+                                               connected(\beta\wedge y\wedge \alpha)\wedge
+                                               crate(x\wedge \beta\wedge s)
                                        )
                                ) \vee\\
                                & (\exists z,\alpha:
                \end{array}$
 \end{itemize}
 
+\newpage
 \subsection{Part 2: Implementation}
 \subsubsection{Task 3: Translate Axioms}
 The only optimization added to the file is the reverse move optimization,
@@ -128,7 +130,16 @@ disallowing the agent to reverse a move immediatly.
 \end{listing}
 
 \subsubsection{Task 6: Inverse Problem}
+\begin{listing}[H]
+       \caption{Instance description task 6}
+       \prologcode{./src/instancetask6.pl}
+\end{listing}
+\begin{listing}[H]
+       \caption{Domain description task 6}
+       \prologcode{./src/domaintask6.pl}
+\end{listing}
 
+\newpage
 \subsection{Part 3: Extending the domain}
 \subsubsection{Task 7: Unlocking the Crates}
 \begin{listing}[H]
@@ -140,6 +151,7 @@ disallowing the agent to reverse a move immediatly.
        \prologcode{./src/domaintask7.pl}
 \end{listing}
 
+\newpage
 \subsection{Part 4: General questions}
 \subsubsection{Task 10: Sitcalc expressivity}
 Situation calculus(sitcalc from now on) is very expressive because you can
index 6324f25..de50b2a 100644 (file)
 \newmintedfile[prologcode]{prolog}{
        bgcolor=mintedbackground,
        fontfamily=tt,
-       linenos=true,
-       numberblanklines=true,
-       numbersep=10pt,
-       numbersep=5pt,
-       gobble=0,
+       fontsize=\scriptsize,
        frame=leftline,
        framerule=0.4pt,
        framesep=2mm,
        funcnamehighlighting=true,
-       tabsize=4,
-       obeytabs=false,
+       gobble=0,
+       linenos=true,
        mathescape=false
+       numberblanklines=true,
+       numbersep=10pt,
+       numbersep=5pt,
+       obeytabs=false,
        showspaces=false,
        showtabs =false,
+       tabsize=4,
        texcl=false,
 }
 
diff --git a/report/src/domaintask6.pl b/report/src/domaintask6.pl
new file mode 100644 (file)
index 0000000..6b0164b
--- /dev/null
@@ -0,0 +1,41 @@
+% ------------------------- Domain Definition -------------------------
+% --- Cross-file definitions ------------------------------------------
+:- multifile connected/3, crate/3, agent/2, visited/2.
+
+% --- Primitive control actions ---------------------------------------
+primitive_action(move(_, _)).
+primitive_action(push(_, _)).
+
+% --- Precondition for primitive actions ------------------------------
+poss(move(From, To), S) :-
+       agent(From, S),
+       connected(From, To, _),
+       not(crate(_, To, S)).
+
+poss(push(From, Direction), S) :-
+       agent(From, S),
+       connected(From, CrateLocation, Direction),
+       crate(_, CrateLocation, S),
+       connected(CrateLocation, CrateTarget, Direction),
+       not(crate(_, CrateTarget, S)).
+
+% --- Successor state axioms ------------------------------------------
+visited(Plek, result(A, S)) :-
+       A = move(Plek, _);
+       visited(Plek, S).
+
+agent(AgentPlek, result(A, S)) :-
+       A = move(_, AgentPlek);
+       A = push(OudeAgentPlek, Richting),
+               connected(OudeAgentPlek, AgentPlek, Richting);
+       not(A = move(AgentPlek, _)), not(A = push(AgentPlek, _)),
+               agent(AgentPlek, S).
+       
+crate(Krat, Kratplek, result(A, S)) :-
+       A = push(AgentPlek, Richting), 
+               connected(AgentPlek, OudeKratPlek, Richting),
+               connected(OudeKratPlek, Kratplek, Richting),
+               crate(Krat, OudeKratPlek, S);
+       not(A = push(AgentPlek2, Richting2)),
+               connected(AgentPlek2, Kratplek, Richting2),
+               crate(Krat, Kratplek, S).
diff --git a/report/src/instancetask6.pl b/report/src/instancetask6.pl
new file mode 100644 (file)
index 0000000..713d81d
--- /dev/null
@@ -0,0 +1,56 @@
+% ------------------------- Problem Instance --------------------------
+% --- Load domain definitions from an external file -------------------
+:- [domaintask6].
+
+% --- Definition of the initial state ---------------------------------
+% north and east
+connected(loc11, loc21, east).
+connected(loc11, loc12, north).
+connected(loc12, loc22, east).
+connected(loc12, loc13, north).
+connected(loc13, loc23, east).
+connected(loc13, loc14, north).
+connected(loc14, loc24, east).
+
+connected(loc21, loc31, east).
+connected(loc21, loc22, north).
+connected(loc22, loc32, east).
+connected(loc22, loc23, north).
+connected(loc23, loc33, east).
+connected(loc23, loc24, north).
+
+connected(loc31, loc32, north).
+connected(loc32, loc33, north).
+
+% The other way around, west and south
+connected(loc21, loc11, west).
+connected(loc12, loc11, south).
+connected(loc22, loc12, west).
+connected(loc13, loc12, south).
+connected(loc23, loc13, west).
+connected(loc14, loc13, south).
+connected(loc24, loc14, west).
+
+connected(loc31, loc21, west).
+connected(loc22, loc21, south).
+connected(loc32, loc22, west).
+connected(loc23, loc22, south).
+connected(loc33, loc23, west).
+connected(loc24, loc23, south).
+
+connected(loc32, loc31, south).
+connected(loc33, loc32, south).
+
+crate(cratec, loc21, s0).
+crate(crateb, loc22, s0).
+crate(cratea, loc23, s0).
+
+target(cratea, loc12).
+target(crateb, loc13).
+target(cratec, loc11).
+
+agent(loc32, s0).
+visited(loc32, s0).
+
+% --- Goal condition that the planner will try to reach ---------------
+goal(S) :- forall(connected(Start, _, _), visited(Start, S)).