|
From: <jom...@us...> - 2009-03-15 09:49:31
|
Revision: 1468
http://jason.svn.sourceforge.net/jason/?rev=1468&view=rev
Author: jomifred
Date: 2009-03-15 09:49:16 +0000 (Sun, 15 Mar 2009)
Log Message:
-----------
fix a bug in centralised env (when the agent was killed)
-- see email of Herv?\195?\131?\194?\169 Lange
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/BugVarsAsGoal.java
trunk/doc/faq/faq.tex
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/Plan.java
trunk/src/jason/asSyntax/PlanBody.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/infra/centralised/CentralisedEnvironment.java
trunk/src/jason/infra/centralised/RunCentralisedMAS.java
Modified: trunk/applications/as-unit-test/src/jason/tests/BugVarsAsGoal.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/BugVarsAsGoal.java 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/applications/as-unit-test/src/jason/tests/BugVarsAsGoal.java 2009-03-15 09:49:16 UTC (rev 1468)
@@ -17,8 +17,8 @@
// defines the agent's AgentSpeak code
ag.parseAScode(
- "+!g <- +p(ggg); !gg. " +
- "+!gg : p(X) <- !!X. " +
+ "+!g <- +p(ggg); !gg; Y={!ggg}; Y. " +
+ "+!gg : p(X) <- +X; !!X. " +
"+!ggg[source(A)] <- jason.asunit.print(A). "
);
}
@@ -26,6 +26,7 @@
@Test
public void testGoal() {
ag.addGoal("g");
- ag.assertPrint("self", 10);
+ ag.assertPrint("self", 10);
+ ag.assertPrint("self", 10);
}
}
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/doc/faq/faq.tex 2009-03-15 09:49:16 UTC (rev 1468)
@@ -954,7 +954,7 @@
The internal actions defined by the user can add new annotations to
indicate particular types of errors (see the API documentation of
- \htlink{JasonException}{http://jason.sourceforge.net/api/classjason_1_1JasonException.html}
+ \htlink{JasonException}{http://jason.sourceforge.net/api/jason/JasonException.html}
for more information about that).
\end{description}
@@ -1004,6 +1004,16 @@
\htlink{here}{http://jasonplugin.wikidot.com/} for more information,
including installation instructions.
+A command line option is also available. To compile a project:
+\begin{verbatim}
+<jason installation path>/bin/mas2j.sh <your project.mas2j>
+\end{verbatim}
+an Ant script is created in the \texttt{bin} directory. To run:
+\begin{verbatim}
+ant -f bin/build.xml
+\end{verbatim}
+
+
\subsection{How to create an Eclipse project for \jason?}
This might be useful if you are planning to contribute code for Jason
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2009-03-15 09:49:16 UTC (rev 1468)
@@ -427,7 +427,7 @@
}
Unifier u = im.unif;
PlanBody h = im.getCurrentStep();
- h.apply(u);
+ h.applyHead(u);
Literal body = null;
Term bTerm = h.getBodyTerm();
@@ -540,14 +540,13 @@
case delAddBel:
// -+a(1,X) ===> remove a(_,_), add a(1,X)
// change all vars to anon vars to remove it
- body = addSelfSource(body);
- Literal bc = (Literal)body.clone();
- bc.makeTermsAnnon();
+ body = addSelfSource(body.copy());
+ body.makeTermsAnnon();
// to delete, create events as external to avoid that
// remove/add create two events for the same intention
try {
- List<Literal>[] result = ag.brf(null, bc, conf.C.SI); // the intention is not the new focus
+ List<Literal>[] result = ag.brf(null, body, conf.C.SI); // the intention is not the new focus
if (result != null) { // really delete something
// generate events
updateEvents(result,Intention.EmptyInt);
Modified: trunk/src/jason/asSyntax/Plan.java
===================================================================
--- trunk/src/jason/asSyntax/Plan.java 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/src/jason/asSyntax/Plan.java 2009-03-15 09:49:16 UTC (rev 1468)
@@ -102,16 +102,6 @@
}
}
- @Override
- public boolean apply(Unifier u) {
- boolean r = false;
- // if I am a term, the body also is (for apply)
- if (isTerm) body.setAsBodyTerm(true);
- r = super.apply(u);
- if (isTerm) body.setAsBodyTerm(false);
- return r;
- }
-
public void setLabel(Pred p) {
label = p;
if (p != null && p.hasAnnot()) {
Modified: trunk/src/jason/asSyntax/PlanBody.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBody.java 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/src/jason/asSyntax/PlanBody.java 2009-03-15 09:49:16 UTC (rev 1468)
@@ -1,5 +1,7 @@
package jason.asSyntax;
+import jason.asSemantics.Unifier;
+
/**
* Interface for elements of a plans's body.
*
@@ -27,6 +29,9 @@
public boolean isEmptyBody();
public int getPlanSize();
+ /** apply unifier only on first element of the body */
+ public boolean applyHead(Unifier u);
+
public void setBodyType(BodyType bt);
public void setBodyTerm(Term t);
public void setBodyNext(PlanBody bl);
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2009-03-15 09:49:16 UTC (rev 1468)
@@ -144,18 +144,8 @@
if (i == 0) term = t;
if (i == 1) System.out.println("Should not setTerm(1) of body literal!");
}
-
- @Override
- public boolean apply(Unifier u) {
- // do not apply in next! (except in case this is a term)
- boolean ok = false;
-
- if (next != null && isTerm) {
- //next.setAsBodyTerm(true); // to force apply in next
- ok = next.apply(u);
- //next.setAsBodyTerm(false);
- }
-
+
+ public boolean applyHead(Unifier u) {
if (term != null && term.apply(u)) {
if (term.isPlanBody()) { // we cannot have "inner" body literals
PlanBody baknext = next;
@@ -163,14 +153,21 @@
next = ((PlanBody)term).getBodyNext();
term = ((PlanBody)term).getBodyTerm();
if (baknext != null) {
- //baknext.setAsBodyTerm(true); // to force apply in next
baknext.apply(u);
- //baknext.setAsBodyTerm(false);
getLastBody().add(baknext);
}
}
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean apply(Unifier u) {
+ boolean ok = next != null && next.apply(u);
+
+ if (applyHead(u))
ok = true;
- }
if (ok)
resetHashCodeCache();
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/src/jason/asSyntax/VarTerm.java 2009-03-15 09:49:16 UTC (rev 1468)
@@ -955,6 +955,13 @@
return null;
}
+ public boolean applyHead(Unifier u) {
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).applyHead(u);
+ else
+ return true;
+ }
+
public boolean isEmptyBody() {
if (value != null && getValue() instanceof PlanBody)
return ((PlanBody) getValue()).isEmptyBody();
Modified: trunk/src/jason/infra/centralised/CentralisedEnvironment.java
===================================================================
--- trunk/src/jason/infra/centralised/CentralisedEnvironment.java 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/src/jason/infra/centralised/CentralisedEnvironment.java 2009-03-15 09:49:16 UTC (rev 1468)
@@ -89,12 +89,10 @@
public void actionExecuted(String agName, Structure actTerm, boolean success, Object infraData) {
ActionExec action = (ActionExec)infraData;
- if (success) {
- action.setResult(true);
- } else {
- action.setResult(false);
- }
- masRunner.getAg(agName).actionExecuted(action);
+ action.setResult(success);
+ CentralisedAgArch ag = masRunner.getAg(agName);
+ if (ag != null)
+ ag.actionExecuted(action);
}
Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java
===================================================================
--- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2009-03-13 10:43:17 UTC (rev 1467)
+++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2009-03-15 09:49:16 UTC (rev 1468)
@@ -83,7 +83,7 @@
private CentralisedEnvironment env = null;
private CentralisedExecutionControl control = null;
private boolean debug = false;
- private Map<String,CentralisedAgArch> ags = new ConcurrentHashMap<String,CentralisedAgArch>();
+ private Map<String,CentralisedAgArch> ags = new ConcurrentHashMap<String,CentralisedAgArch>();
public JButton btDebug;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|