|
From: <jom...@us...> - 2009-03-17 22:19:19
|
Revision: 1472
http://jason.svn.sourceforge.net/jason/?rev=1472&view=rev
Author: jomifred
Date: 2009-03-17 22:19:02 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
use plan body term for internal action .current_intention
Modified Paths:
--------------
trunk/demos/failure/a.asl
trunk/doc/faq/faq.tex
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/ASSyntax.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/stdlib/current_intention.java
Modified: trunk/demos/failure/a.asl
===================================================================
--- trunk/demos/failure/a.asl 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/demos/failure/a.asl 2009-03-17 22:19:02 UTC (rev 1472)
@@ -12,10 +12,10 @@
.print("current intention is: ",I);
I = intention(Id,IntendedMeans);
.println;
- .println("* Intention ",Id, " IM stack:");
+ .println("* Intention #",Id, ", IM stack:");
!print_im(IntendedMeans).
+!print_im([]).
-+!print_im([im(_Planlabel,Body)|R])
++!print_im([im(_PlanLabel,Body)|R])
<- .println("* ",Body);
!print_im(R).
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/doc/faq/faq.tex 2009-03-17 22:19:02 UTC (rev 1472)
@@ -887,19 +887,19 @@
\begin{verbatim}
intention(1,
[
- im("l__6[source(self)]",[".current_intention(I)", .....]),
- im("l__5[source(self)]",[".fail"]),
- im("l__4[source(self)]",["!g5(X)[source(self)]",".print(endg4)"]),
- im("l__3[source(self)]",["!g4(X)[source(self)]",".print(endg3)"]),
- im("l__2[source(self)]",["!g3(X)[source(self)]",".print(endg2)"]),
- im("l__1[source(self)]",["!g2(X)[source(self)]",".print(endg1)"]),
- im("l__0[source(self)]",["!g1(X)[source(self)]",".print("End, X=",X)"])
+ im(l__6[source(self)],{ .current_intention(I); ..... }),
+ im(l__5[source(self)],{ .fail"]),
+ im(l__4[source(self)],{ !g5(X)[source(self)]; .print(endg4) }),
+ im(l__3[source(self)],{ !g4(X)[source(self)]; .print(endg3) }),
+ im(l__2[source(self)],{ !g3(X)[source(self)]; .print(endg2) }),
+ im(l__1[source(self)],{ !g2(X)[source(self)]; .print(endg1) }),
+ im(l__0[source(self)],{ !g1(X)[source(self)]; .print("End, X=",X) })
]
)
\end{verbatim}
You can find more information in the documentation of the
- \htlink{current\_intention}{http://jason.sourceforge.net/api/classjason_1_1stdlib_1_1current__intention.html}
+ \htlink{current\_intention}{http://jason.sourceforge.net/api/jason/stdlib/current_intention.html}
pre-defined internal action.
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2009-03-17 22:19:02 UTC (rev 1472)
@@ -24,13 +24,10 @@
package jason.asSemantics;
-import jason.asSyntax.ListTerm;
-import jason.asSyntax.ListTermImpl;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Plan;
import jason.asSyntax.PlanBody;
import jason.asSyntax.PlanBodyImpl;
-import jason.asSyntax.StringTermImpl;
-import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
@@ -131,18 +128,15 @@
}
public Term getAsTerm() {
- Structure im = new Structure("im");
- im.addTerm(new StringTermImpl(plan.getLabel().toString()));
if (planBody instanceof PlanBodyImpl) {
- ListTerm lt = new ListTermImpl();
- for (PlanBody bd: (PlanBodyImpl)planBody) {
- PlanBody c = bd.clonePB();
- c.apply(unif);
- lt.add(new StringTermImpl(c.getBodyType().toString()+c.getBodyTerm()));
- }
- im.addTerm(lt);
+ //Plan p = new Plan((Pred)plan.getLabel().clone(), getTrigger().clone(), plan.getContext(), planBody.clonePB());
+ //p.makeVarsAnnon();
+ PlanBody bd = (PlanBody)((PlanBodyImpl)planBody.clone()).makeVarsAnnon();
+ bd.setAsBodyTerm(true);
+ return ASSyntax.createStructure("im", ASSyntax.createString(plan.getLabel()), bd);
+ } else {
+ return ASSyntax.createAtom("noimplementedforclass"+planBody.getClass().getSimpleName());
}
- return im;
}
/** get as XML */
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2009-03-17 22:19:02 UTC (rev 1472)
@@ -684,6 +684,7 @@
IntendedMeans topIM = i.pop();
Literal topLiteral = topIM.getTrigger().getLiteral();
if (logger.isLoggable(Level.FINE)) logger.fine("Returning from IM "+topIM.getPlan().getLabel()+", te="+topIM.getPlan().getTrigger());
+
// if finished a failure handling IM ...
if (im.getTrigger().isGoal() && !im.getTrigger().isAddition() && i.size() > 0) {
// needs to get rid of the IM until a goal that
@@ -911,7 +912,7 @@
// code
if (eventLiteral.getAnnots("code").isEmpty())
- eventLiteral.addAnnot(ASSyntax.createStructure("code", ASSyntax.createString(bodyterm.toString())));
+ eventLiteral.addAnnot(ASSyntax.createStructure("code", bodyterm.copy().makeVarsAnnon()));
// ASL source
if (eventLiteral.getAnnots("code_src").isEmpty())
Modified: trunk/src/jason/asSyntax/ASSyntax.java
===================================================================
--- trunk/src/jason/asSyntax/ASSyntax.java 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/src/jason/asSyntax/ASSyntax.java 2009-03-17 22:19:02 UTC (rev 1472)
@@ -100,6 +100,10 @@
public static StringTerm createString(String s) {
return new StringTermImpl(s);
}
+ /** creates a new string term using .toString() of the parameter */
+ public static StringTerm createString(Object o) {
+ return new StringTermImpl(o.toString());
+ }
/** creates a new variable term */
public static VarTerm createVar(String functor) {
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/src/jason/asSyntax/Literal.java 2009-03-17 22:19:02 UTC (rev 1472)
@@ -125,14 +125,14 @@
/** replaces all terms by unnamed variables (_). */
public void makeTermsAnnon() {}
/** replaces all variables by unnamed variables (_). */
- public void makeVarsAnnon() {}
+ public Literal makeVarsAnnon() { return this; }
/**
* replaces all variables of the term for unnamed variables (_).
*
* @param un is the unifier that contains the map of replacements
*/
- public void makeVarsAnnon(Unifier un) {}
+ public Literal makeVarsAnnon(Unifier un) { return this; }
/** returns all annotations of the literal */
public ListTerm getAnnots() { return null; }
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/src/jason/asSyntax/Pred.java 2009-03-17 22:19:02 UTC (rev 1472)
@@ -392,7 +392,7 @@
@Override
- public void makeVarsAnnon(Unifier un) {
+ public Literal makeVarsAnnon(Unifier un) {
if (annots != null) {
Iterator<ListTerm> i = annots.listTermIterator();
while (i.hasNext()) {
@@ -415,7 +415,7 @@
}
}
}
- super.makeVarsAnnon(un);
+ return super.makeVarsAnnon(un);
}
@Override
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/src/jason/asSyntax/Structure.java 2009-03-17 22:19:02 UTC (rev 1472)
@@ -271,12 +271,12 @@
}
@Override
- public void makeVarsAnnon() {
- makeVarsAnnon(new Unifier());
+ public Literal makeVarsAnnon() {
+ return makeVarsAnnon(new Unifier());
}
@Override
- public void makeVarsAnnon(Unifier un) {
+ public Literal makeVarsAnnon(Unifier un) {
final int size = getArity();
for (int i=0; i<size; i++) {
Term ti = getTerm(i);
@@ -299,6 +299,7 @@
}
}
resetHashCodeCache();
+ return this;
}
@Override
Modified: trunk/src/jason/stdlib/current_intention.java
===================================================================
--- trunk/src/jason/stdlib/current_intention.java 2009-03-17 17:00:23 UTC (rev 1471)
+++ trunk/src/jason/stdlib/current_intention.java 2009-03-17 22:19:02 UTC (rev 1472)
@@ -41,16 +41,16 @@
where each intended means has the form:<br><br>
- <code>im(<i>plan label</i>,<i>list of body literals</i>)</code><br><br>
+ <code>im(<i>plan label</i>,<i>plan body term</i>)</code><br><br>
For example:<br><br>
<blockquote>
<code>intention(1,<br>
[<br>
- im("l__6[source(self)]",[".current_intention(I)"]),<br>
- im("l__5[source(self)]",[".fail"]),<br>
- im("l__4[source(self)]",["!g5(X)",".print(endg4)"]),<br>
+ im(l__6[source(self)],{ .current_intention(I); .print(end) }),<br>
+ im(l__5[source(self)],{ .fail}),<br>
+ im(l__4[source(self)],{ !g5(X); .print(endg4) }),<br>
...<br>
])</code>
</blockquote>
@@ -65,7 +65,7 @@
<p>Example:<ul>
<li> <code>.current_intention(X)</code>: <code>X</code> unifies with the
- descriptions of the current intention (i.e. the intention that executed this
+ description of the current intention (i.e. the intention that executed this
internal action).</li>
</ul>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|