|
From: <jom...@us...> - 2008-04-18 16:10:18
|
Revision: 1221
http://jason.svn.sourceforge.net/jason/?rev=1221&view=rev
Author: jomifred
Date: 2008-04-18 09:10:08 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
fix bug in .wait
Modified Paths:
--------------
trunk/release-notes.txt
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSemantics/VarsCluster.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/stdlib/wait.java
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-04-17 21:52:42 UTC (rev 1220)
+++ trunk/release-notes.txt 2008-04-18 16:10:08 UTC (rev 1221)
@@ -11,6 +11,7 @@
. use nested source annotations in communication
. add "source(self)" in goals without source
. correctly handle failure event caused by no relevant plans
+. timeout in .wait does not cause a runtime exception
-------------
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-04-17 21:52:42 UTC (rev 1220)
+++ trunk/src/jason/asSemantics/Agent.java 2008-04-18 16:10:08 UTC (rev 1221)
@@ -252,10 +252,10 @@
try {
// check if the class has "create" method -- singleton implementation
Method create = iaclass.getMethod("create", (Class[])null);
- return (InternalAction)create.invoke(null, (Object[])null);
- } catch (Exception e) {}
-
- objIA = (InternalAction)iaclass.newInstance();
+ objIA = (InternalAction)create.invoke(null, (Object[])null);
+ } catch (Exception e) {
+ objIA = (InternalAction)iaclass.newInstance();
+ }
internalActions.put(iaName, objIA);
}
return objIA;
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-04-17 21:52:42 UTC (rev 1220)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-04-18 16:10:08 UTC (rev 1221)
@@ -90,6 +90,10 @@
return plan;
}
+ public void setUnif(Unifier unif) {
+ this.unif = unif;
+ }
+
public Unifier getUnif() {
return unif;
}
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-04-17 21:52:42 UTC (rev 1220)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-04-18 16:10:08 UTC (rev 1221)
@@ -41,7 +41,7 @@
private static Logger logger = Logger.getLogger(Unifier.class.getName());
- private HashMap<VarTerm, Term> function = new HashMap<VarTerm, Term>();
+ protected HashMap<VarTerm, Term> function = new HashMap<VarTerm, Term>();
/**
* @deprecated use t.apply(un) instead.
@@ -165,7 +165,7 @@
// ----- Unify for Terms
- private boolean unifyTerms(Term t1g, Term t2g) {
+ protected boolean unifyTerms(Term t1g, Term t2g) {
// if args are expressions, apply them and use their values
if (t1g.isArithExpr()) {
t1g = (Term) t1g.clone();
@@ -303,7 +303,7 @@
return true;
}
- private boolean setVarValue(VarTerm vt, Term value) {
+ protected boolean setVarValue(VarTerm vt, Term value) {
// if the var has a cluster, set value for all cluster
Term currentVl = function.get(vt);
if (currentVl != null && currentVl instanceof VarsCluster) {
Modified: trunk/src/jason/asSemantics/VarsCluster.java
===================================================================
--- trunk/src/jason/asSemantics/VarsCluster.java 2008-04-17 21:52:42 UTC (rev 1220)
+++ trunk/src/jason/asSemantics/VarsCluster.java 2008-04-18 16:10:08 UTC (rev 1221)
@@ -63,11 +63,11 @@
private Unifier u;
// used in clone
- private VarsCluster(Unifier u) {
+ protected VarsCluster(Unifier u) {
this.u = u;
}
- VarsCluster(VarTerm v1, VarTerm v2, Unifier u) {
+ protected VarsCluster(VarTerm v1, VarTerm v2, Unifier u) {
id = ++idCount;
this.u = u;
add(v1);
@@ -104,7 +104,7 @@
return false;
}
- boolean hasValue() {
+ public boolean hasValue() {
return vars != null && !vars.isEmpty();
}
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-04-17 21:52:42 UTC (rev 1220)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-04-18 16:10:08 UTC (rev 1221)
@@ -409,7 +409,7 @@
return new InternalActionLiteral(F, curAg);
} catch (Exception e) {
if (getArithFunction(F) == null) // it is not a registered function
- throw new ParseException(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");
+ logger.warning(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");
}
}
return new Literal(type,F);
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-04-17 21:52:42 UTC (rev 1220)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-04-18 16:10:08 UTC (rev 1221)
@@ -555,7 +555,7 @@
{if (true) return new InternalActionLiteral(F, curAg);}
} catch (Exception e) {
if (getArithFunction(F) == null) // it is not a registered function
- {if (true) throw new ParseException(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");}
+ logger.warning(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");
}
}
{if (true) return new Literal(type,F);}
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-04-17 21:52:42 UTC (rev 1220)
+++ trunk/src/jason/stdlib/wait.java 2008-04-18 16:10:08 UTC (rev 1221)
@@ -31,8 +31,9 @@
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Atom;
+import jason.asSyntax.InternalActionLiteral;
+import jason.asSyntax.NumberTerm;
import jason.asSyntax.PlanBodyImpl;
-import jason.asSyntax.NumberTerm;
import jason.asSyntax.StringTerm;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
@@ -176,7 +177,7 @@
si.peek().removeCurrentStep();
if (stopByTimeout && te != null) {
// fail the .wait
- si.peek().getPlan().getBody().add(0, new PlanBodyImpl(BodyType.internalAction, new Atom(".fail")));
+ si.peek().getPlan().getBody().add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
}
if (si.isSuspended()) { // if the intention was suspended by .suspend
String k = suspend.SUSPENDED_INT+si.getId();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-18 17:41:27
|
Revision: 1222
http://jason.svn.sourceforge.net/jason/?rev=1222&view=rev
Author: jomifred
Date: 2008-04-18 10:41:10 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
fix bug in return of ? and !
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/asunit/TestArch.java
trunk/applications/as-unit-test/src/jason/tests/TestAll.java
trunk/release-notes.txt
trunk/src/jason/asSemantics/VarsCluster.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
Added Paths:
-----------
trunk/applications/as-unit-test/src/jason/tests/BugListReturnUnification.java
Modified: trunk/applications/as-unit-test/src/jason/asunit/TestArch.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/asunit/TestArch.java 2008-04-18 16:10:08 UTC (rev 1221)
+++ trunk/applications/as-unit-test/src/jason/asunit/TestArch.java 2008-04-18 17:41:10 UTC (rev 1222)
@@ -93,7 +93,7 @@
}
public void print(String s) {
- //System.out.println(s);
+ System.out.println(s);
output.append(s+"\n");
}
Added: trunk/applications/as-unit-test/src/jason/tests/BugListReturnUnification.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/BugListReturnUnification.java (rev 0)
+++ trunk/applications/as-unit-test/src/jason/tests/BugListReturnUnification.java 2008-04-18 17:41:10 UTC (rev 1222)
@@ -0,0 +1,37 @@
+package jason.tests;
+
+import jason.asunit.TestAgent;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class BugListReturnUnification {
+
+ TestAgent ag;
+
+ @Before
+ public void setupAg() {
+ ag = new TestAgent();
+ ag.setDebugMode(true);
+
+ // defines the agent's AgentSpeak code
+ ag.parseAScode(
+ "+!test1 <- L=[A,B]; ?bundle(L); jason.asunit.print(L). "+
+ "+?bundle([]). "+
+ "+?bundle([a|T]) <- ?bundle(T). "+
+
+ "+!test2 <- L=[A,B,C,D]; !bundle(L); jason.asunit.print(L). "+
+ "+!bundle([]). "+
+ "+!bundle([a|T]) <- !bundle(T). "
+ );
+ }
+
+ @Test
+ public void testContext() {
+ ag.addGoal("test1");
+ ag.assertPrint("[a,a]", 10);
+ ag.addGoal("test2");
+ ag.assertPrint("[a,a,a,a]", 10);
+ }
+
+}
Modified: trunk/applications/as-unit-test/src/jason/tests/TestAll.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestAll.java 2008-04-18 16:10:08 UTC (rev 1221)
+++ trunk/applications/as-unit-test/src/jason/tests/TestAll.java 2008-04-18 17:41:10 UTC (rev 1222)
@@ -6,6 +6,7 @@
@RunWith(Suite.class)
@SuiteClasses({
+ BugListReturnUnification.class,
BugVarsInInitBels.class,
TestAddLogExprInBB.class,
TestGoalSource.class,
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-04-18 16:10:08 UTC (rev 1221)
+++ trunk/release-notes.txt 2008-04-18 17:41:10 UTC (rev 1222)
@@ -12,6 +12,7 @@
. add "source(self)" in goals without source
. correctly handle failure event caused by no relevant plans
. timeout in .wait does not cause a runtime exception
+. unification in return of ! and ?
-------------
Modified: trunk/src/jason/asSemantics/VarsCluster.java
===================================================================
--- trunk/src/jason/asSemantics/VarsCluster.java 2008-04-18 16:10:08 UTC (rev 1221)
+++ trunk/src/jason/asSemantics/VarsCluster.java 2008-04-18 17:41:10 UTC (rev 1222)
@@ -67,7 +67,7 @@
this.u = u;
}
- protected VarsCluster(VarTerm v1, VarTerm v2, Unifier u) {
+ public VarsCluster(VarTerm v1, VarTerm v2, Unifier u) {
id = ++idCount;
this.u = u;
add(v1);
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-04-18 16:10:08 UTC (rev 1221)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-04-18 17:41:10 UTC (rev 1222)
@@ -184,15 +184,14 @@
public Term removeBody(int index) {
if (index == 0) {
+ Term oldvalue = term;
if (next == null) {
term = null; // becomes an empty
} else {
- Term oldvalue = term;
swap(next); // get values of text
next = next.getBodyNext();
- return oldvalue;
}
- return this;
+ return oldvalue;
} else {
return next.removeBody(index - 1);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-20 20:25:45
|
Revision: 1234
http://jason.svn.sourceforge.net/jason/?rev=1234&view=rev
Author: jomifred
Date: 2008-04-20 13:25:43 -0700 (Sun, 20 Apr 2008)
Log Message:
-----------
jason-team: add basic formation for dummies
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/todo.org
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/Plan.java
trunk/src/jason/asSyntax/Trigger.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/environment/grid/GridWorldView.java
trunk/src/jason/stdlib/create_agent.java
trunk/src/jason/stdlib/desire.java
trunk/src/jason/stdlib/drop_desire.java
trunk/src/jason/stdlib/succeed_goal.java
trunk/src/test/TermTest.java
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-04-20 20:25:43 UTC (rev 1234)
@@ -28,16 +28,7 @@
jia.random(RY,40,5) & RY > 5 & Y = (RY-20)+AgY &
not jia.obstacle(X,Y).
-// whether some location X,Y has an agent and I am near that location
-/*
-agent_in_target :-
- pos(AgX,AgY,_) &
- target(TX,TY) &
- (cell(TX,TY,ally(_)) | cell(TX,TY,enemy(_)) | cell(TX,TY,cow(_))) &
- jia.dist(TX,TY,AgX,AgY,D) &
- D <= 2. // this number should be the same used by A* (DIST_FOR_AG_OBSTACLE constant)
-*/
-
+
/* -- initial goal */
!decide_target.
@@ -65,8 +56,7 @@
!decide_target.
+!decide_target
- : jia.herd_position(six,X,Y) //& // compute new location
- //(not target(_,_) | (target(TX,TY) & (TX \== X | TY \== Y))) // no target OR new target
+ : jia.herd_position(six,X,Y)
<- .print("COWS! going to ",X,",",Y); //," previous target ",TX,",",TY);
-+goal(herd);
-+target(X,Y).
@@ -78,11 +68,7 @@
-+goal(search);
-+target(NX,NY).
-//+!decide_target
-// <- .print("No need for a new target, consider last herding location.");
-// do(skip). // send an action so that the simulator does not wait for me.
-
/* -- plans to move to a destination represented in the belief target(X,Y)
-- (it is a kind of persistent goal)
*/
@@ -120,17 +106,6 @@
<- do(D); // this action will "block" the intention until it is sent to the simulator (in the end of the cycle)
!!move. // continue moving
-// find a new destination
-/*+!move
- : pos(X,Y,_) &
- (not target(_,_) | // I have no target OR
- target(X,Y) | // I am at target OR
- jia_obstacle(X,Y) | // An obstacle was discovered in the target
- agent_in_target | // there is an agent in the target
- (target(BX,BY) & jia.direction(X, Y, BX, BY, skip))) // is impossible to go to target
- <- !decide_target.
-*/
-
// in case of failure, move
-!move
<- .current_intention(I); .println("failure in move, intention: ",I);
@@ -144,6 +119,7 @@
/* -- tests -- */
+
+gsize(Weight,Height) <- .println("gsize = ",Weight,",",Height).
+steps(MaxSteps) <- .println("steps = ",MaxSteps).
+corral(X1,Y1,X2,Y2) <- .println("corral = ",X1,",",Y1," -- ",X2,",",Y2).
Modified: trunk/applications/jason-team/todo.org
===================================================================
--- trunk/applications/jason-team/todo.org 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/applications/jason-team/todo.org 2008-04-20 20:25:43 UTC (rev 1234)
@@ -1,8 +1,10 @@
* faster simulator
-* develop a team of dummies to play against
+* DONE develop a team of dummies to play against
+ CLOSED: [2008-04-20 Sun 22:23]
** what is a dummy strategy?
* base components
-** Vectors (operations)
+** DONE Vectors (operations)
+ CLOSED: [2008-04-20 Sun 22:23]
* new scenarios
* team formations (moise+ representation of the team)
** Structure (we have something from the proposal)
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/asSemantics/Agent.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -647,7 +647,7 @@
if (!inBB.isRule()) {
// need to clone unifier since it is changed in previous iteration
Unifier unC = (un == null ? new Unifier() : (Unifier)un.clone());
- if (unC.unifies(bel, inBB)) {
+ if (unC.unifiesNoUndo(bel, inBB)) {
toDel.add(inBB);
}
}
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -49,11 +49,13 @@
private Trigger trigger; // the trigger which created this IM
public IntendedMeans(Option opt, Trigger te) {
- plan = opt.getPlan().cloneBodyOnly();
+ plan = opt.getPlan().cloneOnlyBody();
unif = opt.getUnifier(); //(Unifier)opt.getUnifier().clone();
Literal planLiteral = plan.getTrigger().getLiteral();
if (planLiteral.hasAnnot()) {
planLiteral.getAnnots().apply(unif);
+ // TODO: why?
+ // if the plans.TE is not change, we do not need to clone it in plan.cloneBodyOnly
}
if (te == null) {
trigger = plan.getTrigger();
@@ -63,6 +65,9 @@
// add annots of the trigger into the plan's te
// so that the event +!g[source(ag1)] will add source(ag1)
// in the TE of the plan
+ // TODO: why? -- in the TS.applyClrInt -- end of the method, the unification could be g,tel and not tel,g!
+ // (the plan trigger will be used latter to "return" values
+ // see TS.applyClrInt -- end of the method)
planLiteral.addAnnots(trigger.getLiteral().getAnnots());
}
}
@@ -127,7 +132,7 @@
}
public String toString() {
- return plan + " : " + unif;
+ return plan + " / " + unif;
}
public Term getAsTerm() {
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -651,9 +651,13 @@
// removes !b or ?s
Term g = im.removeCurrentStep();
// make the TE of finished plan ground and unify that
- // with goal in the body
+ // with goal/test in the body (to "return" values).
+ // (it must the plan TE and not the IM.trigger because the
+ // vars have name only in the plan TE, in the IM.trigger
+ // they are anonymous)
Literal tel = topIM.getPlan().getTrigger().getLiteral();
tel.apply(topIM.unif);
+ // TODO: why not unifies(g,tel)?
im.unif.unifies(tel, g);
}
}
Modified: trunk/src/jason/asSyntax/Plan.java
===================================================================
--- trunk/src/jason/asSyntax/Plan.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/asSyntax/Plan.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -208,7 +208,8 @@
return p;
}
- public Plan cloneBodyOnly() {
+ /** used to create a plan clone in a new IM */
+ public Plan cloneOnlyBody() {
Plan p = new Plan();
if (label != null) {
p.label = label;
Modified: trunk/src/jason/asSyntax/Trigger.java
===================================================================
--- trunk/src/jason/asSyntax/Trigger.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/asSyntax/Trigger.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -32,6 +32,7 @@
* a type (<empty>, !, or ?);
* a literal
*/
+import jason.asSemantics.Unifier;
import jason.asSyntax.parser.ParseException;
import jason.asSyntax.parser.as2j;
@@ -136,6 +137,10 @@
}
return piCache;
}
+
+ public boolean apply(Unifier u) {
+ return literal.apply(u);
+ }
public Literal getLiteral() {
return literal;
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-04-20 20:25:43 UTC (rev 1234)
@@ -409,7 +409,7 @@
return new InternalActionLiteral(F, curAg);
} catch (Exception e) {
if (getArithFunction(F) == null) // it is not a registered function
- logger.warning(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");
+ logger.warning(getSourceRef(F)+" warning: The internal action class for '"+F+"' was not found!");
}
}
return new Literal(type,F);
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -555,7 +555,7 @@
{if (true) return new InternalActionLiteral(F, curAg);}
} catch (Exception e) {
if (getArithFunction(F) == null) // it is not a registered function
- logger.warning(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");
+ logger.warning(getSourceRef(F)+" warning: The internal action class for '"+F+"' was not found!");
}
}
{if (true) return new Literal(type,F);}
Modified: trunk/src/jason/environment/grid/GridWorldView.java
===================================================================
--- trunk/src/jason/environment/grid/GridWorldView.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/environment/grid/GridWorldView.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -114,10 +114,7 @@
}
if ((model.data[x][y] & GridWorldModel.AGENT) != 0) {
- //int ag = ;
- //if (ag != -1) {
drawAgent(drawArea.getGraphics(), x, y, Color.blue, model.getAgAtPos(x, y));
- //}
}
}
Modified: trunk/src/jason/stdlib/create_agent.java
===================================================================
--- trunk/src/jason/stdlib/create_agent.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/stdlib/create_agent.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -57,24 +57,23 @@
from the source file in "/tmp/x.asl".</li>
<li>
- <code>.create_agent(bob,"x.asl", [agentClass(myp.MyAgent)])</code>:
+ <code>.create_agent(bob,"x.asl", [agentClass("myp.MyAgent")])</code>:
creates the agent with customised agent class
<code>myp.MyAgent</code>.</li>
- <code>.create_agent(bob,"x.asl", [agentArchClass(myp.MyArch)])</code>:
+ <code>.create_agent(bob,"x.asl", [agentArchClass("myp.MyArch")])</code>:
creates the agent with customised architecture class
<code>myp.MyArch</code>.</li>
- <code>.create_agent(bob,"x.asl", [beliefBaseClass(jason.bb.TextPersistentBB)])</code>:
+ <code>.create_agent(bob,"x.asl", [beliefBaseClass("jason.bb.TextPersistentBB")])</code>:
creates the agent with customised belief base
<code>jason.bb.TextPersistentBB</code>.</li>
- <code>.create_agent(bob,"x.asl", [agentClass(myp.MyAgent),
- agentArchClass(myp.MyArch),
- beliefBaseClass(jason.bb.TextPersistentBB)])</code>: creates the
+ <code>.create_agent(bob,"x.asl", [agentClass("myp.MyAgent"),
+ agentArchClass("myp.MyArch"),
+ beliefBaseClass("jason.bb.TextPersistentBB")])</code>: creates the
agent with agent, acrchitecture and belief base customised.</li>
-
</ul>
@see jason.stdlib.kill_agent
@@ -104,11 +103,11 @@
if (t.isStructure()) {
Structure s = (Structure)t;
if (s.getFunctor().equals("beliefBaseClass")) {
- bbPars = new ClassParameters((Structure)s.getTerm(0));
+ bbPars = new ClassParameters(testString(s.getTerm(0)));
} else if (s.getFunctor().equals("agentClass")) {
- agClass = s.getTerm(0).toString();
+ agClass = testString(s.getTerm(0)).toString();
} else if (s.getFunctor().equals("agentArchClass")) {
- agArchClass = s.getTerm(0).toString();
+ agArchClass = testString(s.getTerm(0)).toString();
}
}
}
@@ -124,4 +123,12 @@
throw new JasonException("Error in internal action 'create_agent': " + e, e);
}
}
+
+ private Structure testString(Term t) {
+ if (t.isStructure())
+ return (Structure)t;
+ if (t.isString())
+ return Structure.parse(((StringTerm)t).getString());
+ return null;
+ }
}
Modified: trunk/src/jason/stdlib/desire.java
===================================================================
--- trunk/src/jason/stdlib/desire.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/stdlib/desire.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -85,7 +85,7 @@
Intention i = C.getSelectedEvent().getIntention();
if (i != Intention.EmptyInt && i.size() > 0) {
t = (Trigger) t.clone();
- t.getLiteral().apply(i.peek().getUnif());
+ t.apply(i.peek().getUnif());
}
if (un.unifies(t, teFromL)) {
return true;
@@ -97,7 +97,7 @@
Intention i = ei.getIntention();
if (i != Intention.EmptyInt && i.size() > 0) {
t = (Trigger) t.clone();
- t.getLiteral().apply(i.peek().getUnif());
+ t.apply(i.peek().getUnif());
}
if (un.unifies(t, teFromL)) {
return true;
Modified: trunk/src/jason/stdlib/drop_desire.java
===================================================================
--- trunk/src/jason/stdlib/drop_desire.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/stdlib/drop_desire.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -92,7 +92,7 @@
Trigger t = ei.getTrigger();
if (ei.getIntention() != Intention.EmptyInt) {
t = (Trigger) t.clone();
- t.getLiteral().apply(ei.getIntention().peek().getUnif());
+ t.apply(ei.getIntention().peek().getUnif());
}
if (un.unifies(t, te)) {
// old implementation: t.setTrigType(Trigger.TEDel); // Just changing "+!g" to "-!g"
Modified: trunk/src/jason/stdlib/succeed_goal.java
===================================================================
--- trunk/src/jason/stdlib/succeed_goal.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/jason/stdlib/succeed_goal.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -108,7 +108,7 @@
Trigger t = e.getTrigger();
if (i != Intention.EmptyInt && i.size() > 0) {
t = (Trigger) t.clone();
- t.getLiteral().apply(i.peek().getUnif());
+ t.apply(i.peek().getUnif());
}
if (un.unifies(t, g)) {
dropInEvent(ts,e,i);
Modified: trunk/src/test/TermTest.java
===================================================================
--- trunk/src/test/TermTest.java 2008-04-20 20:16:53 UTC (rev 1233)
+++ trunk/src/test/TermTest.java 2008-04-20 20:25:43 UTC (rev 1234)
@@ -379,7 +379,7 @@
Unifier u = new Unifier();
assertTrue(u.unifies(t1,t2));
//System.out.println(u);
- t2.getLiteral().apply(u);
+ t2.apply(u);
//System.out.println("t2 with apply = "+t2);
assertEquals(t1.toString(), t2.toString());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-22 11:20:05
|
Revision: 1237
http://jason.svn.sourceforge.net/jason/?rev=1237&view=rev
Author: jomifred
Date: 2008-04-22 04:20:01 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
fix auto update
Modified Paths:
--------------
trunk/build.xml
trunk/release-notes.txt
trunk/src/jason/jeditplugin/CheckVersion.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-04-21 16:46:57 UTC (rev 1236)
+++ trunk/build.xml 2008-04-22 11:20:01 UTC (rev 1237)
@@ -229,6 +229,8 @@
</propertyfile>
<property file="${dist.properties}" />
+ <antcall target="plugin" />
+
<fixcrlf eol="crlf" includes="**/*.txt,**/*.bat" srcdir="${basedir}" />
<delete failonerror="no" includeEmptyDirs="true">
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-04-21 16:46:57 UTC (rev 1236)
+++ trunk/release-notes.txt 2008-04-22 11:20:01 UTC (rev 1237)
@@ -3,16 +3,16 @@
-------------
New features
-. Terms can be body plans enclosed by |{ ... }", as in the following
+. Terms can be body plans enclosed by "{ ... }", as in the following
example:
test({ a1; !g; ?b(X); .print(X) }, 10)
Bugs fixed:
+. unification in return of ! and ?
. use nested source annotations in communication
. add "source(self)" in goals without source
. correctly handle failure event caused by no relevant plans
. timeout in .wait does not cause a runtime exception
-. unification in return of ! and ?
-------------
Modified: trunk/src/jason/jeditplugin/CheckVersion.java
===================================================================
--- trunk/src/jason/jeditplugin/CheckVersion.java 2008-04-21 16:46:57 UTC (rev 1236)
+++ trunk/src/jason/jeditplugin/CheckVersion.java 2008-04-22 11:20:01 UTC (rev 1237)
@@ -21,7 +21,7 @@
public static final String JasonSite = "http://jason.sf.net";
String download;
- int version;
+ String version;
String release;
String getLatestVersion() {
@@ -30,10 +30,11 @@
Properties p = new Properties();
p.load(new URL(JasonSite+"/latest.properties").openStream());
download = p.getProperty("download");
- version = Integer.parseInt(p.getProperty("version"));
+ version = p.getProperty("version");
release = p.getProperty("release");
return version + "." + release;
} catch (Exception ex) {
+ System.out.println(ex);
return null;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-22 16:46:32
|
Revision: 1239
http://jason.svn.sourceforge.net/jason/?rev=1239&view=rev
Author: jomifred
Date: 2008-04-22 09:46:22 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
experimentally remove import E.TE annots to Plan.TE annots
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/BugListReturnUnification.java
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/Plan.java
Modified: trunk/applications/as-unit-test/src/jason/tests/BugListReturnUnification.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/BugListReturnUnification.java 2008-04-22 16:24:29 UTC (rev 1238)
+++ trunk/applications/as-unit-test/src/jason/tests/BugListReturnUnification.java 2008-04-22 16:46:22 UTC (rev 1239)
@@ -22,16 +22,25 @@
"+!test2 <- L=[A,B,C,D]; !bundle(L); jason.asunit.print(L). "+
"+!bundle([]). "+
- "+!bundle([a|T]) <- !bundle(T). "
+ "+!bundle([a|T]) <- !bundle(T). "+
+
+ "+!test3 <- !a(Y)[x(Z), y]; jason.asunit.print(Y, Z). "+
+ "+!a(Y)[x(Z),kk] <- Y=3; Z=4. "+
+ "+!a(Y)[x(Z),source(self)] <- Y=1; Z=2. "
);
}
@Test
- public void testContext() {
+ public void testList() {
ag.addGoal("test1");
ag.assertPrint("[a,a]", 10);
ag.addGoal("test2");
ag.assertPrint("[a,a,a,a]", 10);
}
+ @Test
+ public void testAnnots() {
+ ag.addGoal("test3");
+ ag.assertPrint("12", 10);
+ }
}
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-04-22 16:24:29 UTC (rev 1238)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-04-22 16:46:22 UTC (rev 1239)
@@ -24,12 +24,11 @@
package jason.asSemantics;
-import jason.asSyntax.PlanBody;
-import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
-import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
@@ -51,12 +50,15 @@
public IntendedMeans(Option opt, Trigger te) {
plan = opt.getPlan().cloneOnlyBody();
unif = opt.getUnifier(); //(Unifier)opt.getUnifier().clone();
+
+ // REMOVED: experimental
+ /*
Literal planLiteral = plan.getTrigger().getLiteral();
if (planLiteral.hasAnnot()) {
planLiteral.getAnnots().apply(unif);
// TODO: why?
- // if the plans.TE is not change, we do not need to clone it in plan.cloneBodyOnly
}
+ */
if (te == null) {
trigger = plan.getTrigger();
} else {
@@ -65,10 +67,9 @@
// add annots of the trigger into the plan's te
// so that the event +!g[source(ag1)] will add source(ag1)
// in the TE of the plan
- // TODO: why? -- in the TS.applyClrInt -- end of the method, the unification could be g,tel and not tel,g!
- // (the plan trigger will be used latter to "return" values
- // see TS.applyClrInt -- end of the method)
- planLiteral.addAnnots(trigger.getLiteral().getAnnots());
+ // TODO: why?
+ // REMOVED: experimental
+ //planLiteral.addAnnots(trigger.getLiteral().getAnnots());
}
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-04-22 16:24:29 UTC (rev 1238)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-04-22 16:46:22 UTC (rev 1239)
@@ -657,7 +657,6 @@
// they are anonymous)
Literal tel = topIM.getPlan().getTrigger().getLiteral();
tel.apply(topIM.unif);
- // TODO: why not unifies(g,tel)?
im.unif.unifies(tel, g);
}
}
Modified: trunk/src/jason/asSyntax/Plan.java
===================================================================
--- trunk/src/jason/asSyntax/Plan.java 2008-04-22 16:24:29 UTC (rev 1238)
+++ trunk/src/jason/asSyntax/Plan.java 2008-04-22 16:46:22 UTC (rev 1239)
@@ -218,9 +218,9 @@
p.isAllUnifs = isAllUnifs;
}
- p.tevent = (Trigger)tevent.clone();
+ p.tevent = (Trigger)tevent.clone();
p.context = context;
- p.body = (PlanBody)body.clone();
+ p.body = (PlanBody)body.clone();
p.setSrc(this);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-25 17:34:12
|
Revision: 1260
http://jason.svn.sourceforge.net/jason/?rev=1260&view=rev
Author: jomifred
Date: 2008-04-25 10:33:58 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
jason team: new computation of herding positions
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestIF.java
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/goto.asl
trunk/applications/jason-team/src/java/arch/ACArchitecture.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/jia/Vec.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
trunk/src/jason/environment/grid/Location.java
Added Paths:
-----------
trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestIF.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestIF.java 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/as-unit-test/src/jason/tests/TestIF.java 2008-04-25 17:33:58 UTC (rev 1260)
@@ -20,7 +20,11 @@
"+!test1 <- a1; "+
" .if( b(X), {jason.asunit.print(X); b1}, {jason.asunit.print(no)}); "+
" a2. "+
- "+!test2 <- -b(_); !test1. "
+
+ "+!test2 <- -b(_); !test1. "+
+
+ "+!test3 <- .if( b(X), { Y = X*10; Z = 10 }, { Y = 60; Z=20 }); jason.asunit.print(Y,\" \",Z). "+
+ "+!test4 <- -b(_); !test3. "
);
}
@@ -38,4 +42,12 @@
ag.assertPrint("no", 5);
ag.assertAct("a2", 5);
}
+
+ @Test
+ public void testUnifiyInThenElse() {
+ ag.addGoal("test3");
+ ag.assertPrint("30 10", 5);
+ ag.addGoal("test4");
+ ag.assertPrint("60 20", 10);
+ }
}
Added: trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestLoop.java (rev 0)
+++ trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-04-25 17:33:58 UTC (rev 1260)
@@ -0,0 +1,37 @@
+package jason.tests;
+
+import jason.asunit.TestAgent;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestLoop {
+
+ TestAgent ag;
+
+ // initialisation of the agent test
+ @Before
+ public void setupAg() {
+ ag = new TestAgent();
+
+ // defines the agent's AgentSpeak code
+ ag.parseAScode(
+ "b(1). "+
+ "+!test1 <- .while( .count(b(_),N) & N < 4, {+b(N+1) })."+
+
+ "+!test2 <- L=4; .while( .count(b(_)) < L, { ?b(X); +b(X+1) }); jason.asunit.print(end)."
+ );
+ }
+
+ @Test
+ public void test1() {
+ ag.addGoal("test1");
+ ag.assertBel("b(4)", 20);
+ }
+
+ @Test
+ public void test2() {
+ ag.addGoal("test2");
+ ag.assertBel("b(4)", 30);
+ }
+}
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-25 17:33:58 UTC (rev 1260)
@@ -10,40 +10,40 @@
infrastructure: Centralised
agents:
- orgManager [osfile="src/team-os.xml",gui=yes]
+ orgManager [osfile="src/team-os.xml",gui=no]
agentArchClass jmoise.OrgManager;
- gaucho1 gaucho.asl
+ gaucho1 dummy.asl
[verbose=1, gui=yes, write_status=yes, ac_sim_back_dir="./massim-server/backup",
host="localhost", port=12300, username=participant1, password="1"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)","pratio(_)");
- gaucho2 gaucho.asl
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ gaucho2 dummy.asl
[verbose=1,host="localhost", port=12300, username=participant2, password="2"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)","pratio(_)");
- gaucho3 gaucho.asl
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ gaucho3 dummy.asl
[verbose=1,host="localhost", port=12300, username=participant3, password="3"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)","pratio(_)");
- gaucho4 gaucho.asl
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ gaucho4 dummy.asl
[verbose=1,host="localhost", port=12300, username=participant4, password="4"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)","pratio(_)");
- gaucho5 gaucho.asl
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ gaucho5 dummy.asl
[verbose=1,host="localhost", port=12300, username=participant5, password="5"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)","pratio(_)");
- gaucho6 gaucho.asl
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
+ gaucho6 dummy.asl
[verbose=1,host="localhost", port=12300, username=participant6, password="6"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)","pratio(_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
aslSourcePath: "src/asl";
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-04-25 17:33:58 UTC (rev 1260)
@@ -47,7 +47,7 @@
// revise target each 4 steps
+pos(Step,_,_) // new cycle
- : Step mod 4 == 0
+ : Step mod 10 == 0
<- !decide_target.
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-04-25 17:33:58 UTC (rev 1260)
@@ -15,7 +15,7 @@
+gsize(_Weight,_Height) // new match've started
: .my_name(gaucho1) // agent 1 is responsible for the team creation
- <- .print("oooo creating team group");
+ <- //.print("oooo creating team group");
.if( group(team,Old), {
jmoise.remove_group(Old)
});
@@ -40,40 +40,46 @@
<- .broadcast(tell, group_area(ID,G,A)).
-/* plans for agents with even id */
+/* plans for agents with odd id */
+gsize(_,_)
: .my_name(Me) &
agent_id(Me,AgId) &
- AgId mod 2 == 0 // I have an even Id
- <- // wait my pos
- .if(not pos(MyX, MyY,_), { MyX = 333; MyY = 444 }); //.wait("+pos(MyX,MyY,_)")
- .print("oooo ",MyX, MyY); //?pos(MyX, MyY,_);
+ AgId mod 2 == 1 // I have an odd Id
+ <- .print("ooo Recruiting scouters for my explorer group....");
+
+ // wait my pos
+ ?pos(MyX,MyY,_);
// wait others pos
- .if(not cell(_,_,ally(_)), { .wait("+cell(_,_,ally(_))") });
- .wait(200);
+ .while( .count(cell(_,_,ally(_)), N) & N < 5, {
+ .print("ooo waiting others pos ");
+ .wait("+cell(_,_,ally(_))", 500, nofail)
+ });
- // find distance to odd agents
+ // find distance to even agents
.findall(ag_d(D,AgName),
- cell(X,Y,ally(AgName)) & .print(AgName) & agent_id(AgName,Id) & .print(AgName," ooo ",Id) & Id mod 2 == 1 & jia.dist(MyX, MyY, X, Y, D),
+ cell(X,Y,ally(AgName)) & agent_id(AgName,Id) & Id mod 2 == 0 & jia.dist(MyX, MyY, X, Y, D),
LOdd);
.sort(LOdd, LSOdd);
+
// test if I received the area of my group
- .if( not group_area(AgId div 2,G,A), { .wait("+group_area(AgId div 2,G,A)") });
- .print("oooo Ags=", LSOdd," in area ",group_area(AgId div 2,G,A));
+ ?group_area(AgId div 2,G,A);
+ .print("ooo Scouters candidates =", LSOdd," in area ",group_area(AgId div 2,G,A));
// adopt role explorer in the group
jmoise.adopt_role(explorer,G);
!find_scouter(LSOdd, G).
+!find_scouter([],_)
- <- .print("oooo I do not find a scouter to work with me!").
+ <- .print("ooo I do not find a scouter to work with me!").
+!find_scouter([ag_d(_,AgName)|_],GId)
- <- .send(AgName, achieve, play_role(scouter,GId));
- .wait("+play(Ag,scouter,GId)",1000).
+ <- .print("ooo Ask ",AgName," to play scouter");
+ .send(AgName, achieve, play_role(scouter,GId));
+ .wait("+play(Ag,scouter,GId)",2000).
-!find_scouter([_|LSOdd],GId) // in case the wait fails, try next agent
- <- !find_scouter(LSOdd,GId).
+ <- .print("ooo find_scouter failure, try another agent.");
+ !find_scouter(LSOdd,GId).
/* plans for agents the others */
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-25 17:33:58 UTC (rev 1260)
@@ -32,12 +32,18 @@
/* -- plans -- */
++pos(_,_,_) <- do(skip).
+
+
++?pos(X, Y, S) <- .wait("+pos(X,Y,S)").
++?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
+
+end_of_simulation(_Result)
<- .abolish(area(_,_,_,_,_,_)).
+!restart
- <- //.print("*** restart ***");
- .drop_all_desires;
+ <- .print("*** restart ***");
+ //.drop_all_desires;
.abolish(target(_,_)).
// TODO: what to do?
//!decide_target.
Modified: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-04-25 17:33:58 UTC (rev 1260)
@@ -24,12 +24,13 @@
!!move.
// I still do not know my location
+/*
+!move
: not pos(_,_,_)
<- .print("waiting my location....");
.wait("+pos(_,_,_)");
!move.
-
+*/
+!move
: not target(_,_)
<- .print("waiting my target....");
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-25 17:33:58 UTC (rev 1260)
@@ -177,7 +177,7 @@
// prepare msg to print out
String w = "";
- if (lastActionInCurrentCycle == null && cycleCounter > 3) { // ignore problem in the first cycles (the agent is still in setup!)
+ if (lastActionInCurrentCycle == null && cycleCounter > 10) { // ignore problem in the first cycles (the agent is still in setup!)
addRestart();
w = "*** ";
}
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-25 17:33:58 UTC (rev 1260)
@@ -1,6 +1,7 @@
package arch;
import jason.JasonException;
+import jason.ReceiverDoesNotExistException;
import jason.RevisionFailedException;
import jason.asSemantics.Intention;
import jason.asSemantics.Message;
@@ -67,6 +68,8 @@
massimBackDir = stts.getUserParameter("ac_sim_back_dir");
if (massimBackDir != null && massimBackDir.startsWith("\""))
massimBackDir = massimBackDir.substring(1,massimBackDir.length()-1);
+ logger = Logger.getLogger(CowboyArch.class.getName() + ".CA-" + getAgName());
+
}
@Override
@@ -299,9 +302,15 @@
if (!getAgName().equals(oname)) {
Message msg = new Message(m);
msg.setReceiver(oname);
- try {
- sendMsg(msg);
- } catch (JasonException e) {} // no problem, the agent still does not exists
+ for (int t=0; t<4; t++) {
+ try {
+ sendMsg(msg);
+ break; // the for
+ } catch (ReceiverDoesNotExistException e) {
+ // wait and try again
+ Thread.sleep(500);
+ }
+ }
}
}
}
Modified: trunk/applications/jason-team/src/java/jia/Vec.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Vec.java 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/java/jia/Vec.java 2008-04-25 17:33:58 UTC (rev 1260)
@@ -34,7 +34,7 @@
public int getX() { return (int)Math.round(x); }
public int getY() { return (int)Math.round(y); }
public double magnitude() { return r; }
- public double angle() { return t; }
+ public double angle() { return t; }
public Location getLocation(LocalWorldModel model) {
return new Location(getX(), model.getHeight()-getY()-1);
@@ -54,7 +54,9 @@
while (t < 0) t = t + PI2;
return new Vec(r*Math.cos(t), r*Math.sin(t));
}
-
+ public Vec newMagnitude(double r) {
+ return new Vec(r*Math.cos(t), r*Math.sin(t));
+ }
@Override
public boolean equals(Object o) {
if (o == null) return false;
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-25 17:33:58 UTC (rev 1260)
@@ -9,7 +9,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.ListIterator;
import java.util.logging.Level;
import arch.CowboyArch;
@@ -27,9 +26,9 @@
public static final double maxStdDev = 3;
public enum Formation {
- one { int[] getAngles() { return new int[] { 0 }; } },
- six { int[] getAngles() { return new int[] { 10, -10, 30, -30, 60, -60 }; } };
- abstract int[] getAngles();
+ one { int[] getDistances() { return new int[] { 0 }; } },
+ six { int[] getDistances() { return new int[] { 2, -2, 6, -6, 10, -10 }; } };
+ abstract int[] getDistances();
};
@Override
@@ -99,6 +98,7 @@
Vec mean = Vec.mean(cows);
int stepsFromCenter = (int)Math.round(Vec.max(cows).sub(mean).magnitude())+1;
+ //Vec max = Vec.max(cows);
// run A* to see the cluster target in n steps
Search s = new Search(model, mean.getLocation(model), model.getCorralCenter(), null, false, false, false, true, null);
@@ -108,40 +108,60 @@
Vec cowstarget = new Vec(model, s.getNodeLocation(np.get(n)));
Vec agsTarget = mean.sub(cowstarget);
- Vec agTarget = agsTarget;
List<Location> r = new ArrayList<Location>();
- for (int angle: formation.getAngles()) {
- double nt = angle * (Math.PI / 180);
-
- agTarget = agsTarget.newAngle(agsTarget.angle() + nt);
- Location l = agTarget.add(mean).getLocation(model);
- r.add(l);
+ int initAgTS = 1;
+ for (int dist: formation.getDistances()) { // 2, -2, 6, -6, ....
+ Vec agTarget = agsTarget;
+ Location l = agTarget.add(mean).getLocation(model);
- // TODO: test the code below
- /*
- for (double varangle = nt; nt < 180; nt += 5) {
- agTarget = agsTarget.newAngle(agsTarget.angle() + varangle);
- Location l = agTarget.add(mean).getLocation(model);
-
- // if l is in the path of cows, continue with next varangle
- boolean inpath = false;
- for (Nodo pn: np) {
- if (l.maxBorder(s.getNodeLocation(pn)) <= 0) {
- inpath = true;
- break;
- }
- }
- if (!inpath) {
- r.add(l);
- break;
- }
+ //System.out.println("....... "+dist+" antes angle "+agTarget);
+ if (dist >= 0)
+ agTarget = new Vec( -agTarget.y, agTarget.x);
+ else
+ agTarget = new Vec( agTarget.y, -agTarget.x);
+
+ Location lastloc = null;
+ boolean uselast = false;
+ for (int agTargetSize = initAgTS; agTargetSize <= Math.abs(dist); agTargetSize++) {
+ l = agTarget.newMagnitude(agTargetSize).add(mean).add(agsTarget).getLocation(model);
+ //System.out.println("pos angle "+agTargetSize);
+ uselast = !model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l) && lastloc != null;
+ if (uselast) {
+ r.add(pathToNearCow(model, lastloc));
+ break;
+ }
+ lastloc = l;
}
- */
+ if (!uselast)
+ r.add(pathToNearCow(model, l));
+ if (dist < 0)
+ initAgTS = Math.abs(dist)+1;
}
+ //System.out.println("all places "+r);
return r;
}
+ private Location pathToNearCow(LocalWorldModel model, Location t) {
+ Location near = null;
+ for (Location c: model.getCows()) {
+ if (near == null || t.maxBorder(c) < t.maxBorder(near))
+ near = c;
+ }
+ if (near != null) {
+ Vec nearcv = new Vec(model,near);
+ Vec dircow = new Vec(model,t).sub(nearcv);
+ //System.out.println("Near cow to "+t+" is "+near+" vec = "+dircow);
+ for (int s = 1; s <= 20; s++) {
+ Location l = dircow.newMagnitude(s).add(nearcv).getLocation(model);
+ if (model.isFree(l))
+ return l;
+ }
+ }
+ return t;
+ }
+
public Location nearFreeForAg(LocalWorldModel model, Location ag, Location t) throws Exception {
+ /*
// run A* to get the path from ag to t
if (! model.inGrid(t))
t = model.nearFree(t);
@@ -159,6 +179,7 @@
if (i++ > 3) // do not go to far from target
break;
}
+ */
return model.nearFree(t);
}
}
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-25 17:33:58 UTC (rev 1260)
@@ -149,20 +149,20 @@
assertEquals(3, stepsFromCenter);
Location byIA = new herd_position().getAgTarget(model, Formation.one, cowboy.getLocation(model));
- assertEquals(new Location(7,37), byIA);
+ assertEquals(new Location(6,38), byIA);
byIA = new herd_position().getAgTarget(model, Formation.six, cowboy.getLocation(model));
- assertEquals(new Location(6,37), byIA);
+ assertEquals(new Location(5,38), byIA);
- // add an agent in 6,38
- model.add(WorldModel.AGENT, 6,38);
+ // add an agent in 5,38
+ model.add(WorldModel.AGENT, 5,38);
byIA = new herd_position().getAgTarget(model, Formation.six, cowboy.getLocation(model));
- assertEquals(new Location(8,38), byIA);
+ assertEquals(new Location(7,42), byIA);
- // add an agent in 8,39 (near 8,38)
- model.add(WorldModel.AGENT, 8,39);
+ // add an agent in 7,42
+ model.add(WorldModel.AGENT, 7,42);
byIA = new herd_position().getAgTarget(model, Formation.six,cowboy.getLocation(model));
- assertEquals(new Location(3,37), byIA);
+ assertEquals(new Location(8,42), byIA);
}
@Test
Modified: trunk/src/jason/environment/grid/Location.java
===================================================================
--- trunk/src/jason/environment/grid/Location.java 2008-04-25 14:39:27 UTC (rev 1259)
+++ trunk/src/jason/environment/grid/Location.java 2008-04-25 17:33:58 UTC (rev 1260)
@@ -41,6 +41,7 @@
@Override
public boolean equals(Object obj) {
+ if (obj == null) return false;
if (this == obj) return true;
if (getClass() != obj.getClass()) return false;
final Location other = (Location) obj;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-26 08:07:41
|
Revision: 1262
http://jason.svn.sourceforge.net/jason/?rev=1262&view=rev
Author: jomifred
Date: 2008-04-26 01:07:38 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
add schemes for herding and exploring in the org. spec.
define better cardinalities in org. spec.
Modified Paths:
--------------
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/doc/roles/ac2008-roles.pdf
trunk/applications/jason-team/doc/roles/figures/jason-team-SS.pdf
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/team-os.xml
trunk/src/jason/infra/centralised/CentralisedAgArch.java
Added Paths:
-----------
trunk/applications/jason-team/doc/roles/figures/jason-team-SS.dia
trunk/src/jason/ReceiverNotFoundException.java
Removed Paths:
-------------
trunk/applications/jason-team/doc/roles/figures/exploration-positioning.eps
trunk/applications/jason-team/doc/roles/figures/jason-team-SS.eps
trunk/applications/jason-team/doc/roles/figures/partition.eps
trunk/src/jason/ReceiverDoesNotExistException.java
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-25 20:05:54 UTC (rev 1261)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-26 08:07:38 UTC (rev 1262)
@@ -10,36 +10,36 @@
infrastructure: Centralised
agents:
- orgManager [osfile="src/team-os.xml",gui=no]
+ orgManager [osfile="src/team-os.xml",gui=yes]
agentArchClass jmoise.OrgManager;
- gaucho1 dummy.asl
+ gaucho1 gaucho.asl
[verbose=1, gui=yes, write_status=yes, ac_sim_back_dir="./massim-server/backup",
host="localhost", port=12300, username=participant1, password="1"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
- gaucho2 dummy.asl
+ gaucho2 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant2, password="2"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
- gaucho3 dummy.asl
+ gaucho3 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant3, password="3"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
- gaucho4 dummy.asl
+ gaucho4 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant4, password="4"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
- gaucho5 dummy.asl
+ gaucho5 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant5, password="5"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)");
- gaucho6 dummy.asl
+ gaucho6 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant6, password="6"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
Modified: trunk/applications/jason-team/doc/roles/ac2008-roles.pdf
===================================================================
(Binary files differ)
Deleted: trunk/applications/jason-team/doc/roles/figures/exploration-positioning.eps
===================================================================
--- trunk/applications/jason-team/doc/roles/figures/exploration-positioning.eps 2008-04-25 20:05:54 UTC (rev 1261)
+++ trunk/applications/jason-team/doc/roles/figures/exploration-positioning.eps 2008-04-26 08:07:38 UTC (rev 1262)
@@ -1,382 +0,0 @@
-%!PS-Adobe-3.0 EPSF-3.0
-%%BoundingBox: 0 0 326 332
-%%Pages: 0
-%%Creator: Sun Microsystems, Inc.
-%%Title: none
-%%CreationDate: none
-%%LanguageLevel: 2
-%%EndComments
-%%BeginProlog
-%%BeginResource: procset SDRes-Prolog 1.0 0
-/b4_inc_state save def
-/dict_count countdictstack def
-/op_count count 1 sub def
-userdict begin
-0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit[] 0 setdash newpath
-/languagelevel where {pop languagelevel 1 ne {false setstrokeadjust false setoverprint} if} if
-/bdef {bind def} bind def
-/c {setrgbcolor} bdef
-/l {neg lineto} bdef
-/rl {neg rlineto} bdef
-/lc {setlinecap} bdef
-/lj {setlinejoin} bdef
-/lw {setlinewidth} bdef
-/ml {setmiterlimit} bdef
-/ld {setdash} bdef
-/m {neg moveto} bdef
-/ct {6 2 roll neg 6 2 roll neg 6 2 roll neg curveto} bdef
-/r {rotate} bdef
-/t {neg translate} bdef
-/s {scale} bdef
-/sw {show} bdef
-/gs {gsave} bdef
-/gr {grestore} bdef
-/f {findfont dup length dict begin
-{1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def
-currentdict end /NFont exch definefont pop /NFont findfont} bdef
-/p {closepath} bdef
-/sf {scalefont setfont} bdef
-/ef {eofill}bdef
-/pc {closepath stroke}bdef
-/ps {stroke}bdef
-/pum {matrix currentmatrix}bdef
-/pom {setmatrix}bdef
-/bs {/aString exch def /nXOfs exch def /nWidth exch def currentpoint nXOfs 0 rmoveto pum nWidth aString stringwidth pop div 1 scale aString show pom moveto} bdef
-%%EndResource
-%%EndProlog
-%%BeginSetup
-%%EndSetup
-%%Page: 1 1
-%%BeginPageSetup
-%%EndPageSetup
-pum
-0.02834 0.02831 s
-0 -11726 t
-/tm matrix currentmatrix def
-tm setmatrix
--2500 -11000 t
-1 1 s
-0.753 0.753 0.753 c 3500 20000 m 4067 20000 4500 20433 4500 21000 ct 4500 21567 4067 22000 3500 22000 ct
-2933 22000 2500 21567 2500 21000 ct 2500 20433 2933 20000 3500 20000 ct p ef
-0 lw 1 lj 0.003 0.003 0.003 c 3500 20000 m 4067 20000 4500 20433 4500 21000 ct
-4500 21567 4067 22000 3500 22000 ct 2933 22000 2500 21567 2500 21000 ct 2500 20433 2933 20000 3500 20000 ct
-pc
-0.648 0.648 0.648 c 3175 20588 m 3235 20588 3282 20635 3282 20695 ct 3282 20755 3235 20802 3175 20802 ct
-3115 20802 3068 20755 3068 20695 ct 3068 20635 3115 20588 3175 20588 ct p ef
-0.003 0.003 0.003 c 3175 20588 m 3235 20588 3282 20635 3282 20695 ct 3282 20755 3235 20802 3175 20802 ct
-3115 20802 3068 20755 3068 20695 ct 3068 20635 3115 20588 3175 20588 ct pc
-0.648 0.648 0.648 c 3823 20588 m 3883 20588 3930 20635 3930 20695 ct 3930 20755 3883 20802 3823 20802 ct
-3763 20802 3716 20755 3716 20695 ct 3716 20635 3763 20588 3823 20588 ct p ef
-0.003 0.003 0.003 c 3823 20588 m 3883 20588 3930 20635 3930 20695 ct 3930 20755 3883 20802 3823 20802 ct
-3763 20802 3716 20755 3716 20695 ct 3716 20635 3763 20588 3823 20588 ct pc
-2951 21436 m 3304 21623 3696 21623 4049 21436 ct ps
-gs
-gs
-pum
-10438 19614 t
-54 0 m 54 -455 l 385 -455 l 385 -399 l 114 -399 l 114 -261 l 365 -261 l
-365 -207 l 114 -207 l 114 -53 l 389 -53 l 389 0 l 54 0 l p
-222 -455 m 222 -455 l p ef
-543 -169 m 432 -331 l 505 -331 l 581 -214 l 658 -331 l 726 -329 l
-614 -169 l 731 0 l 660 0 l 577 -124 l 497 0 l 426 0 l 543 -169 l
-p ef
-923 -35 m 948 -35 969 -46 986 -68 ct 1003 -90 1012 -123 1012 -167 ct 1012 -193 1008 -216 1001 -236 ct
-986 -273 960 -291 923 -291 ct 884 -291 858 -271 844 -232 ct 837 -212 833 -185 833 -153 ct
-833 -127 837 -105 844 -87 ct 859 -52 885 -35 923 -35 ct p
-778 132 m 778 132 778 132 778 -330 ct 778 -330 778 -330 833 -330 ct 833 -330 833 -330 833 -286 ct
-844 -301 856 -313 869 -321 ct 888 -333 910 -339 935 -339 ct 973 -339 1005 -325 1031 -296 ct
-1057 -267 1070 -226 1070 -172 ct 1070 -99 1051 -48 1013 -17 ct 989 2 962 12 930 12 ct
-905 12 884 7 867 -3 ct 857 -9 846 -20 834 -35 ct 834 -35 834 -35 834 132 ct 834 132 834 132 778 132 ct
-p ef
-1134 0 m 1134 -454 l 1190 -454 l 1190 0 l 1134 0 l p ef
-1404 -35 m 1440 -35 1465 -49 1479 -77 ct 1492 -105 1499 -137 1499 -171 ct 1499 -202 1494 -227 1484 -247 ct
-1469 -278 1442 -293 1404 -293 ct 1371 -293 1346 -280 1331 -254 ct 1316 -228 1308 -196 1308 -159 ct
-1308 -124 1316 -94 1331 -70 ct 1346 -47 1370 -35 1404 -35 ct p
-1405 -341 m 1448 -341 1484 -327 1513 -298 ct 1542 -270 1557 -228 1557 -172 ct
-1557 -119 1544 -74 1518 -39 ct 1492 -4 1452 12 1398 12 ct 1353 12 1317 -2 1290 -33 ct
-1263 -64 1250 -106 1250 -158 ct 1250 -214 1264 -258 1292 -291 ct 1320 -324 1358 -341 1405 -341 ct
-p
-1404 -339 m 1404 -339 l p ef
-1625 0 m 1625 0 1625 0 1625 -332 ct 1625 -332 1625 -332 1678 -332 ct 1678 -332 1678 -332 1678 -275 ct
-1682 -286 1693 -299 1710 -315 ct 1727 -331 1747 -339 1769 -339 ct 1770 -339 1772 -339 1774 -339 ct
-1777 -338 1781 -338 1787 -337 ct 1787 -337 1787 -337 1787 -279 ct 1784 -280 1781 -280 1778 -281 ct
-1775 -281 1772 -281 1769 -281 ct 1740 -281 1719 -272 1704 -254 ct 1689 -235 1681 -214 1681 -191 ct
-1681 -191 1681 -191 1681 0 ct 1681 0 1681 0 1625 0 ct p ef
-1973 -339 m 1996 -339 2019 -333 2041 -322 ct 2063 -311 2079 -297 2091 -279 ct
-2102 -262 2109 -243 2113 -220 ct 2116 -205 2118 -180 2118 -147 ct 2118 -147 2118 -147 1877 -147 ct
-1878 -113 1886 -86 1901 -66 ct 1915 -45 1938 -35 1969 -35 ct 1998 -35 2021 -45 2038 -64 ct
-2047 -75 2054 -87 2058 -102 ct 2058 -102 2058 -102 2113 -102 ct 2112 -90 2107 -76 2099 -62 ct
-2090 -47 2081 -35 2071 -25 ct 2054 -9 2034 1 2009 7 ct 1996 10 1981 12 1964 12 ct
-1923 12 1888 -2 1860 -32 ct 1831 -62 1817 -105 1817 -159 ct 1817 -212 1831 -256 1860 -289 ct
-1889 -322 1926 -339 1973 -339 ct p
-1878 -191 m 1878 -191 1878 -191 2060 -191 ct 2058 -216 2053 -235 2044 -250 ct
-2029 -277 2004 -291 1969 -291 ct 1944 -291 1922 -282 1905 -263 ct 1888 -244 1879 -220 1878 -191 ct
-p
-1968 -339 m 1968 -339 l p ef
-2188 0 m 2188 0 2188 0 2188 -332 ct 2188 -332 2188 -332 2241 -332 ct 2241 -332 2241 -332 2241 -275 ct
-2245 -286 2256 -299 2273 -315 ct 2290 -331 2310 -339 2332 -339 ct 2333 -339 2335 -339 2337 -339 ct
-2340 -338 2344 -338 2350 -337 ct 2350 -337 2350 -337 2350 -279 ct 2347 -280 2344 -280 2341 -281 ct
-2338 -281 2335 -281 2332 -281 ct 2303 -281 2282 -272 2267 -254 ct 2252 -235 2244 -214 2244 -191 ct
-2244 -191 2244 -191 2244 0 ct 2244 0 2244 0 2188 0 ct p ef
-pom
-gr
-gr
-gs
-gs
-pum
-4246 22312 t
-31 -147 m 31 -147 31 -147 89 -147 ct 90 -121 96 -100 107 -84 ct 126 -54 161 -39 210 -39 ct
-233 -39 253 -42 271 -49 ct 306 -62 324 -85 324 -118 ct 324 -143 317 -161 302 -171 ct
-286 -181 263 -190 230 -197 ct 230 -197 230 -197 171 -211 ct 132 -220 104 -230 88 -241 ct
-60 -260 46 -288 46 -326 ct 46 -367 60 -401 87 -427 ct 115 -454 154 -467 204 -467 ct
-251 -467 290 -455 322 -432 ct 355 -409 371 -373 371 -322 ct 371 -322 371 -322 313 -322 ct
-310 -346 304 -365 294 -378 ct 276 -401 246 -413 203 -413 ct 168 -413 143 -405 128 -390 ct
-113 -375 105 -357 105 -337 ct 105 -315 114 -298 132 -288 ct 144 -281 170 -273 212 -263 ct
-212 -263 212 -263 273 -249 ct 303 -242 326 -232 342 -220 ct 370 -199 384 -168 384 -127 ct
-384 -77 366 -41 330 -19 ct 295 1 253 12 206 12 ct 151 12 108 -1 77 -30 ct 46 -59 30 -98 31 -147 ct
-p
-209 -467 m 209 -467 l p ef
-592 -341 m 629 -341 659 -332 683 -314 ct 706 -296 720 -264 725 -220 ct 725 -220 725 -220 671 -220 ct
-668 -240 660 -257 648 -271 ct 637 -284 618 -291 592 -291 ct 556 -291 531 -274 516 -239 ct
-506 -216 501 -188 501 -155 ct 501 -122 508 -94 522 -71 ct 536 -48 558 -37 588 -37 ct
-611 -37 630 -44 643 -58 ct 657 -72 666 -92 671 -116 ct 671 -116 671 -116 725 -116 ct
-719 -72 703 -40 679 -20 ct 654 0 622 10 583 10 ct 540 10 506 -5 480 -37 ct 454 -68 441 -108 441 -156 ct
-441 -214 455 -260 483 -292 ct 512 -325 548 -341 592 -341 ct p
-583 -339 m 583 -339 l p ef
-913 -35 m 949 -35 974 -49 988 -77 ct 1001 -105 1008 -137 1008 -171 ct 1008 -202 1003 -227 993 -247 ct
-978 -278 951 -293 913 -293 ct 880 -293 855 -280 840 -254 ct 825 -228 817 -196 817 -159 ct
-817 -124 825 -94 840 -70 ct 855 -47 879 -35 913 -35 ct p
-914 -341 m 957 -341 993 -327 1022 -298 ct 1051 -270 1066 -228 1066 -172 ct
-1066 -119 1053 -74 1027 -39 ct 1001 -4 961 12 907 12 ct 862 12 826 -2 799 -33 ct
-772 -64 759 -106 759 -158 ct 759 -214 773 -258 801 -291 ct 829 -324 867 -341 914 -341 ct
-p
-913 -339 m 913 -339 l p ef
-1132 -332 m 1132 -332 1132 -332 1188 -332 ct 1188 -332 1188 -332 1188 -110 ct
-1188 -93 1191 -79 1196 -68 ct 1206 -48 1224 -38 1250 -38 ct 1288 -38 1314 -55 1328 -90 ct
-1335 -109 1339 -135 1339 -168 ct 1339 -168 1339 -168 1339 -332 ct 1339 -332 1339 -332 1395 -332 ct
-1395 -332 1395 -332 1395 0 ct 1395 0 1395 0 1342 0 ct 1342 0 1342 0 1343 -47 ct
-1336 -34 1327 -24 1316 -15 ct 1295 1 1270 9 1240 9 ct 1194 9 1162 -6 1146 -38 ct
-1137 -55 1132 -77 1132 -106 ct 1132 -106 1132 -106 1132 -332 ct p
-1264 -339 m 1264 -339 l p ef
-1496 -332 m 1496 -332 1496 -332 1496 -424 ct 1496 -424 1496 -424 1552 -424 ct
-1552 -424 1552 -424 1552 -332 ct 1552 -332 1552 -332 1605 -332 ct 1605 -332 1605 -332 1605 -286 ct
-1605 -286 1605 -286 1552 -286 ct 1552 -286 1552 -286 1552 -70 ct 1552 -58 1556 -50 1564 -46 ct
-1568 -44 1575 -43 1585 -43 ct 1588 -43 1591 -43 1594 -43 ct 1597 -43 1601 -44 1605 -44 ct
-1605 -44 1605 -44 1605 0 ct 1599 2 1592 3 1585 4 ct 1578 5 1571 5 1563 5 ct 1537 5 1519 -1 1510 -14 ct
-1501 -27 1496 -45 1496 -66 ct 1496 -66 1496 -66 1496 -286 ct 1496 -286 1496 -286 1451 -286 ct
-1451 -286 1451 -286 1451 -332 ct 1451 -332 1451 -332 1496 -332 ct p ef
-pom
-gr
-gr
-gs
-gs
-pum
-11258 12708 t
-9 -455 m 377 -455 l 377 -401 l 224 -401 l 224 0 l 162 0 l 162 -401 l
-9 -401 l 9 -455 l p ef
-401 -87 m 401 -71 407 -58 419 -49 ct 430 -40 444 -35 461 -35 ct 480 -35 499 -40 518 -49 ct
-549 -64 564 -89 564 -123 ct 564 -123 564 -123 564 -168 ct 557 -163 548 -159 538 -156 ct
-527 -153 516 -151 506 -150 ct 506 -150 506 -150 472 -146 ct 452 -143 437 -139 427 -133 ct
-410 -123 401 -108 401 -87 ct p
-447 -189 m 447 -189 447 -189 536 -200 ct 549 -201 557 -207 562 -216 ct 565 -221 566 -228 566 -237 ct
-566 -256 559 -270 546 -278 ct 532 -287 513 -291 487 -291 ct 458 -291 438 -283 425 -268 ct
-419 -259 414 -246 412 -229 ct 412 -229 412 -229 360 -229 ct 361 -270 374 -299 400 -315 ct
-425 -331 455 -339 489 -339 ct 528 -339 559 -331 584 -316 ct 608 -301 620 -278 620 -247 ct
-620 -247 620 -247 620 -56 ct 620 -50 621 -46 624 -42 ct 626 -39 631 -37 639 -37 ct
-641 -37 644 -37 647 -37 ct 650 -38 653 -38 657 -39 ct 657 -39 657 -39 657 1 ct
-648 4 642 5 637 6 ct 633 7 626 7 618 7 ct 599 7 585 0 576 -12 ct 572 -20 569 -30 567 -43 ct
-555 -28 539 -15 518 -4 ct 497 6 473 12 448 12 ct 417 12 392 3 372 -15 ct 353 -34 343 -57 343 -85 ct
-343 -116 353 -140 372 -157 ct 391 -174 416 -185 447 -189 ct p
-490 -339 m 490 -339 l p ef
-711 0 m 711 0 711 0 711 -332 ct 711 -332 711 -332 764 -332 ct 764 -332 764 -332 764 -275 ct
-768 -286 779 -299 796 -315 ct 813 -331 833 -339 855 -339 ct 856 -339 858 -339 860 -339 ct
-863 -338 867 -338 873 -337 ct 873 -337 873 -337 873 -279 ct 870 -280 867 -280 864 -281 ct
-861 -281 858 -281 855 -281 ct 826 -281 805 -272 790 -254 ct 775 -235 767 -214 767 -191 ct
-767 -191 767 -191 767 0 ct 767 0 767 0 711 0 ct p ef
-1039 -337 m 1065 -337 1088 -331 1108 -318 ct 1118 -311 1129 -301 1140 -287 ct
-1140 -287 1140 -287 1140 -328 ct 1140 -328 1140 -328 1190 -328 ct 1190 -328 1190 -328 1190 -26 ct
-1190 15 1184 48 1171 72 ct 1148 117 1105 140 1040 140 ct 1004 140 974 132 950 116 ct
-926 100 912 75 909 41 ct 909 41 909 41 967 41 ct 970 56 975 67 983 75 ct 996 88 1016 94 1043 94 ct
-1086 94 1114 79 1127 49 ct 1135 31 1139 0 1138 -46 ct 1127 -29 1113 -16 1097 -8 ct
-1082 0 1061 4 1035 4 ct 999 4 967 -8 940 -33 ct 913 -59 899 -101 899 -160 ct 899 -216 913 -259 940 -290 ct
-967 -321 1000 -337 1039 -337 ct p
-1139 -167 m 1139 -209 1131 -239 1114 -259 ct 1097 -279 1075 -289 1049 -289 ct
-1010 -289 983 -271 968 -234 ct 961 -214 957 -188 957 -156 ct 957 -119 965 -90 980 -70 ct
-995 -51 1015 -41 1041 -41 ct 1081 -41 1109 -59 1125 -95 ct 1134 -116 1139 -140 1139 -167 ct
-p
-1045 -339 m 1045 -339 l p ef
-1410 -339 m 1433 -339 1456 -333 1478 -322 ct 1500 -311 1516 -297 1528 -279 ct
-1539 -262 1546 -243 1550 -220 ct 1553 -205 1555 -180 1555 -147 ct 1555 -147 1555 -147 1314 -147 ct
-1315 -113 1323 -86 1338 -66 ct 1352 -45 1375 -35 1406 -35 ct 1435 -35 1458 -45 1475 -64 ct
-1484 -75 1491 -87 1495 -102 ct 1495 -102 1495 -102 1550 -102 ct 1549 -90 1544 -76 1536 -62 ct
-1527 -47 1518 -35 1508 -25 ct 1491 -9 1471 1 1446 7 ct 1433 10 1418 12 1401 12 ct
-1360 12 1325 -2 1297 -32 ct 1268 -62 1254 -105 1254 -159 ct 1254 -212 1268 -256 1297 -289 ct
-1326 -322 1363 -339 1410 -339 ct p
-1315 -191 m 1315 -191 1315 -191 1497 -191 ct 1495 -216 1490 -235 1481 -250 ct
-1466 -277 1441 -291 1406 -291 ct 1381 -291 1359 -282 1342 -263 ct 1325 -244 1316 -220 1315 -191 ct
-p
-1405 -339 m 1405 -339 l p ef
-1635 -332 m 1635 -332 1635 -332 1635 -424 ct 1635 -424 1635 -424 1691 -424 ct
-1691 -424 1691 -424 1691 -332 ct 1691 -332 1691 -332 1744 -332 ct 1744 -332 1744 -332 1744 -286 ct
-1744 -286 1744 -286 1691 -286 ct 1691 -286 1691 -286 1691 -70 ct 1691 -58 1695 -50 1703 -46 ct
-1707 -44 1714 -43 1724 -43 ct 1727 -43 1730 -43 1733 -43 ct 1736 -43 1740 -44 1744 -44 ct
-1744 -44 1744 -44 1744 0 ct 1738 2 1731 3 1724 4 ct 1717 5 1710 5 1702 5 ct 1676 5 1658 -1 1649 -14 ct
-1640 -27 1635 -45 1635 -66 ct 1635 -66 1635 -66 1635 -286 ct 1635 -286 1635 -286 1590 -286 ct
-1590 -286 1590 -286 1590 -332 ct 1590 -332 1590 -332 1635 -332 ct p ef
-pom
-gr
-gr
-[ 51 51 51 51 ] 0 ld
-4500 21000 m 11500 21000 l ps
-[ ] 0 ld
-9250 21000 m 9000 21000 l 9000 20500 l 9500 20500 l 9500 21000 l 9250 21000 l
-pc
-8447 18860 m 8482 18953 l 8517 19046 l 8553 19140 l 8541 19145 l 8528 19150 l
-8516 19154 l 8481 19061 l 8446 18967 l 8410 18873 l 8422 18869 l 8435 18864 l
-8447 18860 l p ef
-4553 20640 m 4518 20547 l 4483 20454 l 4447 20360 l 4459 20355 l 4472 20350 l
-4484 20346 l 4519 20439 l 4554 20533 l 4590 20627 l 4578 20631 l 4565 20636 l
-4553 20640 l p ef
-1 lw 0 lj 8470 19011 m 8421 19030 l ps
-8371 19048 m 8321 19067 l ps
-8272 19086 m 8222 19104 l ps
-8172 19123 m 8122 19142 l ps
-8073 19160 m 8023 19179 l ps
-7973 19198 m 7924 19216 l ps
-7874 19235 m 7824 19253 l ps
-7774 19272 m 7725 19291 l ps
-7675 19309 m 7625 19328 l ps
-7576 19347 m 7526 19365 l ps
-7476 19384 m 7426 19403 l ps
-7377 19421 m 7327 19440 l ps
-7277 19458 m 7228 19477 l ps
-7178 19496 m 7128 19514 l ps
-7079 19533 m 7029 19552 l ps
-6979 19570 m 6929 19589 l ps
-6880 19608 m 6830 19626 l ps
-6780 19645 m 6731 19664 l ps
-6681 19682 m 6631 19701 l ps
-6581 19719 m 6532 19738 l ps
-6482 19757 m 6432 19775 l ps
-6383 19794 m 6333 19813 l ps
-6283 19831 m 6233 19850 l ps
-6184 19869 m 6134 19887 l ps
-6084 19906 m 6035 19925 l ps
-5985 19943 m 5935 19962 l ps
-5885 19980 m 5836 19999 l ps
-5786 20018 m 5736 20036 l ps
-5687 20055 m 5637 20074 l ps
-5587 20092 m 5537 20111 l ps
-5488 20130 m 5438 20148 l ps
-5388 20167 m 5339 20186 l ps
-5289 20204 m 5239 20223 l ps
-5189 20241 m 5140 20260 l ps
-5090 20279 m 5040 20297 l ps
-4991 20316 m 4941 20335 l ps
-4891 20353 m 4842 20372 l ps
-4792 20391 m 4742 20409 l ps
-4692 20428 m 4643 20446 l ps
-4593 20465 m 4543 20484 l ps
-9500 13000 m 9650 13450 l 9350 13450 l 9500 13000 l p ef
-9500 22500 m 9500 13360 l ps
-0.753 0.753 0.753 c 9500 17500 m 10067 17500 10500 17933 10500 18500 ct 10500 19067 10067 19500 9500 19500 ct
-8933 19500 8500 19067 8500 18500 ct 8500 17933 8933 17500 9500 17500 ct p ef
-0 lw 1 lj 0.003 0.003 0.003 c 9500 17500 m 10067 17500 10500 17933 10500 18500 ct
-10500 19067 10067 19500 9500 19500 ct 8933 19500 8500 19067 8500 18500 ct 8500 17933 8933 17500 9500 17500 ct
-pc
-0.648 0.648 0.648 c 9175 18088 m 9235 18088 9282 18135 9282 18195 ct 9282 18255 9235 18302 9175 18302 ct
-9115 18302 9068 18255 9068 18195 ct 9068 18135 9115 18088 9175 18088 ct p ef
-0.003 0.003 0.003 c 9175 18088 m 9235 18088 9282 18135 9282 18195 ct 9282 18255 9235 18302 9175 18302 ct
-9115 18302 9068 18255 9068 18195 ct 9068 18135 9115 18088 9175 18088 ct pc
-0.648 0.648 0.648 c 9823 18088 m 9883 18088 9930 18135 9930 18195 ct 9930 18255 9883 18302 9823 18302 ct
-9763 18302 9716 18255 9716 18195 ct 9716 18135 9763 18088 9823 18088 ct p ef
-0.003 0.003 0.003 c 9823 18088 m 9883 18088 9930 18135 9930 18195 ct 9930 18255 9883 18302 9823 18302 ct
-9763 18302 9716 18255 9716 18195 ct 9716 18135 9763 18088 9823 18088 ct pc
-8951 18936 m 9304 19123 9696 19123 10049 18936 ct ps
-gs
-gs
-pum
-5252 19449 t
-121 -23 m 138 -23 152 -30 164 -45 ct 175 -60 181 -82 181 -111 ct 181 -129 178 -144 173 -157 ct
-164 -182 146 -194 121 -194 ct 95 -194 77 -181 68 -155 ct 63 -141 60 -123 60 -102 ct
-60 -85 63 -70 68 -58 ct 77 -35 95 -23 121 -23 ct p
-24 88 m 24 88 24 88 24 -220 ct 24 -220 24 -220 60 -220 ct 60 -220 60 -220 60 -191 ct
-67 -201 76 -208 84 -214 ct 97 -222 112 -226 129 -226 ct 154 -226 175 -216 193 -197 ct
-210 -178 219 -150 219 -114 ct 219 -66 206 -31 181 -11 ct 165 1 146 8 125 8 ct 108 8 94 4 83 -2 ct
-77 -6 69 -13 61 -23 ct 61 -23 61 -23 61 88 ct 61 88 61 88 24 88 ct p ef
-356 -226 m 372 -226 387 -222 401 -215 ct 416 -208 427 -198 435 -187 ct 442 -176 447 -163 450 -148 ct
-452 -138 453 -121 453 -98 ct 453 -98 453 -98 292 -98 ct 293 -75 298 -57 308 -44 ct
-318 -30 333 -23 354 -23 ct 373 -23 388 -29 400 -42 ct 406 -50 410 -58 413 -68 ct
-413 -68 413 -68 450 -68 ct 449 -60 446 -51 440 -41 ct 435 -31 429 -23 422 -17 ct
-411 -6 397 1 380 5 ct 372 7 361 8 350 8 ct 323 8 300 -1 281 -21 ct 262 -41 252 -69 252 -106 ct
-252 -141 262 -170 281 -193 ct 300 -215 325 -226 356 -226 ct p
-293 -129 m 293 -129 293 -129 415 -129 ct 414 -145 410 -158 405 -167 ct 394 -185 378 -194 354 -194 ct
-337 -194 323 -188 311 -176 ct 300 -163 294 -148 293 -129 ct p
-353 -226 m 353 -226 l p ef
-501 0 m 501 0 501 0 501 -220 ct 501 -220 501 -220 537 -220 ct 537 -220 537 -220 537 -184 ct
-540 -191 547 -200 559 -210 ct 570 -221 584 -226 599 -226 ct 599 -226 601 -226 602 -226 ct
-604 -226 607 -225 611 -225 ct 611 -225 611 -225 611 -187 ct 609 -187 607 -188 605 -188 ct
-603 -188 601 -188 598 -188 ct 579 -188 564 -182 554 -170 ct 543 -158 538 -144 538 -128 ct
-538 -128 538 -128 538 0 ct 538 0 538 0 501 0 ct p ef
-726 -226 m 751 -226 771 -220 787 -208 ct 802 -196 812 -175 815 -146 ct 815 -146 815 -146 779 -146 ct
-777 -160 772 -171 764 -180 ct 756 -189 744 -194 726 -194 ct 703 -194 686 -182 676 -159 ct
-669 -144 666 -126 666 -104 ct 666 -82 671 -63 680 -48 ct 689 -33 704 -25 724 -25 ct
-739 -25 751 -30 760 -39 ct 769 -49 776 -62 779 -78 ct 779 -78 779 -78 815 -78 ct
-811 -49 801 -27 784 -13 ct 768 0 747 6 721 6 ct 692 6 669 -4 652 -25 ct 635 -46 626 -72 626 -103 ct
-626 -142 635 -172 654 -194 ct 673 -215 697 -226 726 -226 ct p
-720 -226 m 720 -226 l p ef
-945 -226 m 961 -226 976 -222 990 -215 ct 1005 -208 1016 -198 1024 -187 ct 1031 -176 1036 -163 1039 -148 ct
-1041 -138 1042 -121 1042 -98 ct 1042 -98 1042 -98 881 -98 ct 882 -75 887 -57 897 -44 ct
-907 -30 922 -23 943 -23 ct 962 -23 977 -29 989 -42 ct 995 -50 999 -58 1002 -68 ct
-1002 -68 1002 -68 1039 -68 ct 1038 -60 1035 -51 1029 -41 ct 1024 -31 1018 -23 1011 -17 ct
-1000 -6 986 1 969 5 ct 961 7 950 8 939 8 ct 912 8 889 -1 870 -21 ct 851 -41 841 -69 841 -106 ct
-841 -141 851 -170 870 -193 ct 889 -215 914 -226 945 -226 ct p
-882 -129 m 882 -129 882 -129 1004 -129 ct 1003 -145 999 -158 994 -167 ct 983 -185 967 -194 943 -194 ct
-926 -194 912 -188 900 -176 ct 889 -163 883 -148 882 -129 ct p
-942 -226 m 942 -226 l p ef
-1184 -23 m 1201 -23 1215 -30 1227 -45 ct 1238 -60 1244 -82 1244 -111 ct 1244 -129 1241 -144 1236 -157 ct
-1227 -182 1209 -194 1184 -194 ct 1158 -194 1140 -181 1131 -155 ct 1126 -141 1123 -123 1123 -102 ct
-1123 -85 1126 -70 1131 -58 ct 1140 -35 1158 -23 1184 -23 ct p
-1087 88 m 1087 88 1087 88 1087 -220 ct 1087 -220 1087 -220 1123 -220 ct 1123 -220 1123 -220 1123 -191 ct
-1130 -201 1139 -208 1147 -214 ct 1160 -222 1175 -226 1192 -226 ct 1217 -226 1238 -216 1256 -197 ct
-1273 -178 1282 -150 1282 -114 ct 1282 -66 1269 -31 1244 -11 ct 1228 1 1209 8 1188 8 ct
-1171 8 1157 4 1146 -2 ct 1140 -6 1132 -13 1124 -23 ct 1124 -23 1124 -23 1124 88 ct
-1124 88 1124 88 1087 88 ct p ef
-1334 -220 m 1334 -220 1334 -220 1334 -281 ct 1334 -281 1334 -281 1371 -281 ct
-1371 -281 1371 -281 1371 -220 ct 1371 -220 1371 -220 1407 -220 ct 1407 -220 1407 -220 1407 -189 ct
-1407 -189 1407 -189 1371 -189 ct 1371 -189 1371 -189 1371 -46 ct 1371 -38 1374 -33 1379 -30 ct
-1382 -29 1387 -28 1394 -28 ct 1396 -28 1398 -28 1400 -28 ct 1402 -28 1404 -29 1407 -29 ct
-1407 -29 1407 -29 1407 0 ct 1403 1 1398 2 1394 3 ct 1389 4 1384 4 1379 4 ct 1361 4 1350 0 1343 -8 ct
-1337 -17 1334 -29 1334 -43 ct 1334 -43 1334 -43 1334 -189 ct 1334 -189 1334 -189 1304 -189 ct
-1304 -189 1304 -189 1304 -220 ct 1304 -220 1304 -220 1334 -220 ct p ef
-1445 0 m 1445 -220 l 1482 -220 l 1482 0 l 1445 0 l p
-1445 -261 m 1445 -303 l 1482 -303 l 1482 -261 l 1445 -261 l p ef
-1626 -23 m 1650 -23 1667 -32 1676 -51 ct 1685 -70 1690 -90 1690 -113 ct 1690 -134 1687 -151 1680 -163 ct
-1670 -184 1652 -194 1626 -194 ct 1603 -194 1587 -185 1576 -168 ct 1566 -151 1561 -130 1561 -105 ct
-1561 -82 1566 -62 1576 -47 ct 1587 -31 1603 -23 1626 -23 ct p
-1627 -226 m 1655 -226 1679 -217 1699 -198 ct 1718 -179 1728 -151 1728 -114 ct
-1728 -78 1719 -49 1702 -26 ct 1685 -3 1658 8 1622 8 ct 1592 8 1568 -1 1550 -22 ct
-1532 -42 1523 -70 1523 -104 ct 1523 -142 1532 -171 1551 -193 ct 1570 -215 1595 -226 1627 -226 ct
-p
-1626 -226 m 1626 -226 l p ef
-1775 0 m 1775 0 1775 0 1775 -220 ct 1775 -220 1775 -220 1811 -220 ct 1811 -220 1811 -220 1811 -190 ct
-1821 -203 1832 -212 1844 -218 ct 1856 -223 1869 -226 1883 -226 ct 1914 -226 1935 -215 1946 -193 ct
-1952 -181 1955 -164 1955 -141 ct 1955 -141 1955 -141 1955 0 ct 1955 0 1955 0 1918 0 ct
-1918 0 1918 0 1918 -139 ct 1918 -153 1916 -164 1912 -172 ct 1905 -186 1893 -193 1876 -193 ct
-1867 -193 1860 -192 1854 -190 ct 1844 -187 1835 -181 1827 -172 ct 1821 -165 1817 -157 1815 -149 ct
-1813 -141 1812 -130 1812 -116 ct 1812 -116 1812 -116 1812 0 ct 1812 0 1812 0 1775 0 ct
-p
-1862 -226 m 1862 -226 l p ef
-pom
-gr
-gr
-0.753 0.753 0.753 c 9500 11000 m 10501 12000 l 9500 13001 l 8500 12000 l
-9500 11000 l 9500 11000 l p ef
-0.003 0.003 0.003 c 9500 11000 m 10501 12000 l 9500 13001 l 8500 12000 l
-9500 11000 l 9500 11000 l pc
-0 11726 t
-pom
-count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat b4_inc_state restore
-%%PageTrailer
-%%Trailer
-%%EOF
Added: trunk/applications/jason-team/doc/roles/figures/jason-team-SS.dia
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jason-team/doc/roles/figures/jason-team-SS.dia
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/applications/jason-team/doc/roles/figures/jason-team-SS.eps
===================================================================
--- trunk/applications/jason-team/doc/roles/figures/jason-team-SS.eps 2008-04-25 20:05:54 UTC (rev 1261)
+++ trunk/applications/jason-team/doc/roles/figures/jason-team-SS.eps 2008-04-26 08:07:38 UTC (rev 1262)
@@ -1,6442 +0,0 @@
-%!PS-Adobe-2.0 EPSF-2.0
-%%Title: /media/JOMI/pubs/2008/agent-contest/proposal/figures/jason-team-SS.dia
-%%Creator: Dia v0.96.1
-%%CreationDate: Fri Mar 7 10:36:35 2008
-%%For: hubner
-%%Orientation: Portrait
-%%Magnification: 1.0000
-%%BoundingBox: 0 0 960 912
-%%BeginSetup
-%%EndSetup
-%%EndComments
-%%BeginProlog
-[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
-/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
-/two /three /four /five /six /seven /eight /nine /colon /semicolon
-/less /equal /greater /question /at /A /B /C /D /E
-/F /G /H /I /J /K /L /M /N /O
-/P /Q /R /S /T /U /V /W /X /Y
-/Z /bracketleft /backslash /bracketright /asciicircum /underscore /quoteleft /a /b /c
-/d /e /f /g /h /i /j /k /l /m
-/n /o /p /q /r /s /t /u /v /w
-/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/space /exclamdown /cent /sterling /currency /yen /brokenbar /section /dieresis /copyright
-/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior /threesuperior
-/acute /mu /paragraph /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright /onequarter /onehalf
-/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
-/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde
-/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash /Ugrave /Uacute /Ucircumflex
-/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring
-/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis
-/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave
-/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def
-/cp {closepath} bind def
-/c {curveto} bind def
-/f {fill} bind def
-/a {arc} bind def
-/ef {eofill} bind def
-/ex {ex...
[truncated message content] |
|
From: <jom...@us...> - 2008-04-26 11:54:33
|
Revision: 1263
http://jason.svn.sourceforge.net/jason/?rev=1263&view=rev
Author: jomifred
Date: 2008-04-26 04:54:31 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
fix bug in drop_desire
Modified Paths:
--------------
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/asl/moise-common.asl
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/link.java
trunk/applications/jason-team/src/java/jia/random.java
trunk/demos/tell-rule/rules/get_rules.java
trunk/examples/gold-miners-II/jia/random.java
trunk/examples/iterated-prisoners-dilemma/my/random.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/Intention.java
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/stdlib/drop_desire.java
trunk/src/jason/stdlib/drop_intention.java
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/asl/moise-common.asl
===================================================================
--- trunk/applications/jason-moise/src/asl/moise-common.asl 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/applications/jason-moise/src/asl/moise-common.asl 2008-04-26 11:54:31 UTC (rev 1263)
@@ -48,5 +48,9 @@
+goal_state(Sch, G[root], achieved)
: true | .print("achieved ",G) // just to avoid G as singleton var warning
<- jmoise.remove_mission(Sch).
-
-+error(M)[source(orgManager)] <- .print("Error in organisational action: ",M); -error(M).
+
+// if some scheme is finished, drop all intentions related to it.
+-scheme(_Spec,Id)
+ <- .drop_desire(X[scheme(Id)]).
+
++error(M)[source(orgManager)] <- .print("Error in organisational action: ",M); -error(M)[source(orgManager)].
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -13,6 +13,7 @@
import jason.asSyntax.Literal;
import jason.asSyntax.Pred;
import jason.asSyntax.PredicateIndicator;
+import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
import jason.asSyntax.UnnamedVar;
@@ -34,6 +35,8 @@
import moise.oe.OEAgent;
import moise.oe.Permission;
import moise.oe.SchemeInstance;
+import moise.os.fs.Goal;
+import moise.os.fs.Goal.GoalType;
/**
* Organisational Architecture, binds Jason agent to
@@ -187,9 +190,19 @@
alreadyGeneratedEvents.add(gi);
Literal l = Literal.parseLiteral(gi.getAsProlog());
- Literal giID = new Literal("scheme");
+ // add annot with scheme id
+ Structure giID = new Structure("scheme", 1);
giID.addTerm(new Atom(gi.getScheme().getId()));
l.addAnnot(giID);
+
+ // add annot with type of goal
+ Structure type = new Structure("type", 1);
+ type.addTerm(getGoalTypeAtom(gi.getSpec()));
+ l.addAnnot(type);
+
+ // add source annot
+ l.addAnnot(managerSource);
+
// "role(notimplemented),group(notimplemented)"+
// TODO: add annots: role, group (percorrer as missoes do ag que
// em GI, procurar os papel com obrigacao para essa missao)
@@ -198,6 +211,17 @@
}
}
}
+
+ private static final Atom aAchievementGoal = new Atom(GoalType.achievement.toString());
+ private static final Atom aMaintenanceGoal = new Atom(GoalType.maintenance.toString());
+
+ public static Atom getGoalTypeAtom(Goal g) {
+ switch (g.getType()) {
+ case achievement: return aAchievementGoal;
+ case maintenance: return aMaintenanceGoal;
+ }
+ return null;
+ }
void removeAchieveEvents(String schId) {
Iterator<GoalInstance> i = alreadyGeneratedEvents.iterator();
Modified: trunk/applications/jason-moise/src/jmoise/link.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/link.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/applications/jason-moise/src/jmoise/link.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -75,7 +75,7 @@
gr = rp.getGroup();
}
for (OEAgent ag: currentOE.getAgents( gr, link.getTarget())) { // all agents of the target role
- Unifier c = (Unifier)un.clone();
+ Unifier c = un.copy();
// unifies the type and target
if (c.unifies(args[0], new Atom(link.getTypeStr())) &&
Modified: trunk/applications/jason-team/src/java/jia/random.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/random.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/applications/jason-team/src/java/jia/random.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -38,7 +38,7 @@
public Unifier next() {
i++;
- Unifier c = (Unifier)un.clone();
+ Unifier c = un.copy();
c.unifies(args[0], new NumberTermImpl(random.nextInt(max)));
return c;
}
Modified: trunk/demos/tell-rule/rules/get_rules.java
===================================================================
--- trunk/demos/tell-rule/rules/get_rules.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/demos/tell-rule/rules/get_rules.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -27,8 +27,7 @@
while (i.hasNext()) {
Literal l = i.next();
if (l.isRule()) {
- Unifier unc = (Unifier)un.clone();
- if (unc.unifies(pattern, l)) {
+ if (un.copy().unifies(pattern, l)) {
l = (Literal)l.clone();
l.delSources();
result.add(new StringTermImpl(l.toString()));
Modified: trunk/examples/gold-miners-II/jia/random.java
===================================================================
--- trunk/examples/gold-miners-II/jia/random.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/examples/gold-miners-II/jia/random.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -38,7 +38,7 @@
public Unifier next() {
i++;
- Unifier c = (Unifier)un.clone();
+ Unifier c = un.copy();
c.unifies(args[0], new NumberTermImpl(random.nextInt(max)));
return c;
}
Modified: trunk/examples/iterated-prisoners-dilemma/my/random.java
===================================================================
--- trunk/examples/iterated-prisoners-dilemma/my/random.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/examples/iterated-prisoners-dilemma/my/random.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -35,7 +35,7 @@
}
public Unifier next() {
- Unifier c = (Unifier)un.clone();
+ Unifier c = un.copy();
c.unifies(args[0], new NumberTermImpl(random.nextInt(max)));
return c;
}
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/src/jason/asSemantics/Agent.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -649,7 +649,7 @@
Literal inBB = il.next();
if (!inBB.isRule()) {
// need to clone unifier since it is changed in previous iteration
- Unifier unC = (un == null ? new Unifier() : (Unifier)un.clone());
+ Unifier unC = (un == null ? new Unifier() : un.copy());
if (unC.unifiesNoUndo(bel, inBB)) {
toDel.add(inBB);
}
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -126,7 +126,7 @@
public Object clone() {
IntendedMeans c = new IntendedMeans();
- c.unif = (Unifier)this.unif.clone();
+ c.unif = this.unif.copy();
c.plan = (Plan)this.plan.clone();
c.trigger = (Trigger)this.trigger.clone();
return c;
Modified: trunk/src/jason/asSemantics/Intention.java
===================================================================
--- trunk/src/jason/asSemantics/Intention.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/src/jason/asSemantics/Intention.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -130,6 +130,7 @@
/** returns the IntendedMeans with TE = g, returns null if there isn't one */
public IntendedMeans getIM(Trigger g, Unifier u) {
for (IntendedMeans im : intendedMeans) {
+ //System.out.println(g + " = "+ im.getTrigger()+" = "+u.unifies(g, im.getTrigger()));
if (u.unifies(g, im.getTrigger())) {
return im;
}
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -348,6 +348,11 @@
}
}
+ /** same as clone but with typed return */
+ public Unifier copy() {
+ return (Unifier)clone();
+ }
+
public boolean equals(Object o) {
if (o == null) return false;
if (o == this) return true;
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/src/jason/asSyntax/Literal.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -166,7 +166,7 @@
Literal rhead = rule.headClone();
rhead.apply(ruleUn);
- Unifier unC = (Unifier) un.clone();
+ Unifier unC = un.copy();
if (unC.unifiesNoUndo(Literal.this, rhead)) {
current = unC;
return;
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/src/jason/asSyntax/Structure.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -76,8 +76,12 @@
setSrc(t);
}
- /** to be used by list term and atom to not create the array list for terms */
- protected Structure(String functor, int termsSize) {
+ /**
+ * Create a structure with a defined number of terms.
+ *
+ * It is used by list term and atom to not create the array list for terms.
+ */
+ public Structure(String functor, int termsSize) {
//this.functor = (functor == null ? null : functor.intern());
if (functor == null)
logger.log(Level.WARNING, "A structure functor should not be null!", new Exception());
Modified: trunk/src/jason/stdlib/drop_desire.java
===================================================================
--- trunk/src/jason/stdlib/drop_desire.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/src/jason/stdlib/drop_desire.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -94,7 +94,7 @@
t = (Trigger) t.clone();
t.apply(ei.getIntention().peek().getUnif());
}
- if (un.unifies(t, te)) {
+ if (un.copy().unifiesNoUndo(t, te)) {
// old implementation: t.setTrigType(Trigger.TEDel); // Just changing "+!g" to "-!g"
ie.remove();
}
Modified: trunk/src/jason/stdlib/drop_intention.java
===================================================================
--- trunk/src/jason/stdlib/drop_intention.java 2008-04-26 08:07:38 UTC (rev 1262)
+++ trunk/src/jason/stdlib/drop_intention.java 2008-04-26 11:54:31 UTC (rev 1263)
@@ -84,7 +84,7 @@
Trigger g = new Trigger(TEOperator.add, TEType.achieve, l);
for (Intention i: C.getIntentions()) {
- if (i.hasTrigger(g, un)) {
+ if (i.hasTrigger(g, un.copy())) {
C.removeIntention(i);
}
}
@@ -92,7 +92,7 @@
// intention may be suspended in E
for (Event e: C.getEvents()) {
Intention i = e.getIntention();
- if (i != null && i.hasTrigger(g, un)) {
+ if (i != null && i.hasTrigger(g, un.copy())) {
C.removeEvent(e);
}
}
@@ -100,14 +100,14 @@
// intention may be suspended in PA! (in the new semantics)
for (ActionExec a: C.getPendingActions().values()) {
Intention i = a.getIntention();
- if (i.hasTrigger(g, un)) {
+ if (i.hasTrigger(g, un.copy())) {
C.dropPendingAction(i);
}
}
// intention may be suspended in PI! (in the new semantics)
for (Intention i: C.getPendingIntentions().values()) {
- if (i != null && i.hasTrigger(g, un)) {
+ if (i != null && i.hasTrigger(g, un.copy())) {
C.dropPendingIntention(i);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-26 14:12:33
|
Revision: 1264
http://jason.svn.sourceforge.net/jason/?rev=1264&view=rev
Author: jomifred
Date: 2008-04-26 07:12:31 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
jason team: add org. goals (with no code) in the code of the agents
Modified Paths:
--------------
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/asl/moise-common.asl
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
trunk/applications/jason-team/src/team-os.xml
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/environment/grid/Location.java
trunk/src/test/VarTermTest.java
Added Paths:
-----------
trunk/applications/jason-team/src/java/jia/near_least_visited.java
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/asl/moise-common.asl
===================================================================
--- trunk/applications/jason-moise/src/asl/moise-common.asl 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-moise/src/asl/moise-common.asl 2008-04-26 14:12:31 UTC (rev 1264)
@@ -51,6 +51,6 @@
// if some scheme is finished, drop all intentions related to it.
-scheme(_Spec,Id)
- <- .drop_desire(X[scheme(Id)]).
+ <- .drop_desire(_[scheme(Id)]).
+error(M)[source(orgManager)] <- .print("Error in organisational action: ",M); -error(M)[source(orgManager)].
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-04-26 14:12:31 UTC (rev 1264)
@@ -103,6 +103,7 @@
addCommand(new SetGoalState());
addCommand(new SetGoalArg());
addCommand(new RemoveScheme());
+ addCommand(new AbortScheme());
addCommand(new AddAgent());
}
@@ -428,13 +429,24 @@
sendReply(sender, mId, "error(\"you are not the owner of the scheme " + schId + ", so you can not change it\")");
}
- currentOE.finishScheme(sch);
-
+ act(currentOE, sch);
// send untell to agents
updateMembersOE(currentOE.getAgents(), "scheme(" + sch.getSpec().getId() + "," + sch.getId() + ")[owner(" + sch.getOwner() + ")]", false, false);
}
+ protected void act(OE currentOE, SchemeInstance sch) throws MoiseException {
+ currentOE.finishScheme(sch);
+ }
}
+ class AbortScheme extends RemoveScheme {
+ public String getId() {
+ return "abort_scheme";
+ }
+ protected void act(OE currentOE, SchemeInstance sch) throws MoiseException {
+ currentOE.abortScheme(sch);
+ }
+ }
+
class SetGoalState implements OrgManagerCommand {
public String getId() {
return "set_goal_state";
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-04-26 14:12:31 UTC (rev 1264)
@@ -1,5 +1,13 @@
/* -- plans for exploration phase -- */
+
+/* -- initial beliefs -- */
+
+// missions I can commit to
+desired_mission(exploring, mexplorer).
+desired_mission(exploring, mscouter).
+
+
/* -- initial goals -- */
//!test.
@@ -34,8 +42,9 @@
X = math.round(((W*H)/3)/H);
+group_area(0, G1, area(0, 0, X, H-1));
+group_area(1, G2, area(X+1, 0, W-1, H/2));
- +group_area(2, G3, area(X+1, (H/2)+1, W-1, H-1)).
+ +group_area(2, G3, area(X+1, (H/2)+1, W-1, H-1)).
+
+group_area(ID,G,A)[source(self)]
<- .broadcast(tell, group_area(ID,G,A)).
@@ -81,8 +90,55 @@
<- .print("ooo find_scouter failure, try another agent.");
!find_scouter(LSOdd,GId).
+// If if start playing explorer in a group that has no scheme, create the scheme
++play(Ag,explorer,G)
+ : .my_name(Ag) &
+ not scheme_group(_,G)
+ <- jmoise.create_scheme(exploring, [G]).
+
-/* plans for agents the others */
+/* plans for the others */
-+!play_role(Role,Group)
- <- jmoise.adopt_role(Role,Group).
++!play_role(Role,Group)[source(Ag)]
+ <- .print("ooo Adopting role ",Role,", asked by ",Ag);
+ jmoise.adopt_role(Role,Group).
+
+
+/* -- plans for the goals of role explorer -- */
+
+// TODO: make a pattern for organisational maintainance goal
+
++!goto_near_unvisited[scheme(Sch)]
+ <- .print("ooo I should find the near unvisited location and go there!");
+ .my_name(Me);
+ ?play(Me,explorer,GroupId); // get the group where I play explorer
+ ?group_area(_,GroupId, Area); // get the area of this group
+ ?pos(MeX, MeY, _); // get my location
+ jia.near_least_visited(MeX, MeY, Area, TargetX, TargetY);
+ -+target(TargetX, TargetY);
+ .wait("+pos(_,_,_)"); // wait next cycle
+ !!goto_near_unvisited[scheme(Sch)].
+
+-!goto_near_unvisited[scheme(Sch)]
+ <- .current_intention(I);
+ .print("ooo Failure to goto_near_unvisited ",I);
+ .wait("+pos(_,_,_)"); // wait next cycle
+ !!goto_near_unvisited[scheme(Sch)].
+
+
+/* -- plans for the goals of role scouter -- */
+
++!follow_leader[scheme(Sch)]
+ <- .print("ooo I should follow the leader!");
+ // TODO:
+ .wait("+pos(_,_,_)"); // wait next cycle
+ !!follow_leader[scheme(Sch)].
+
+/* -- plans for the goals of all roles -- */
+
++!share_cows[scheme(Sch)]
+ <- .print("ooo I should share cows!");
+ // TODO:
+ .wait("+pos(_,_,_)"); // wait next cycle
+ !!share_cows[scheme(Sch)].
+
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-26 14:12:31 UTC (rev 1264)
@@ -32,9 +32,6 @@
/* -- plans -- */
-+pos(_,_,_) <- do(skip).
-
-
+?pos(X, Y, S) <- .wait("+pos(X,Y,S)").
+?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-04-26 14:12:31 UTC (rev 1264)
@@ -1 +1,35 @@
/* -- plans for herding phase -- */
+
+/* -- initial beliefs -- */
+
+// missions I can commit to
+desired_mission(exploring, mherder).
+desired_mission(exploring, mherdboy).
+
+
+/* -- plans for the goals of role herder -- */
+
++!recruit[scheme(Sch)]
+ <- .print("ooo I should revise the size of the cluster and recruit!");
+ // TODO
+ .wait("+pos(_,_,_)"); // wait next cycle
+ !!recruit[scheme(Sch)].
+
+
++!define_formation[scheme(Sch)]
+ <- .print("ooo I should define the formation of my group!");
+ jia.herd_position(2,L); // formation in two (TODO: get the number of players in the group or scheme)
+ .print("ooo formation is ",L);
+ // TODO: allocate and share the formation
+ .wait("+pos(_,_,_)"); // wait next cycle
+ !!define_formation[scheme(Sch)].
+
+
+/* -- plans for the goals of all roles (herder and herdboy) -- */
+
++!be_in_formation[scheme(Sch)]
+ <- .print("ooo I should be in formation!");
+ // TODO
+ .wait("+pos(_,_,_)"); // wait next cycle
+ !!be_in_formation[scheme(Sch)].
+
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-04-26 14:12:31 UTC (rev 1264)
@@ -185,10 +185,7 @@
}
/** returns the near location of x,y that was least visited */
- public Location getNearLeastVisited(int agx, int agy) {
- //int distanceToBorder = (agx < getWidth()/2 ? agx : getWidth() - agx) - 1;
- Location agloc = new Location(agx,agy);
-
+ public Location getNearLeastVisited(Location agloc, Location tr, Location bl) {
/*
logger.info("------");
for (int i = 0; i < getWidth(); i++) {
@@ -203,8 +200,8 @@
//int visitedTarget = 0;
while (true) {
- int x = agx;
- int y = agy;
+ int x = agloc.x;
+ int y = agloc.y;
int w = 1;
int dx = 0;
int dy = 0;
@@ -217,13 +214,13 @@
dx++;
break;
} else {
- stage = 2;//(x % 2 == 0) ? 2 : 3;
+ stage = 2;
}
case 2: if (dy < w) {
dy++;
break;
} else {
- stage = 3;//(x % 2 == 0) ? 3 : 1;
+ stage = 3;
}
case 3: if (dx > 0) {
dx--;
@@ -243,7 +240,7 @@
}
Location l = new Location(x+dx,y+dy);
- if (isFree(l) && !l.equals(agloc)) {
+ if (isFree(l) && !l.equals(agloc) && l.isInArea(tr, bl)) {
if (visited[l.x][l.y] < minVisited) { // a place better then minVisited! go there
return l;
} if (visited[l.x][l.y] == minVisited) { // a place in the minVisited level
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-26 14:12:31 UTC (rev 1264)
@@ -3,7 +3,11 @@
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.ListTermImpl;
+import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
+import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.environment.grid.Location;
@@ -18,6 +22,11 @@
/**
* Gives a good location to herd cows
+ *
+ * the first argument is the formation id (one, two, ... 1, 2, ....)
+ *
+ * if it is called with 3 args, returns the a free location in the formation
+ * otherwise return a list of location for the formation
*
* @author jomi
*/
@@ -26,32 +35,62 @@
public static final double maxStdDev = 3;
public enum Formation {
- one { int[] getDistances() { return new int[] { 0 }; } },
- six { int[] getDistances() { return new int[] { 2, -2, 6, -6, 10, -10 }; } };
+ one { int[] getDistances() { return new int[] { 0 }; } },
+ two { int[] getDistances() { return new int[] { 2, -2 }; } },
+ three { int[] getDistances() { return new int[] { 0, 4, -4 }; } },
+ four { int[] getDistances() { return new int[] { 2, -2, 6, -6 }; } },
+ five { int[] getDistances() { return new int[] { 0, 4, -4, 8, -8 }; } },
+ six { int[] getDistances() { return new int[] { 2, -2, 6, -6, 10, -10 }; } };
abstract int[] getDistances();
};
@Override
- public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
CowboyArch arch = (CowboyArch)ts.getUserAgArch();
LocalWorldModel model = arch.getModel();
if (model == null)
return false;
-
Location agLoc = model.getAgPos(arch.getMyId());
+ // identify the formation id
+ Formation formation = Formation.six;
+ if (args[0].isNumeric()) {
+ int index = (int)((NumberTerm)args[0]).solve();
+ formation = Formation.values()[ index-1 ];
+ } else {
+ formation = Formation.valueOf(args[0].toString());
+ }
+
// update GUI
if (arch.hasGUI())
- setFormationLoc(model, Formation.valueOf(terms[0].toString()));
+ setFormationLoc(model, formation);
- Location agTarget = getAgTarget(model, Formation.valueOf(terms[0].toString()), agLoc);
- if (agTarget != null) {
- agTarget = nearFreeForAg(model, agLoc, agTarget);
- return un.unifies(terms[1], new NumberTermImpl(agTarget.x)) &&
- un.unifies(terms[2], new NumberTermImpl(agTarget.y));
+ // if the return is a location for one agent
+ if (args.length == 3) {
+ Location agTarget = getAgTarget(model, formation, agLoc);
+ if (agTarget != null) {
+ return un.unifies(args[1], new NumberTermImpl(agTarget.x)) &&
+ un.unifies(args[2], new NumberTermImpl(agTarget.y));
+ } else {
+ ts.getLogger().info("No target! I am at "+agLoc+" places are "+formationPlaces(model, formation));
+ }
} else {
- ts.getLogger().info("No target! I am at "+agLoc+" places are "+formationPlaces(model, Formation.valueOf(terms[0].toString())));
+ // return all the locations for the formation
+ List<Location> locs = formationPlaces(model, formation);
+ if (locs != null) {
+ ListTerm r = new ListTermImpl();
+ ListTerm tail = r;
+ for (Location l: locs) {
+ Structure p = new Structure("pos",2);
+ p.addTerm(new NumberTermImpl(l.x));
+ p.addTerm(new NumberTermImpl(l.y));
+ tail = tail.append(p);
+ }
+ return un.unifies(args[1], r);
+ } else {
+ ts.getLogger().info("No formation possible! I am at "+agLoc+" places are "+formationPlaces(model, formation));
+ }
}
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "herd_position error: "+e, e);
@@ -66,11 +105,13 @@
for (Location l : locs) {
r = l;
if (ag.equals(l) || // I am there
- model.countObjInArea(WorldModel.AGENT, l, 1) == 0) { // no one else is there
+ !model.hasObject(WorldModel.AGENT, l)) { // no one else is there
break;
}
}
}
+ if (r != null)
+ r = model.nearFree(r);
return r;
}
@@ -125,7 +166,7 @@
for (int agTargetSize = initAgTS; agTargetSize <= Math.abs(dist); agTargetSize++) {
l = agTarget.newMagnitude(agTargetSize).add(mean).add(agsTarget).getLocation(model);
//System.out.println("pos angle "+agTargetSize);
- uselast = !model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l) && lastloc != null;
+ uselast = (!model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l)) && lastloc != null;
if (uselast) {
r.add(pathToNearCow(model, lastloc));
break;
@@ -160,8 +201,8 @@
return t;
}
+ /*
public Location nearFreeForAg(LocalWorldModel model, Location ag, Location t) throws Exception {
- /*
// run A* to get the path from ag to t
if (! model.inGrid(t))
t = model.nearFree(t);
@@ -179,8 +220,8 @@
if (i++ > 3) // do not go to far from target
break;
}
- */
return model.nearFree(t);
}
+ */
}
Added: trunk/applications/jason-team/src/java/jia/near_least_visited.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/near_least_visited.java (rev 0)
+++ trunk/applications/jason-team/src/java/jia/near_least_visited.java 2008-04-26 14:12:31 UTC (rev 1264)
@@ -0,0 +1,59 @@
+package jia;
+
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.NumberTerm;
+import jason.asSyntax.NumberTermImpl;
+import jason.asSyntax.Structure;
+import jason.asSyntax.Term;
+import jason.environment.grid.Location;
+
+import java.util.logging.Level;
+
+import arch.CowboyArch;
+import arch.LocalWorldModel;
+
+/**
+ * Gets the near least visited location for a location (args 0 and 1) inside an area (arg 2).
+ *
+ * Example: jia.near_least_visited(10,10,area(0,0,20,30),X,Y).
+ *
+ * Its is based on the agent's model of the world.
+ *
+ * @author jomi
+ */
+public class near_least_visited extends DefaultInternalAction {
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ LocalWorldModel model = ((CowboyArch)ts.getUserAgArch()).getModel();
+ if (model == null) {
+ ts.getLogger().log(Level.SEVERE, "no model to get near_least_visited!");
+ } else {
+ int agx = (int)((NumberTerm)args[0]).solve();
+ int agy = (int)((NumberTerm)args[1]).solve();
+ Location ag = new Location(agx, agy);
+
+ Structure sarea = (Structure)args[2];
+ int ax1 = (int)((NumberTerm)sarea.getTerm(0)).solve();
+ int ay1 = (int)((NumberTerm)sarea.getTerm(1)).solve();
+ int ax2 = (int)((NumberTerm)sarea.getTerm(2)).solve();
+ int ay2 = (int)((NumberTerm)sarea.getTerm(3)).solve();
+
+ Location tr = new Location(ax1, ay1);
+ Location bl = new Location(ax2, ay2);
+
+ Location n = model.getNearLeastVisited(ag, tr, bl);
+ un.unifies(args[3], new NumberTermImpl(n.x));
+ un.unifies(args[4], new NumberTermImpl(n.y));
+ //ts.getLogger().info("at "+agx+","+agy+" to "+n.x+","+n.y);
+ return true;
+ }
+ } catch (Throwable e) {
+ ts.getLogger().log(Level.SEVERE, "near_least_visited error: "+e, e);
+ }
+ return false;
+ }
+}
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-26 14:12:31 UTC (rev 1264)
@@ -170,7 +170,6 @@
scenario2();
model.add(WorldModel.ENEMY, 11,48);
Location byIA = new herd_position().getAgTarget(model, Formation.one, cowboy.getLocation(model));
- byIA = new herd_position().nearFreeForAg(model, new Location(11,46), byIA);
assertEquals(new Location(11,49), byIA);
}
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/applications/jason-team/src/team-os.xml 2008-04-26 14:12:31 UTC (rev 1264)
@@ -107,8 +107,8 @@
</functional-specification>
<deontic-specification>
- <deontic-relation type="obligation" role="explorer" mission="mscouter" />
- <deontic-relation type="obligation" role="scouter" mission="mexplorer" />
+ <deontic-relation type="obligation" role="explorer" mission="mexplorer" />
+ <deontic-relation type="obligation" role="scouter" mission="mscouter" />
<deontic-relation type="obligation" role="herder" mission="mherder" />
<deontic-relation type="obligation" role="herdboy" mission="mherdboy" />
</deontic-specification>
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-04-26 14:12:31 UTC (rev 1264)
@@ -368,9 +368,12 @@
@Override
public void countVars(Map<VarTerm, Integer> c) {
- if (isVar()) {
- int n = c.containsKey(this) ? c.get(this) : 0;
- c.put(this, n+1);
+ if (value == null) {
+ int n = c.containsKey(this) ? c.get(this) : 0;
+ c.put(this, n+1);
+ super.countVars(c);
+ } else {
+ value.countVars(c);
}
}
Modified: trunk/src/jason/environment/grid/Location.java
===================================================================
--- trunk/src/jason/environment/grid/Location.java 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/src/jason/environment/grid/Location.java 2008-04-26 14:12:31 UTC (rev 1264)
@@ -23,7 +23,10 @@
return Math.max( Math.abs(this.x - l.x) , Math.abs(this.y - l.y));
}
- public boolean isNeigbour(Location l) {
+ public boolean isInArea(Location tr, Location bl) {
+ return x >= tr.x && x <= bl.x && y >= tr.y && y <= bl.y;
+ }
+ public boolean isNeigbour(Location l) {
return
distance(l) == 1 ||
equals(l) ||
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-04-26 11:54:31 UTC (rev 1263)
+++ trunk/src/test/VarTermTest.java 2008-04-26 14:12:31 UTC (rev 1264)
@@ -23,7 +23,9 @@
import jason.infra.centralised.CentralisedAgArch;
import java.io.StringReader;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import junit.framework.TestCase;
@@ -443,6 +445,13 @@
assertFalse(v.isGround());
}
+ public void testUnamedVarAnnots() {
+ Term t = DefaultTerm.parse("_[scheme(Id)]");
+ Map<VarTerm,Integer> c = new HashMap<VarTerm, Integer>();
+ t.countVars(c);
+ assertEquals(1,c.get(new VarTerm("Id")).intValue());
+ }
+
public void testUnifClone() {
VarTerm x1 = new VarTerm("X");
VarTerm x2 = new VarTerm("X");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-27 18:25:32
|
Revision: 1275
http://jason.svn.sourceforge.net/jason/?rev=1275&view=rev
Author: jomifred
Date: 2008-04-27 11:25:28 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
add a constant to define the distance between agents in a formation
Modified Paths:
--------------
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/src/jason/stdlib/wait.java
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-27 18:11:57 UTC (rev 1274)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-27 18:25:28 UTC (rev 1275)
@@ -33,15 +33,18 @@
public class herd_position extends DefaultInternalAction {
public static final double maxStdDev = 3;
+ public static final int agDistanceInFormation = 4;
public enum Formation {
one { int[] getDistances() { return new int[] { 0 }; } },
- two { int[] getDistances() { return new int[] { 2, -2 }; } },
- three { int[] getDistances() { return new int[] { 0, 4, -4 }; } },
- four { int[] getDistances() { return new int[] { 2, -2, 6, -6 }; } },
- five { int[] getDistances() { return new int[] { 0, 4, -4, 8, -8 }; } },
- six { int[] getDistances() { return new int[] { 2, -2, 6, -6, 10, -10 }; } };
+ two { int[] getDistances() { return new int[] { sd, -sd }; } },
+ three { int[] getDistances() { return new int[] { 0, d, -d }; } },
+ four { int[] getDistances() { return new int[] { sd, -sd, d+sd, -(d+sd) }; } },
+ five { int[] getDistances() { return new int[] { 0, d, -d, d*2, -d*2 }; } },
+ six { int[] getDistances() { return new int[] { sd, -sd, d+sd, -(d+sd), d*2+sd, -(d*2+sd) }; } };
abstract int[] getDistances();
+ private static final int d = agDistanceInFormation;
+ private static final int sd = agDistanceInFormation/2;
};
@Override
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-04-27 18:11:57 UTC (rev 1274)
+++ trunk/src/jason/stdlib/wait.java 2008-04-27 18:25:28 UTC (rev 1275)
@@ -54,7 +54,7 @@
<code>"+!go(X,Y)"</code>.
Although the argument is a string, the variables
- in the string will be unified with the event, i.e., the unifier have
+ in the string will be unified with the event, i.e., the unifier might have
values for X and Y after the execution of <code>.wait("+!go(X,Y)")</code>.
<p>Parameters:<ul>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-01 21:29:40
|
Revision: 1282
http://jason.svn.sourceforge.net/jason/?rev=1282&view=rev
Author: jomifred
Date: 2008-05-01 14:29:36 -0700 (Thu, 01 May 2008)
Log Message:
-----------
several changes in jason team
fix bug in BUF (no source was added in del bel)
fix bug in clone of unnamed vars
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/asl/moise-common.asl
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-team/AC-Local-Dummies.mas2j
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/java/agent/SelectEvent.java
trunk/applications/jason-team/src/java/arch/ACArchitecture.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
trunk/applications/jason-team/src/java/jia/Search.java
trunk/applications/jason-team/src/java/jia/direction.java
trunk/applications/jason-team/src/java/jia/near_least_visited.java
trunk/applications/jason-team/src/java/test/MindView.java
trunk/applications/jason-team/src/team-os.xml
trunk/release-notes.txt
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/Circumstance.java
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/stdlib/drop_intention.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -20,9 +20,9 @@
"p(1,a). p(2,a). p(3,b). p(4,b). p(6,a). "+
"+!test1 <- .while( .count(b(_),N) & N < 4, {+b(N+1) })."+
- "+!test2 <- L=4; .while( .count(b(_)) < L, { ?b(X); +b(X+1) }); jason.asunit.print(end). "+
+ "+!test2 <- L=4; .while( .count(b(_)) < L { ?b(X); +b(X+1) }); jason.asunit.print(end). "+
- "+!test3 <- L=4; .for( p(N,a) & N < L, { jason.asunit.print(N) }); jason.asunit.print(end). "+
+ "+!test3 <- L=4; .for( p(N,a) & N < L { jason.asunit.print(N) }); jason.asunit.print(end). "+
"+!test4 <- .for( .member(N, [1,3,4]), { jason.asunit.print(N) }); jason.asunit.print(end). "
);
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/asl/moise-common.asl
===================================================================
--- trunk/applications/jason-moise/src/asl/moise-common.asl 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-moise/src/asl/moise-common.asl 2008-05-01 21:29:36 UTC (rev 1282)
@@ -45,8 +45,7 @@
// when the root goal of the scheme is achieved,
// remove my missions
-+goal_state(Sch, G[root], achieved)
- : true | .print("achieved ",G) // just to avoid G as singleton var warning
++goal_state(Sch, _[root], achieved)
<- jmoise.remove_mission(Sch).
// if some scheme is finished, drop all intentions related to it.
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -23,8 +23,10 @@
import jason.mas2j.ClassParameters;
import jason.runtime.Settings;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -98,8 +100,9 @@
i.remove();
} else if (m.getSender().equals(getOrgManagerName())) {
// the content is a normal predicate
- final String content = m.getPropCont().toString();
- final boolean isTell = m.getIlForce().equals("tell");
+ final String content = m.getPropCont().toString();
+ final boolean isTell = m.getIlForce().equals("tell");
+ final boolean isUntell = m.getIlForce().equals("untell");
if (isTell && content.startsWith("scheme(")) {
i.remove();
addAsBel(content);
@@ -113,12 +116,18 @@
i.remove();
updateGoalBels(Pred.parsePred(content));
updateGoalEvt = true;
- } else if (isTell && content.startsWith("scheme_group")) {
+ } else if (content.startsWith("scheme_group")) {
i.remove();
- // this message is generated when my group becomes
- // responsible for a scheme
- Literal l = addAsBel(content);
- generateObligationPermissionEvents(l);
+ if (isTell) {
+ // this message is generated when my group becomes
+ // responsible for a scheme
+ Literal l = addAsBel(content);
+ generateObligationPermissionEvents(l);
+ } else if (isUntell) {
+ Literal l = delAsBel(content);
+ removeObligationPermissionBeliefs(l, "obligation");
+ removeObligationPermissionBeliefs(l, "permission");
+ }
} else if (isTell && content.startsWith("commitment")) {
i.remove();
addAsBel(content);
@@ -127,7 +136,7 @@
} else if (m.getIlForce().equals("untell") && content.startsWith("scheme")) {
String schId = Pred.parsePred(content).getTerm(1).toString();
- removeAchieveEvents(schId);
+ removeAchieveGoalsOfSch(schId);
removeBeliefs(schId);
}
}
@@ -152,8 +161,14 @@
getTS().getAg().addBel(l);
return l;
}
+ private Literal delAsBel(String b) throws RevisionFailedException {
+ Literal l = Literal.parseLiteral(b);
+ l.addAnnot(managerSource);
+ getTS().getAg().delBel(l);
+ return l;
+ }
- void generateObligationPermissionEvents(Pred m) throws RevisionFailedException {
+ private void generateObligationPermissionEvents(Pred m) throws RevisionFailedException {
// computes this agent obligations in the scheme
String schId = m.getTerm(0).toString();
String grId = m.getTerm(1).toString();
@@ -166,7 +181,7 @@
obligations.add(p);
Literal l = Literal.parseLiteral("obligation(" + p.getScheme().getId() + ","
+ p.getMission().getId() + ")[" + "role(" + p.getRolePlayer().getRole().getId()
- + "),group(" + p.getRolePlayer().getGroup().getGrSpec().getId() + ")]");
+ + "),group(" + p.getRolePlayer().getGroup().getId() + ")]");
l.addAnnot(managerSource);
getTS().getAg().addBel(l);
if (logger.isLoggable(Level.FINE)) logger.fine("New obligation: " + l);
@@ -178,15 +193,45 @@
if (p.getRolePlayer().getGroup().getId().equals(grId) && p.getScheme().getId().equals(schId) && !obligations.contains(p)) {
Literal l = Literal.parseLiteral("permission(" + p.getScheme().getId() + ","
+ p.getMission().getId() + ")[" + "role(" + p.getRolePlayer().getRole().getId()
- + "),group(" + p.getRolePlayer().getGroup().getGrSpec().getId() + ")]");
+ + "),group(" + p.getRolePlayer().getGroup().getId() + ")]");
l.addAnnot(managerSource);
getTS().getAg().addBel(l);
if (logger.isLoggable(Level.FINE)) logger.fine("New permission: " + l);
}
}
}
+
+
+ private void removeObligationPermissionBeliefs(Pred m, String type) throws RevisionFailedException {
+ // computes this agent obligations in the scheme
+ Term sch = m.getTerm(0);
+ Term grId = m.getTerm(1);
+
+ Structure giAnnot = new Structure("group");
+ giAnnot.addTerm(grId);
+
+ Literal obl = new Literal(type);
+ obl.addTerms(sch,new UnnamedVar());
+ obl.addAnnot(giAnnot);
+
+ // find obligation(sch,_)[group(id)]
+ Unifier un = new Unifier();
+ Iterator<Literal> i = getTS().getAg().getBB().getCandidateBeliefs(obl, un);
+ if (i != null) {
+ List<Literal> todel = new ArrayList<Literal>();
+ while (i.hasNext()) {
+ Literal inbb = i.next();
+ un.clear();
+ if (un.unifies(obl, inbb))
+ todel.add(inbb);
+ }
+ for (Literal l: todel) {
+ getTS().getAg().delBel(l);
+ }
+ }
+ }
- private void generateOrgGoalEvents() {
+ private void generateOrgGoalEvents() {
OEAgent me = getMyOEAgent();
for (GoalInstance gi : getMyOEAgent().getPossibleGoals()) {
if (!alreadyGeneratedEvents.contains(gi)) {
@@ -198,6 +243,15 @@
giID.addTerm(new Atom(gi.getScheme().getId()));
l.addAnnot(giID);
+ // add annot with mission id
+ Structure mission = new Structure("mission", 1);
+ for (MissionPlayer mp: getMyOEAgent().getMissions()) {
+ if (mp.getMission().getGoals().contains(gi.getSpec())) {
+ mission.addTerm(new Atom(mp.getMission().getId()));
+ }
+ }
+ l.addAnnot(mission);
+
// add annot with type of goal
Structure type = new Structure("type", 1);
type.addTerm(getGoalTypeAtom(gi.getSpec()));
@@ -238,7 +292,7 @@
return null;
}
- void removeAchieveEvents(String schId) {
+ void removeAchieveGoalsOfSch(String schId) {
Iterator<GoalInstance> i = alreadyGeneratedEvents.iterator();
while (i.hasNext()) {
GoalInstance gi = i.next();
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -160,6 +160,9 @@
logger.info("Received an unknown message: " + m + "!");
}
updateGUI();
+ } catch (MoiseException e) {
+ logger.log(Level.SEVERE, "Error processing '" + m + "' for " + agSender + ". "+e);
+ sendReply(agSender, m.getMsgId(), "error(\"" + e + "\")");
} catch (Exception e) {
logger.log(Level.SEVERE, "Error processing '" + m + "' for " + agSender, e);
sendReply(agSender, m.getMsgId(), "error(\"" + e + "\")");
@@ -337,15 +340,44 @@
sendReply(sender, mId, "error(\"you are not the owner of the group " + grId + ", so you can not remove it\")");
}
- currentOE.removeGroup(grId);
+ gr.checkRemove();
- String annot = "";
+ /*String annot = "";
if (gr.getGrSpec().isRoot()) {
annot = "root";
} else {
annot = "super_gr(" + gr.getSuperGroup().getId() + ")";
}
- updateMembersOE(currentOE.getAgents(), "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")[owner(" + gr.getOwner() + ")," + annot + "]", false, false);
+ */
+ //updateMembersOE(currentOE.getAgents(), "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")[owner(" + gr.getOwner() + ")," + annot + "]", false, false);
+
+ // also send untell scheme_group (if it is the case)
+ for (SchemeInstance sch: gr.getRespSchemes()) {
+ updateMembersOE(gr.getPlayers(), "scheme_group(" + sch.getId() + "," + grId + ")", false, false);
+ }
+ // untell players
+ for (RolePlayer rp: gr.getPlayers()) {
+ updateMembersOE(gr.getAgents(true), "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + gr.getId() + ")", false, false);
+ }
+
+ // send changes for subgroups of gr
+ for (GroupInstance sg: gr.getAllSubGroupsTree()) {
+ updateMembersOE(currentOE.getAgents(), "group(" + sg.getGrSpec().getId() + "," + sg.getId() + ")", false, false);
+ // also send untell scheme_group (if it is the case)
+ for (SchemeInstance sch: sg.getRespSchemes()) {
+ updateMembersOE(sg.getPlayers(), "scheme_group(" + sch.getId() + "," + sg.getId() + ")", false, false);
+ }
+ // untell players
+ for (RolePlayer rp: sg.getPlayers()) {
+ updateMembersOE(sg.getAgents(true), "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + sg.getId() + ")", false, false);
+ }
+ }
+
+ // have to remove after sending the untells
+ currentOE.removeGroup(grId);
+
+ // sent a new copy of OE
+ updateMembersOE(currentOE.getAgents(), "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")", true, false);
}
}
@@ -428,7 +460,8 @@
sendReply(sender, mId, "error(\"the scheme " + schId + " does not exist\")");
return;
}
- if (!sender.equals(sch.getOwner())) {
+
+ if (sch.getSpec().getFS().getBoolProperty("only-owner-can-remove-scheme") && !sender.equals(sch.getOwner())) {
sendReply(sender, mId, "error(\"you are not the owner of the scheme " + schId + ", so you can not change it\")");
}
Modified: trunk/applications/jason-team/AC-Local-Dummies.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-Dummies.mas2j 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/AC-Local-Dummies.mas2j 2008-05-01 21:29:36 UTC (rev 1282)
@@ -17,27 +17,27 @@
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy2 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent2, password="2"]
+ [host="localhost", port=12300, username=botagent2, password="2"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy3 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent3, password="3"]
+ [host="localhost", port=12300, username=botagent3, password="3"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy4 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent4, password="4"]
+ [host="localhost", port=12300, username=botagent4, password="4"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy5 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent5, password="5"]
+ [host="localhost", port=12300, username=botagent5, password="5"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy6 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent6, password="6"]
+ [host="localhost", port=12300, username=botagent6, password="6"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-01 21:29:36 UTC (rev 1282)
@@ -1,4 +1,3 @@
-
/* Jason Team for the
* Multi-Agent Programming Contest 2008
* (http://cig.in.tu-clausthal.de/AgentContest)
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-05-01 21:29:36 UTC (rev 1282)
@@ -46,7 +46,7 @@
: goal(search) & cell(_,_,cow(_)) // I see cows and was searching
<- !decide_target.
-// revise target each 4 steps
+// revise target each 6 steps
+pos(Step,_,_) // new cycle
: Step mod 6 == 0
<- !decide_target.
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-01 21:29:36 UTC (rev 1282)
@@ -5,9 +5,6 @@
/* -- initial goals -- */
-//!test.
-//+!test <- +gsize(16,8).
-
/*
-- plans for new match
-- create the initial exploration groups and areas
@@ -17,10 +14,8 @@
/* plans for the team's groups creation */
+!create_team_group
- <- .print("oooo creating team group");
- .if( group(team,Old), {
- jmoise.remove_group(Old)
- });
+ <- .print("oooo creating new team group -- ************************************************ ");
+ !remove_org;
jmoise.create_group(team).
+group(team,GId) // agent 1 is responsible for the creation of exploration groups
@@ -28,9 +23,10 @@
<- jmoise.create_group(exploration_grp,GId);
jmoise.create_group(exploration_grp,GId);
jmoise.create_group(exploration_grp,GId).
-+group(exploration_grp,_) // compute the area of the groups
++group(exploration_grp,_) // compute the area of the groups
: .my_name(gaucho1) &
- .findall(GId, group(exploration_grp,GId), LG) &
+ group(team,TeamId) &
+ .findall(GId, group(exploration_grp,GId)[super_gr(TeamId)], LG) &
LG = [G1,G2,G3] // there are three groups
<- ?gsize(W,H);
X = math.round(((W*H)/3)/H);
@@ -49,7 +45,7 @@
: .my_name(Me) &
agent_id(Me,AgId) &
AgId mod 2 == 1 // I have an odd Id
- <- .if( .my_name(gaucho1), {
+ <- .if( .my_name(gaucho1) {
!create_team_group
});
@@ -59,7 +55,7 @@
?pos(MyX,MyY,_);
// wait others pos
- .while( .count(ally_pos(_,_,_), N) & N < 5, {
+ .while( .count(ally_pos(_,_,_), N) & N < 5 {
.print("ooo waiting others pos ");
.wait("+ally_pos(_,_,_)", 500, nofail)
});
@@ -99,7 +95,7 @@
// TODO: make a pattern for organisational maintainance goal
-+!goto_near_unvisited[scheme(Sch)]
++!goto_near_unvisited[scheme(Sch),mission(Mission)]
<- .print("ooo I should find the nearest unvisited location and go there!");
.my_name(Me);
?play(Me,explorer,GroupId); // get the group where I play explorer
@@ -108,13 +104,13 @@
jia.near_least_visited(MeX, MeY, Area, TargetX, TargetY);
-+target(TargetX, TargetY);
.wait("+pos(_,_,_)"); // wait next cycle
- !!goto_near_unvisited[scheme(Sch)].
+ !!goto_near_unvisited[scheme(Sch),mission(Mission)].
--!goto_near_unvisited[scheme(Sch)]
+-!goto_near_unvisited[scheme(Sch),mission(Mission)]
<- .current_intention(I);
.print("ooo Failure to goto_near_unvisited ",I);
.wait("+pos(_,_,_)"); // wait next cycle
- !!goto_near_unvisited[scheme(Sch)].
+ !!goto_near_unvisited[scheme(Sch),mission(Mission)].
/* -- plans for the goals of role scouter -- */
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-01 21:29:36 UTC (rev 1282)
@@ -43,7 +43,8 @@
+?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
+end_of_simulation(_Result)
- <- .abolish(group_area(_,_,_)).
+ <- .abolish(group_area(_,_,_));
+ !remove_org.
+!restart.
@@ -56,19 +57,6 @@
/* -- plans for the goals of all roles -- */
-// get the list G of participants of the group where I play R
-+?my_group_players(G,R)
- <- .my_name(Me);
- play(Me,R,Gid);
- .findall(P, play(P,_,Gid), G).
-
-+!play_role(Role,Group)[source(Ag)]
- : .my_name(Me) & not play(Me,_,_) // I can not play more than one role
- <- .print("ooo Adopting role ",Role,", asked by ",Ag);
- jmoise.adopt_role(Role, Group).
-+!play_role(Role,Group)[source(Ag)]
- <- .print("ooo Can NOT adopt role ",Role,", asked by ",Ag).
-
/*
TODO: use a list given by BUF
@@ -104,12 +92,51 @@
/* -- general organisational plans -- */
+// remove all groups and schemes (only agent1 does that)
++!remove_org
+ : .my_name(gaucho1)
+ <- .if( group(team,Old) {
+ jmoise.remove_group(Old)
+ });
+
+ .for( scheme(_,SchId) {
+ jmoise.remove_scheme(SchId)
+ }).
++!remove_org.
+
+// finish the scheme if it has no more players
+// and it was created by me
++sch_players(Sch,0)
+ : .my_name(Me) & scheme(_, Sch)[owner(Me)]
+ <- jmoise.remove_scheme(Sch).
+
+
+// get the list G of participants of the group where I play R
++?my_group_players(G,R)
+ <- .my_name(Me);
+ play(Me,R,Gid);
+ .findall(P, play(P,_,Gid), G).
+
++!play_role(Role,Group)[source(Ag)]
+ <- .print("ooo Adopting role ",Role," in group ",Group,", asked by ",Ag);
+ jmoise.adopt_role(Role, Group).
+
// when I have an obligation or permission to a mission, commit to it
+obligation(Sch, Mission)
<- jmoise.commit_mission(Mission,Sch).
+permission(Sch, Mission)
<- jmoise.commit_mission(Mission,Sch).
+// when I am not obligated to a mission anymore, uncommit
+-obligation(Sch, Mission)
+ <- jmoise.remove_mission(Mission,Sch).
+-permission(Sch, Mission)
+ <- jmoise.remove_mission(Mission,Sch).
+
+// when I am not committed to a mission anymore, remove all goals based on that mission
+-commitment(Ag,Mission,Sch)
+ <- .drop_desire(_[scheme(Id),mission(Mission)]).
+
// if some scheme is finished, drop all intentions related to it.
-scheme(_Spec,Id)
<- .drop_desire(_[scheme(Id)]).
Modified: trunk/applications/jason-team/src/java/agent/SelectEvent.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/SelectEvent.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/agent/SelectEvent.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -10,13 +10,13 @@
import java.util.Queue;
/**
- * change the default select event function to prefer cell(_,_,cow(_)) events.
+ * change the default select event function to prefer +cow(_,_,_) events.
*
* @author Jomi
*/
public class SelectEvent extends Agent {
- private Trigger cow = Trigger.parseTrigger("+cell(_,_,cow(_))");
+ private Trigger cow = Trigger.parseTrigger("+cow(_,_,_)");
private Unifier un = new Unifier();
public Event selectEvent(Queue<Event> events) {
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -168,12 +168,14 @@
}
// set all actions as successfully executed
List<ActionExec> feedback = getTS().getC().getFeedbackActions();
- while (!toExecute.isEmpty()) {
- ActionExec action = toExecute.poll();
- action.setResult(true);
- feedback.add(action);
- if (!toExecute.isEmpty())
- notsent.append(action.getActionTerm()+" ");
+ synchronized (feedback) {
+ while (!toExecute.isEmpty()) {
+ ActionExec action = toExecute.poll();
+ action.setResult(true);
+ feedback.add(action);
+ if (!toExecute.isEmpty())
+ notsent.append(action.getActionTerm()+" ");
+ }
}
go(); // reset the wait
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -55,7 +55,6 @@
@Override
public void initAg(String agClass, ClassParameters bbPars, String asSrc, Settings stts) throws JasonException {
super.initAg(agClass, bbPars, asSrc, stts);
-
model = new LocalWorldModel(10,10, WorldModel.agsByTeam, getTS().getAg().getBB()); // just to have a default model
gui = "yes".equals(stts.getUserParameter("gui"));
if ("yes".equals(stts.getUserParameter("write_status"))) {
@@ -116,16 +115,14 @@
// manage GUIs
if (view != null) view.dispose();
if (acView != null) acView.finish();
- if (gui) {
- view = new WorldView("Herding (view of cowboy "+(getMyId()+1)+") -- against "+opponent,model);
- }
+ if (gui) view = new WorldView("Herding (view of cowboy "+(getMyId()+1)+") -- against "+opponent,model);
+ if (writeStatusThread != null) writeStatusThread.reset();
+
if (massimBackDir != null && massimBackDir.length() > 0) {
acView = new ACViewer(massimBackDir, w, h);
acView.setPriority(Thread.MIN_PRIORITY);
acView.start();
}
- if (writeStatusThread != null)
- writeStatusThread.reset();
}
/** The perception of the corral location is removed from the percepts list
@@ -225,7 +222,7 @@
protected void addRestart() {
try {
logger.info("** Arch adding restart for "+getAgName());
- //getTS().getC().create();
+ //getTS().getC().create(); // it is terrible for pending intentions of cowboys!
getTS().getC().addAchvGoal(new Literal("restart"), Intention.EmptyInt);
lo2 = new Location(-1,-1); // to not restart again in the next cycle
} catch (Exception e) {
@@ -241,25 +238,8 @@
return l;
}
- //private static final Literal cowstoclean = Literal.parseLiteral("cell(_,_,cow(_))");
- //private boolean cleanCows = false;
-
- /*
- @Override
- public synchronized void agDidPerceive() {
- super.agDidPerceive();
- if (cleanCows) {
- try {
- getTS().getAg().abolish(cowstoclean, null);
- } catch (RevisionFailedException e) {}
- cleanCows = false;
- }
- }
- */
-
void initKnownCows() {
model.clearCows();
- //cleanCows = true;
}
//void cowPerceived(int x, int y) {
@@ -283,11 +263,14 @@
void simulationEndPerceived(String result) throws RevisionFailedException {
getTS().getAg().addBel(Literal.parseLiteral("end_of_simulation("+result+")"));
+ model = null;
playing = false;
+ if (view != null) view.dispose();
}
void setCycle(int s) {
cycle = s;
+ super.setCycleNumber(cycle);
if (view != null) view.setCycle(cycle);
if (writeStatusThread != null) writeStatusThread.go();
}
@@ -321,14 +304,14 @@
@SuppressWarnings("unchecked")
@Override
public void checkMail() {
- try {
- super.checkMail();
-
- // remove messages related to obstacles and agent_position
- // and update the model
- Iterator<Message> im = getTS().getC().getMailBox().iterator();
- while (im.hasNext()) {
- Message m = im.next();
+ super.checkMail();
+
+ // remove messages related to obstacles and agent_position
+ // and update the model
+ Iterator<Message> im = getTS().getC().getMailBox().iterator();
+ while (im.hasNext()) {
+ Message m = im.next();
+ try {
if (m.getIlForce().equals("tell-cows")) {
im.remove();
/* not used anymore
@@ -341,18 +324,21 @@
} else {
String ms = m.getPropCont().toString();
if (ms.startsWith("cell") && ms.endsWith("obstacle)") && model != n...
[truncated message content] |
|
From: <jom...@us...> - 2008-05-02 08:43:50
|
Revision: 1283
http://jason.svn.sourceforge.net/jason/?rev=1283&view=rev
Author: jomifred
Date: 2008-05-02 01:43:47 -0700 (Fri, 02 May 2008)
Log Message:
-----------
jason team: use pattern for org goal
new experimental syntax for { ... } terms (they can be placed after ")" as in
.for( .member(X,[a,b,c]) ) {
.print(X)
};
it is more similar to java/c
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/doc/roles/ac2008-roles.tex
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
Added Paths:
-----------
trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-05-02 08:43:47 UTC (rev 1283)
@@ -20,9 +20,9 @@
"p(1,a). p(2,a). p(3,b). p(4,b). p(6,a). "+
"+!test1 <- .while( .count(b(_),N) & N < 4, {+b(N+1) })."+
- "+!test2 <- L=4; .while( .count(b(_)) < L { ?b(X); +b(X+1) }); jason.asunit.print(end). "+
+ "+!test2 <- L=4; .while( .count(b(_)) < L) { ?b(X); +b(X+1) }; jason.asunit.print(end). "+
- "+!test3 <- L=4; .for( p(N,a) & N < L { jason.asunit.print(N) }); jason.asunit.print(end). "+
+ "+!test3 <- L=4; .for( p(N,a) & N < L) { jason.asunit.print(N) }; jason.asunit.print(end). "+
"+!test4 <- .for( .member(N, [1,3,4]), { jason.asunit.print(N) }); jason.asunit.print(end). "
);
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-02 08:43:47 UTC (rev 1283)
@@ -45,6 +45,7 @@
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
+ directives: maintenance_goal = agent.OrgMaintenanceGoal;
+
aslSourcePath: "src/asl";
-
}
Modified: trunk/applications/jason-team/doc/roles/ac2008-roles.tex
===================================================================
--- trunk/applications/jason-team/doc/roles/ac2008-roles.tex 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/applications/jason-team/doc/roles/ac2008-roles.tex 2008-05-02 08:43:47 UTC (rev 1283)
@@ -291,6 +291,42 @@
\ascomment{}
+
+\section{Some algorithms}
+
+\subsection{Cluster identification}
+
+some how based on Hierarchical Clustering Algorithms
+http://home.dei.polimi.it/matteucc/Clustering/tutorial\_html
+
+\begin{verbatim}
+V = set of all seen cows sorted by the distance to the center of V
+C = { the cow near to the center of V }
+
+add = true
+while (add)
+ add = false
+ for all v in V
+ if (some cow in C sees v)
+ add v in C
+ add = true
+\end{verbatim}
+
+\subsection{Merging clusters/groups}
+
+performed by each herder of group gi
+\begin{verbatim}
+for all herding groups gj with id > gi.id
+
+let Si the set of cows seen by agents of group gi
+let Sj the set of cows seen by agents of group gj
+if Si intersect Sj not empty
+ // merge condition
+ group gj is removed from the organisation
+ all agents from gj adopt scouter in gi
+\end{verbatim}
+
+
\section{TODO list}
\begin{enumerate}
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-02 08:43:47 UTC (rev 1283)
@@ -14,7 +14,7 @@
/* plans for the team's groups creation */
+!create_team_group
- <- .print("oooo creating new team group -- ************************************************ ");
+ <- .print("oooo creating new team group ------------------------------------------------- ");
!remove_org;
jmoise.create_group(team).
@@ -45,9 +45,9 @@
: .my_name(Me) &
agent_id(Me,AgId) &
AgId mod 2 == 1 // I have an odd Id
- <- .if( .my_name(gaucho1) {
+ <- .if( .my_name(gaucho1) ) {
!create_team_group
- });
+ };
.print("ooo Recruiting scouters for my explorer group....");
@@ -55,10 +55,10 @@
?pos(MyX,MyY,_);
// wait others pos
- .while( .count(ally_pos(_,_,_), N) & N < 5 {
+ .while( .count(ally_pos(_,_,_), N) & N < 5 ) {
.print("ooo waiting others pos ");
.wait("+ally_pos(_,_,_)", 500, nofail)
- });
+ };
// find distance to even agents
.findall(ag_d(D,AgName),
@@ -95,6 +95,8 @@
// TODO: make a pattern for organisational maintainance goal
+{ begin maintenance_goal("+pos(_,_,_)") }
+
+!goto_near_unvisited[scheme(Sch),mission(Mission)]
<- .print("ooo I should find the nearest unvisited location and go there!");
.my_name(Me);
@@ -102,19 +104,27 @@
?group_area(_,GroupId, Area); // get the area of this group
?pos(MeX, MeY, _); // get my location
jia.near_least_visited(MeX, MeY, Area, TargetX, TargetY);
- -+target(TargetX, TargetY);
+ -+target(TargetX, TargetY).
+
+ /* added by the pattern
.wait("+pos(_,_,_)"); // wait next cycle
- !!goto_near_unvisited[scheme(Sch),mission(Mission)].
+ !!goto_near_unvisited[scheme(Sch),mission(Mission)]
+ */
+
+{ end }
+/* added by the pattern
-!goto_near_unvisited[scheme(Sch),mission(Mission)]
<- .current_intention(I);
.print("ooo Failure to goto_near_unvisited ",I);
.wait("+pos(_,_,_)"); // wait next cycle
!!goto_near_unvisited[scheme(Sch),mission(Mission)].
-
+*/
/* -- plans for the goals of role scouter -- */
+{ begin maintenance_goal("+pos(_,_,_)") }
+
+!follow_leader[scheme(Sch),group(Gr)]
: play(Leader, explorer, Gr)
<- .print("ooo I should follow the leader ",Leader);
@@ -124,22 +134,14 @@
jia.dist(MyX, MyY, LX, LY, DistanceToLeader);
// If I am far from him, go to him
- .if( DistanceToLeader > (AGPR * 2) -3, {
+ .if( DistanceToLeader > (AGPR * 2) -3) {
.print("ooo Approaching leader.");
-+target(LX,LY)
- }, {
+ }{
.print("ooo being in formation with leader.");
.send(Leader,askOne,target(X,Y),target(TX,TY));
jia.scouter_pos(LX, LY, TX, TY, SX, SY);
-+target(SX,SY)
- });
-
- .wait("+pos(_,_,_)"); // wait next cycle
- !!follow_leader[scheme(Sch),group(Gr)].
-
--!follow_leader[scheme(Sch),group(Gr)]
- <- .current_intention(I);
- .print("ooo Failure to follow_leader ",I);
- .wait("+pos(_,_,_)"); // wait next cycle
- !!follow_leader[scheme(Sch),group(Gr)].
-
\ No newline at end of file
+ }
+
+{ end }
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-02 08:43:47 UTC (rev 1283)
@@ -95,13 +95,13 @@
// remove all groups and schemes (only agent1 does that)
+!remove_org
: .my_name(gaucho1)
- <- .if( group(team,Old) {
+ <- .if( group(team,Old) ) {
jmoise.remove_group(Old)
- });
+ };
- .for( scheme(_,SchId) {
+ .for( scheme(_,SchId)) {
jmoise.remove_scheme(SchId)
- }).
+ }.
+!remove_org.
// finish the scheme if it has no more players
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-02 08:43:47 UTC (rev 1283)
@@ -5,21 +5,23 @@
/* -- plans for the goals of role herder -- */
+{ begin maintenance_goal("+pos(_,_,_)") }
+
+!recruit[scheme(Sch)]
- <- .print("ooo I should revise the size of the cluster and recruit!");
- // TODO
- .wait("+pos(_,_,_)"); // wait next cycle
- !!recruit[scheme(Sch)].
+ <- .print("ooo I should revise the size of the cluster and recruit!").
+{ end }
+{ begin maintenance_goal("+pos(_,_,_)") }
+
+!define_formation[scheme(Sch)]
<- .print("ooo I should define the formation of my group!");
?my_group_players(G, herder);
jia.herd_position(.length(G),L);
.print("ooo formation is ",L);
- !alloc_all(G,L);
- .wait("+pos(_,_,_)"); // wait next cycle
- !!define_formation[scheme(Sch)].
+ !alloc_all(G,L).
+
+{ end }
+!alloc_all([],LA).
+!alloc_all([HA|TA],LA)
@@ -45,9 +47,10 @@
/* -- plans for the goals of all roles (herder and herdboy) -- */
+{ begin maintenance_goal("+pos(_,_,_)") }
+
+!be_in_formation[scheme(Sch)]
- <- .print("ooo I should be in formation!");
+ <- .print("ooo I should be in formation!").
// TODO
- .wait("+pos(_,_,_)"); // wait next cycle
- !!be_in_formation[scheme(Sch)].
-
+
+{ end }
Added: trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java (rev 0)
+++ trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java 2008-05-02 08:43:47 UTC (rev 1283)
@@ -0,0 +1,63 @@
+package agent;
+
+import jason.asSemantics.Agent;
+import jason.asSyntax.InternalActionLiteral;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Plan;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
+import jason.asSyntax.Pred;
+import jason.asSyntax.directives.Directive;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class OrgMaintenanceGoal implements Directive {
+
+ static Logger logger = Logger.getLogger(OrgMaintenanceGoal.class.getName());
+
+ public Agent process(Pred directive, Agent outerContent, Agent innerContent) {
+ try {
+ Agent newAg = new Agent();
+
+ PlanBody endofplan = null;
+ Literal goal = null;
+
+ // change all inner plans
+ for (Plan p: innerContent.getPL()) {
+ // create end of plan: .wait
+ InternalActionLiteral wait = new InternalActionLiteral(".wait");
+ wait.addTerm(directive.getTerm(0));
+ endofplan = new PlanBodyImpl(PlanBody.BodyType.internalAction, wait);
+
+ // create end of plan: !!goal[.....]
+ goal = p.getTrigger().getLiteral().copy();
+ endofplan.add(new PlanBodyImpl(PlanBody.BodyType.achieveNF, goal));
+
+ // add in the end of plan
+ p.getBody().add(endofplan);
+
+ logger.info("*** changed plan = "+p);
+ }
+
+ // add failure plan:
+ // -!goto_near_unvisited[scheme(Sch),mission(Mission)]
+ // <- .current_intention(I);
+ // .print("ooo Failure to goto_near_unvisited ",I);
+ // .wait("+pos(_,_,_)"); // wait next cycle
+ // !!goto_near_unvisited[scheme(Sch),mission(Mission)].
+ String sp = "-!"+goal+" <- .current_intention(I); " +
+ ".print(\"ooo Failure in organisational goal "+goal+", I\"); "+
+ endofplan + ".";
+
+ logger.info("*** new plan s = "+sp);
+ Plan p = Plan.parse(sp);
+
+ newAg.getPL().add(p);
+ return newAg;
+ } catch (Exception e) {
+ logger.log(Level.SEVERE,"OrgMaintenanceGoal directive error.", e);
+ }
+ return null;
+ }
+}
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/src/jason/asSyntax/Literal.java 2008-05-02 08:43:47 UTC (rev 1283)
@@ -250,6 +250,10 @@
c.hashCodeCache = this.hashCodeCache;
return c;
}
+
+ public Literal copy() {
+ return (Literal)clone();
+ }
@Override
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-05-02 08:43:47 UTC (rev 1283)
@@ -421,7 +421,7 @@
}
/* Annotated Formulae */
-Pred pred() : { Token K; Pred p; List l; ListTerm lt;}
+Pred pred() : { Token K; Pred p; List l; ListTerm lt; PlanBody b; }
{
(
K=<ATOM>
@@ -429,28 +429,29 @@
K=<TK_BEGIN>
|
K=<TK_END>
- ) { p = new Pred(K.image);
- p.setSrcLine(K.beginLine);
- p.setSrc(asSource);
- }
+ ) { p = new Pred(K.image);
+ p.setSrcLine(K.beginLine);
+ p.setSrc(asSource);
+ }
[
- "(" l = terms()
- ")" { p.setTerms(l); }
+ "(" l = terms()
+ ")" { p.setTerms(l); }
]
+ ( b=plan_body_term() { p.addTerm(b); }
+ )*
[
- lt = list() { p.setAnnots(lt); }
+ lt = list() { p.setAnnots(lt); }
]
- { return p; }
+ { return p; }
}
/* List of terms */
-List terms() : { List listTerms = new ArrayList(); Term v; Object o; }
+List terms() : { List listTerms = new ArrayList(); Term v; PlanBody o; }
{
v=term() { listTerms.add(v); }
( "," v=term() { listTerms.add(v); }
- | o=plan_body_term() { listTerms.add(o); }
)*
{ return listTerms; }
}
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-05-01 21:29:36 UTC (rev 1282)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-05-02 08:43:47 UTC (rev 1283)
@@ -578,7 +578,7 @@
/* Annotated Formulae */
final public Pred pred() throws ParseException {
- Token K; Pred p; List l; ListTerm lt;
+ Token K; Pred p; List l; ListTerm lt; PlanBody b;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ATOM:
K = jj_consume_token(ATOM);
@@ -594,64 +594,64 @@
jj_consume_token(-1);
throw new ParseException();
}
- p = new Pred(K.image);
- p.setSrcLine(K.beginLine);
- p.setSrc(asSource);
+ p = new Pred(K.image);
+ p.setSrcLine(K.beginLine);
+ p.setSrc(asSource);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 39:
jj_consume_token(39);
l = terms();
jj_consume_token(40);
- p.setTerms(l);
+ p.setTerms(l);
break;
default:
jj_la1[24] = jj_gen;
;
}
+ label_9:
+ while (true) {
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 27:
+ ;
+ break;
+ default:
+ jj_la1[25] = jj_gen;
+ break label_9;
+ }
+ b = plan_body_term();
+ p.addTerm(b);
+ }
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 42:
lt = list();
- p.setAnnots(lt);
+ p.setAnnots(lt);
break;
default:
- jj_la1[25] = jj_gen;
+ jj_la1[26] = jj_gen;
;
}
- {if (true) return p;}
+ {if (true) return p;}
throw new Error("Missing return statement in function");
}
/* List of terms */
final public List terms() throws ParseException {
- List listTerms = new ArrayList(); Term v; Object o;
+ List listTerms = new ArrayList(); Term v; PlanBody o;
v = term();
listTerms.add(v);
- label_9:
+ label_10:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case 27:
case 41:
;
break;
default:
- jj_la1[26] = jj_gen;
- break label_9;
+ jj_la1[27] = jj_gen;
+ break label_10;
}
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case 41:
- jj_consume_token(41);
- v = term();
+ jj_consume_token(41);
+ v = term();
listTerms.add(v);
- break;
- case 27:
- o = plan_body_term();
- listTerms.add(o);
- break;
- default:
- jj_la1[27] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
}
{if (true) return listTerms;}
throw new Error("Missing return statement in function");
@@ -709,7 +709,7 @@
case 42:
f = term_in_list();
last = lt.append(f); lt.setSrcLine(f.getSrcLine()); lt.setSrc(f.getSrc());
- label_10:
+ label_11:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 41:
@@ -717,7 +717,7 @@
break;
default:
jj_la1[29] = jj_gen;
- break label_10;
+ break label_11;
}
jj_consume_token(41);
f = term_in_list();
@@ -1199,30 +1199,40 @@
finally { jj_save(0, xla); }
}
+ final private boolean jj_3R_16() {
+ if (jj_scan_token(27)) return true;
+ return false;
+ }
+
final private boolean jj_3_1() {
if (jj_scan_token(27)) return true;
if (jj_scan_token(TK_BEGIN)) return true;
- if (jj_3R_11()) return true;
+ if (jj_3R_12()) return true;
if (jj_scan_token(28)) return true;
return false;
}
- final private boolean jj_3R_13() {
- if (jj_3R_14()) return true;
+ final private boolean jj_3R_15() {
+ if (jj_3R_17()) return true;
return false;
}
- final private boolean jj_3R_12() {
+ final private boolean jj_3R_14() {
+ if (jj_3R_16()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_13() {
if (jj_scan_token(39)) return true;
return false;
}
- final private boolean jj_3R_14() {
+ final private boolean jj_3R_17() {
if (jj_scan_token(42)) return true;
return false;
}
- final private boolean jj_3R_11() {
+ final private boolean jj_3R_12() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(20)) {
@@ -1233,9 +1243,13 @@
}
}
xsp = jj_scanpos;
- if (jj_3R_12()) jj_scanpos = xsp;
+ if (jj_3R_13()) jj_scanpos = xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_14()) { jj_scanpos = xsp; break; }
+ }
xsp = jj_scanpos;
- if (jj_3R_13()) jj_scanpos = xsp;
+ if (jj_3R_15()) jj_scanpos = xsp;
return false;
}
@@ -1256,10 +1270,10 @@
jj_la1_1();
}
private static void jj_la1_0() {
- jj_la1_0 = new int[] {0x8000000,0x10cb00,0x8000000,0x80000000,0x8000000,0x10000,0x10cb00,0x8000000,0x8000000,0x20000000,0x10000,0x0,0x0,0x0,0x80000000,0x80000000,0x30cb80,0x0,0x0,0x80000000,0x80000000,0x800,0x10cb00,0x10c000,0x0,0x0,0x8000000,0x8000000,0x83acf80,0x0,0x200080,0x0,0x3acb80,0x3acb80,0x0,0x0,0x3acf80,0x3acb80,0x0,0x83acb80,0x0,0x0,0x0,0x3000,0x3000,0x0,0x32cb80,0x200080,0x0,};
+ jj_la1_0 = new int[] {0x8000000,0x10cb00,0x8000000,0x80000000,0x8000000,0x10000,0x10cb00,0x8000000,0x8000000,0x20000000,0x10000,0x0,0x0,0x0,0x80000000,0x80000000,0x30cb80,0x0,0x0,0x80000000,0x80000000,0x800,0x10cb00,0x10c000,0x0,0x8000000,0x0,0x0,0x83acf80,0x0,0x200080,0x0,0x3acb80,0x3acb80,0x0,0x0,0x3acf80,0x3acb80,0x0,0x83acb80,0x0,0x0,0x0,0x3000,0x3000,0x0,0x32cb80,0x200080,0x0,};
}
private static void jj_la1_1() {
- jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x1,0x2,0xc,0x10,0x10,0x0,0x20,0x4,0x5c,0x5c,0x0,0x0,0x0,0x80,0x400,0x200,0x200,0x488,0x200,0x400,0x800,0x488,0x488,0x800,0x2000,0x88,0x88,0x3fc000,0x488,0x3fc000,0xc,0xc,0xc00000,0xc00000,0x1000000,0x88,0x0,0x400,};
+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x1,0x2,0xc,0x10,0x10,0x0,0x20,0x4,0x5c,0x5c,0x0,0x0,0x0,0x80,0x0,0x400,0x200,0x488,0x200,0x400,0x800,0x488,0x488,0x800,0x2000,0x88,0x88,0x3fc000,0x488,0x3fc000,0xc,0xc,0xc00000,0xc00000,0x1000000,0x88,0x0,0x400,};
}
final private JJCalls[] jj_2_rtns = new JJCalls[1];
private boolean jj_rescan = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-03 14:16:18
|
Revision: 1285
http://jason.svn.sourceforge.net/jason/?rev=1285&view=rev
Author: jomifred
Date: 2008-05-03 07:16:12 -0700 (Sat, 03 May 2008)
Log Message:
-----------
jason team: improvements
.suspend without arg
.delete in list uses unification
Modified Paths:
--------------
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-moise/src/jmoise/broadcast.java
trunk/applications/jason-team/gauchos.xml
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/goto.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
trunk/applications/jason-team/src/java/test/MindView.java
trunk/applications/jason-team/src/team-os.xml
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/asSyntax/ListTermImpl.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/asSyntax/patterns/goal/EBDG.java
trunk/src/jason/stdlib/delete.java
trunk/src/jason/stdlib/drop_desire.java
trunk/src/jason/stdlib/package.html
trunk/src/jason/stdlib/resume.java
trunk/src/jason/stdlib/suspend.java
trunk/src/xml/agInspection.xsl
Added Paths:
-----------
trunk/applications/as-unit-test/src/jason/tests/TestIAdelete.java
Added: trunk/applications/as-unit-test/src/jason/tests/TestIAdelete.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestIAdelete.java (rev 0)
+++ trunk/applications/as-unit-test/src/jason/tests/TestIAdelete.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -0,0 +1,54 @@
+package jason.tests;
+
+import jason.asunit.TestAgent;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestIAdelete {
+
+ TestAgent ag;
+
+ // initialisation of the agent test
+ @Before
+ public void setupAg() {
+ ag = new TestAgent();
+
+ // defines the agent's AgentSpeak code
+ ag.parseAScode(
+ "pos(3). pos(4). pos(1). pos(10). "+
+ "+!test1 <- .findall(pos(X),pos(X),L); !find_closest(5,L,Alloc,Rest); jason.asunit.print(\"*\",Alloc); jason.asunit.print(Rest)."+
+
+ "+!test2 <- .findall(pos(X),pos(X),L); !alloc([1,2,3,4],L)."+
+
+ "+!alloc([],_). "+
+ "+!alloc([A|T],Options) <- !find_closest(A,Options,Loc,Rest); jason.asunit.print(A,\" to \",Loc); !alloc(T,Rest). " +
+
+ "+!find_closest(Ag,Options, MinDist, Rest) <- "+
+ " ?calc_distances(Options,Distances,Ag); jason.asunit.print(Distances); "+
+ " .min(Distances,d(_,MinDist)); "+
+ " .delete(pos(MinDist),Options,Rest). "+
+
+ "calc_distances([],[],_) :- true. "+
+ "calc_distances([pos(F)|TP], [d(D,F)|TD], Ref) "+
+ ":- D = math.abs(Ref - F) & calc_distances(TP, TD, Ref). "
+ );
+ }
+
+ @Test
+ public void testDelete() {
+ ag.addGoal("test1");
+ ag.assertPrint("[d(2,3),d(1,4),d(4,1),d(5,10)]", 5);
+ ag.assertPrint("*4", 5);
+ ag.assertPrint("[pos(3),pos(1),pos(10)]", 3);
+ }
+
+ @Test
+ public void testAlloc() {
+ ag.addGoal("test2");
+ ag.assertPrint("1 to 1", 10);
+ ag.assertPrint("2 to 3", 10);
+ ag.assertPrint("3 to 4", 10);
+ ag.assertPrint("4 to 10", 10);
+ }
+}
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -156,10 +156,10 @@
OrgManagerCommand cmd = commands.get(content.getFunctor());
if (cmd != null) {
cmd.process(currentOE, content, agSender, m.getMsgId());
+ updateGUI();
} else {
logger.info("Received an unknown message: " + m + "!");
}
- updateGUI();
} catch (MoiseException e) {
logger.log(Level.SEVERE, "Error processing '" + m + "' for " + agSender + ". "+e);
sendReply(agSender, m.getMsgId(), "error(\"" + e + "\")");
@@ -215,11 +215,22 @@
public void process(OE currentOE, Pred command, OEAgent sender, String mId) throws MoiseException {
String roleId = command.getTerm(0).toString();
String grId = command.getTerm(1).toString();
+
sender.removeRole(roleId, grId);
GroupInstance gr = currentOE.findGroup(grId);
// notify other players
updateMembersOE(gr.getAgents(true), "play(" + sender + "," + roleId + "," + grId + ")", false, false);
+
+ // and the sender
+ updateMembersOE(sender, "play(" + sender + "," + roleId + "," + grId + ")", true, false);
+
+ // if the agent is not member of the group anymore, remove other informations of the group
+ if (!gr.getAgents(false).contains(sender)) {
+ for (RolePlayer rp : gr.getPlayers()) {
+ updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + gr.getId() + ")", false, false);
+ }
+ }
}
}
Modified: trunk/applications/jason-moise/src/jmoise/broadcast.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/broadcast.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-moise/src/jmoise/broadcast.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -59,7 +59,7 @@
GroupInstance gi = oag.getOE().findGroup(target.toString());
if (gi != null) {
for (OEAgent ag: gi.getAgents(true)) {
- if (!ag.getId().equals(oag.getAgName())) {
+ if (!ag.getId().equals(oag.getAgName()) && !oag.getAgName().startsWith("someone")) {
oag.sendMsg(new Message(ilf.toString(), null, ag.getId(), pcnt));
}
}
@@ -68,7 +68,7 @@
SchemeInstance sch = oag.getOE().findScheme(target.toString());
if (sch != null) {
for (OEAgent ag: sch.getAgents()) {
- if (!ag.getId().equals(oag.getAgName())) {
+ if (!ag.getId().equals(oag.getAgName()) && !oag.getAgName().startsWith("someone")) {
oag.sendMsg(new Message(ilf.toString(), null, ag.getId(), pcnt));
}
}
Modified: trunk/applications/jason-team/gauchos.xml
===================================================================
--- trunk/applications/jason-team/gauchos.xml 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/gauchos.xml 2008-05-03 14:16:12 UTC (rev 1285)
@@ -32,9 +32,9 @@
<copy file="../jason-moise/lib/moise.jar" todir="lib" />
<mkdir dir="tmp-ag-mind" />
- <!--delete failonerror="no" includeEmptyDirs="true" verbose="false">
- <fileset dir="tmp-ag-mind" includes="*.xml"/>
- </delete-->
+ <delete failonerror="no" includeEmptyDirs="true" verbose="false">
+ <fileset dir="massim-server/backup" includes="*"/>
+ </delete>
</target>
<target name="user-end">
</target>
@@ -93,7 +93,11 @@
<target name="run" depends="compile" >
- <echo message="Running project ${ant.project.name}" />
+ <delete failonerror="no" includeEmptyDirs="true" verbose="false">
+ <fileset dir="tmp-ag-mind" includes="*.xml"/>
+ </delete>
+
+ <echo message="Running project ${ant.project.name}" />
<java classname="jason.infra.centralised.RunCentralisedMAS"
failonerror="true" fork="yes" dir="${basedir}" >
<classpath refid="project.classpath"/>
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-03 14:16:12 UTC (rev 1285)
@@ -5,6 +5,8 @@
/* -- initial goals -- */
+!create_team_group.
+
/*
-- plans for new match
-- create the initial exploration groups and areas
@@ -14,10 +16,12 @@
/* plans for the team's groups creation */
+!create_team_group
+ : .my_name(gaucho1)
<- .print("oooo creating new team group ------------------------------------------------- ");
!remove_org;
jmoise.create_group(team).
-
++!create_team_group.
+
+group(team,GId) // agent 1 is responsible for the creation of exploration groups
: .my_name(gaucho1)
<- jmoise.create_group(exploration_grp,GId);
@@ -45,9 +49,9 @@
: .my_name(Me) &
agent_id(Me,AgId) &
AgId mod 2 == 1 // I have an odd Id
- <- .if( .my_name(gaucho1) ) {
- !create_team_group
- };
+ <- //.if( .my_name(gaucho1) ) {
+ // !create_team_group
+ //};
.print("ooo Recruiting scouters for my explorer group....");
@@ -79,7 +83,7 @@
+!find_scouter([ag_d(_,AgName)|_],GId)
<- .print("ooo Ask ",AgName," to play scouter");
.send(AgName, achieve, play_role(scouter,GId));
- .wait("+play(Ag,scouter,GId)",2000).
+ .wait("+play(AgName,scouter,GId)",2000).
-!find_scouter([_|LSOdd],GId) // in case the wait fails, try next agent
<- .print("ooo find_scouter failure, try another agent.");
!find_scouter(LSOdd,GId).
@@ -93,8 +97,6 @@
/* -- plans for the goals of role explorer -- */
-// TODO: make a pattern for organisational maintainance goal
-
{ begin maintenance_goal("+pos(_,_,_)") }
+!goto_near_unvisited[scheme(Sch),mission(Mission)]
@@ -121,11 +123,13 @@
!!goto_near_unvisited[scheme(Sch),mission(Mission)].
*/
+
+
/* -- plans for the goals of role scouter -- */
{ begin maintenance_goal("+pos(_,_,_)") }
-+!follow_leader[scheme(Sch),group(Gr)]
++!follow_leader[scheme(Sch),mission(Mission),group(Gr)]
: play(Leader, explorer, Gr)
<- .print("ooo I should follow the leader ",Leader);
?pos(MyX,MyY,_);
@@ -139,9 +143,10 @@
-+target(LX,LY)
}{
.print("ooo being in formation with leader.");
- .send(Leader,askOne,target(X,Y),target(TX,TY));
+ .send(Leader,askOne,target(_,_),target(TX,TY));
jia.scouter_pos(LX, LY, TX, TY, SX, SY);
-+target(SX,SY)
- }
+ }.
{ end }
+
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-03 14:16:12 UTC (rev 1285)
@@ -41,6 +41,8 @@
+?pos(X, Y, S) <- .wait("+pos(X,Y,S)").
+?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
++?gsize(W,H) <- .wait("+gsize(W,H)").
++?ally_pos(Name,X,Y) : .my_name(Name) <- ?pos(X,Y,_).
+end_of_simulation(_Result)
<- .abolish(group_area(_,_,_));
@@ -57,39 +59,18 @@
/* -- plans for the goals of all roles -- */
-/*
-TODO: use a list given by BUF
++!share_seen_cows <- .print("ooo start sharing cows."); .suspend.
-+!share_seen_cows[scheme(Sch)]
- <- .print("ooo I should share cows!");
- ?cows_to_inform(C);
- jmoise.broadcast(Sch, tell, C);
- // TODO: limpar -+cows_to_inform([])
- .wait("+pos(_,_,_)"); // wait next cycle
- !!share_seen_cows[scheme(Sch)].
-
-+?cows_to_inform([]).
-
-+cell(X,Y,cow(Id))
- <- +cow(Id,X,Y); //Jomi, tu nao vai gostar disso :D
- ?cows_to_inform(C);
- -+cows_to_inform([cow(Id,X,Y)|C]).
-
-*/
-
-+!share_seen_cows.
-
// simple implementation of share_cows (see TODO above)
+cow(Id,X,Y)[source(percept)]
- : .my_name(Me) & play(Me,_,Gr)
+ : .desire(share_seen_cows) & .my_name(Me) & play(Me,_,Gr)
<- jmoise.broadcast(Gr, tell, cow(Id,X,Y)).
-cow(Id,X,Y)[source(percept)]
- : .my_name(Me) & play(Me,_,Gr)
+ : .desire(share_seen_cows) & .my_name(Me) & play(Me,_,Gr)
<- jmoise.broadcast(Gr, untell, cow(Id,X,Y)).
-
/* -- general organisational plans -- */
// remove all groups and schemes (only agent1 does that)
@@ -114,7 +95,7 @@
// get the list G of participants of the group where I play R
+?my_group_players(G,R)
<- .my_name(Me);
- play(Me,R,Gid);
+ ?play(Me,R,Gid);
.findall(P, play(P,_,Gid), G).
+!play_role(Role,Group)[source(Ag)]
@@ -134,8 +115,9 @@
<- jmoise.remove_mission(Mission,Sch).
// when I am not committed to a mission anymore, remove all goals based on that mission
--commitment(Ag,Mission,Sch)
- <- .drop_desire(_[scheme(Id),mission(Mission)]).
+-commitment(Me,Mission,Sch)
+ : .my_name(Me)
+ <- .drop_desire(_[scheme(Sch),mission(Mission)]).
// if some scheme is finished, drop all intentions related to it.
-scheme(_Spec,Id)
Modified: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-05-03 14:16:12 UTC (rev 1285)
@@ -21,6 +21,7 @@
+target(NX,NY)
<- .drop_desire(move);
jia.set_target(NX,NY);
+ -at_target;
!!move.
// I still do not know my location
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-03 14:16:12 UTC (rev 1285)
@@ -2,55 +2,127 @@
/* -- initial beliefs -- */
+/* -- plans for herding groups creation -- */
+// if see cow and is not herding, create the herding group and change roles
+@lcs[atomic]
++cow(_,_,_)
+ : .my_name(Me) &
+ play(Me,explorer,_) &
+ not .desire(create_herding_gr) // to avoid crating several groups
+ <- !create_herding_gr.
+
++!create_herding_gr
+ <- .print("ooo Creating herding group.");
+ .my_name(Me);
+
+ // create the new group
+ ?group(team,TeamId);
+ jmoise.create_group(herding_grp, TeamId);
+ .wait("+group(herding_grp, HG)[owner(Me)]", 4000);
+
+ // store the list of scouter in my group
+ ?play(Me,explorer,EG);
+ .findall(Scouter,play(Scouter,scouter,EG),LScouters);
+
+ !change_role(herder,HG);
+
+ // ask scouters to change role
+ .print("ooo Asking ",LScouters," to adopt the herdboy role");
+ .send(LScouters,achieve,change_role(herdboy,HG)).
+
+
++!change_role(herder,HG)
+ <- .my_name(Me);
+ .if (commitment(Me,explore,Sch)) {
+ jmoise.remove_mission(explore,Sch)
+ };
+ .if (play(Me,explorer,EG)) {
+ jmoise.remove_role(explorer,EG)
+ };
+ jmoise.adopt_role(herder,HG).
+
++!change_role(herdboy,HG)
+ <- .my_name(Me);
+ .if (commitment(Me,scout,Sch)) {
+ jmoise.remove_mission(scout,Sch)
+ };
+ .if (play(Me,scouter,EG)) {
+ jmoise.remove_role(scouter,EG)
+ };
+ jmoise.adopt_role(herdboy,HG).
+
+
+// If if start playing explorer in a group that has no scheme, create the scheme
++play(Ag,herder,G)
+ : .my_name(Ag) &
+ not scheme_group(_,G)
+ <- jmoise.create_scheme(herd_sch, [G]).
+
+
/* -- plans for the goals of role herder -- */
{ begin maintenance_goal("+pos(_,_,_)") }
-+!recruit[scheme(Sch)]
++!recruit[scheme(Sch),mission(Mission)]
<- .print("ooo I should revise the size of the cluster and recruit!").
{ end }
+
{ begin maintenance_goal("+pos(_,_,_)") }
-+!define_formation[scheme(Sch)]
++!define_formation[scheme(Sch),mission(Mission)]
<- .print("ooo I should define the formation of my group!");
?my_group_players(G, herder);
jia.herd_position(.length(G),L);
- .print("ooo formation is ",L);
+ .print("ooo Formation is ",L, " for agents ",G);
!alloc_all(G,L).
{ end }
-+!alloc_all([],LA).
++!alloc_all([],_).
+!alloc_all([HA|TA],LA)
<- !find_closest(HA,LA,pos(X,Y),NLA);
+ .print("ooo Alocating position ",pos(X,Y)," to agent ",HA);
.send(HA,tell,target(X,Y));
- -+alloc_target(HA,Alloc);
+ //-+alloc_target(HA,Alloc);
!alloc_all(TA,NLA).
-+!find_closest(Ag, List, Alloc, Rest) // rule
- <- ?ally_pos(Ag,XY);
- !closest(List,[],Sorted,pos(X,Y),9999);
- Sorted = [Alloc|Rest];
- .print("FIND CLOSEST: ",Sorted).
-// TODO: use min
-+!closest([],S,S,P,D).
++!find_closest(Ag, ListPos, MinDist, Rest) // find the location in ListPos nearest to agent Ag
+ <- ?ally_pos(Ag,X,Y);
+ ?calc_distances(ListPos,Distances,pos(X,Y));
+ .print("Distances for ",ag_pos(Ag,X,Y)," are ",Distances);
+ .min(Distances,d(_,MinDist));
+ .delete(d(_,MinDist),Distances,Rest);
+ .print("rest is ",Rest).
+ //!closest(ListPos,[],Sorted,pos(X,Y),9999);
+ //Sorted = [Alloc|Rest];
+ //.print("FIND CLOSEST: ",Sorted).
+
+calc_distances([],[],_) :- true.
+calc_distances([pos(Fx,Fy)|TP], [d(D,pos(Fx,Fy))|TD], pos(AgX,AgY))
+ :- jia.path_length(Fx,Fy,AgX,AgY,D) & calc_distances(TP, TD, pos(AgX,AgY)).
+
+/*
++!closest([],S,S,_,_).
+!closest([pos(XH,YH)|T],Aux,S,pos(XP,YP),LD)
- : jia.path_length(XH,YH,XP,YP,D) & D < LD // usar A*
+ : jia.path_length(XH,YH,XP,YP,D) & D < LD
<- !closest(T,[pos(XH,YH)|Aux],S,pos(XP,YP),D).
+!closest([pos(XH,YH)|T],Aux,S,pos(XP,YP),LD)
<- .concat(Aux,[pos(XH,YH)],Aux2);
!closest(T,Aux2,S,pos(XP,YP),LD).
+*/
-
/* -- plans for the goals of all roles (herder and herdboy) -- */
-{ begin maintenance_goal("+pos(_,_,_)") }
-+!be_in_formation[scheme(Sch)]
- <- .print("ooo I should be in formation!").
- // TODO
+//{ begin maintenance_goal("+pos(_,_,_)") }
+
+// This goal behaviour is set by the message "tell target" of the leader of the group
++!be_in_formation[scheme(Sch),mission(Mission)]
+ <- .print("ooo I should be in formation!");
+ .suspend.
-{ end }
+// { end }
+
Modified: trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -23,6 +23,8 @@
PlanBody endofplan = null;
Literal goal = null;
+ //ListTerm annots = ListTermImpl.parseList("[scheme(SchId),mission(MissionId),group(GroupId)]");
+
// change all inner plans
for (Plan p: innerContent.getPL()) {
// create end of plan: .wait
@@ -31,13 +33,13 @@
endofplan = new PlanBodyImpl(PlanBody.BodyType.internalAction, wait);
// create end of plan: !!goal[.....]
+ //p.getTrigger().getLiteral().addAnnots( (ListTerm)annots.clone());
goal = p.getTrigger().getLiteral().copy();
endofplan.add(new PlanBodyImpl(PlanBody.BodyType.achieveNF, goal));
// add in the end of plan
p.getBody().add(endofplan);
-
- logger.info("*** changed plan = "+p);
+ newAg.getPL().add(p);
}
// add failure plan:
@@ -47,10 +49,8 @@
// .wait("+pos(_,_,_)"); // wait next cycle
// !!goto_near_unvisited[scheme(Sch),mission(Mission)].
String sp = "-!"+goal+" <- .current_intention(I); " +
- ".print(\"ooo Failure in organisational goal "+goal+", I\"); "+
+ ".print(\"ooo Failure in organisational goal "+goal+"\", I); "+
endofplan + ".";
-
- logger.info("*** new plan s = "+sp);
Plan p = Plan.parse(sp);
newAg.getPL().add(p);
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -70,7 +70,10 @@
out = new PrintWriter(fileName);
while (true) {
try {
+ long timebefore = System.currentTimeMillis();
waitNextCycle();
+ long cycletime = System.currentTimeMillis() - timebefore;
+
//out.println("\n\n** Agent "+getAgName()+" in cycle "+cycle+"\n");
//for (int i=0; i<model.getNbOfAgs(); i++) {
// out.println("miner"+(i+1)+" is carrying "+model.getGoldsWithAg(i)+" gold(s), at "+model.getAgPos(i));
@@ -97,17 +100,20 @@
}
}
+ s.append( String.format("%7d ms", cycletime));
+ logger.info(s.toString());
+ out.println(s.toString());
+ out.flush();
+
+
// store the agent'd mind
if (dirmind != null) {
- String agmind = new asl2xml().transform(owner.getTS().getAg().getAgState());
- FileWriter outmind = new FileWriter(new File(dirmind.getName()+"/"+owner.getCycle()+".xml"));
- outmind.write(agmind);
- outmind.close();
+ String agmind = new asl2xml().transform(owner.getTS().getAg().getAgState());
+ FileWriter outmind = new FileWriter(new File(dirmind.getName()+"/"+owner.getCycle()+".xml"));
+ outmind.write(agmind);
+ outmind.close();
}
- logger.info(s.toString());
- out.println(s.toString());
- out.flush();
} catch (InterruptedException e) { // no problem, quit the thread
return;
} catch (Exception e) {
Modified: trunk/applications/jason-team/src/java/test/MindView.java
===================================================================
--- trunk/applications/jason-team/src/java/test/MindView.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/src/java/test/MindView.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -161,28 +161,23 @@
@SuppressWarnings("unchecked")
private void setupSlider() {
+ int first = -1;
int size = 0;
for (String f: new File("tmp-ag-mind").list()) {
if (f.endsWith(".xml")) {
f = f.substring(0, f.length()-4);
try {
int n = Integer.parseInt(f);
+ if (first < 0)
+ first = n;
if (n > size)
size = n;
} catch (Exception e) { }
}
}
- /*File f = new File("tmp-ag-mind/"+size+".xml");
- while (f.exists()) {
- size++;
- f = new File("tmp-ag-mind/"+size+".xml");
- }
- */
- //Hashtable<Integer,Component> labelTable = new Hashtable<Integer,Component>();
- //labelTable.put( 0, new JLabel("Cycle 0") );
- //labelTable.put( size, new JLabel("Cycle "+size) );
- //jHistory.setLabelTable( labelTable );
+ step = first;
+ jHistory.setMinimum(first);
jHistory.setMaximum(size);
- jHistory.setValue(0);
+ jHistory.setValue(step);
}
}
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-03 14:16:12 UTC (rev 1285)
@@ -55,9 +55,12 @@
</sub-groups>
<formation-constraints>
- <!--compatibility from="cowboy" to="cowboy" type="compatibility"
+ <compatibility from="explorer" to="herder" type="compatibility"
scope="intra-group" extends-sub-groups="true"
- bi-dir="true"/ -->
+ bi-dir="true"/>
+ <compatibility from="scouter" to="herder" type="herdboy"
+ scope="intra-group" extends-sub-groups="true"
+ bi-dir="true"/>
</formation-constraints>
</group-specification>
</structural-specification>
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -154,6 +154,7 @@
/** get as XML */
public Element getAsDOM(Document document) {
Element eim = (Element) document.createElement("intended-means");
+ eim.setAttribute("trigger", trigger.toString());
if (plan != null) {
eim.appendChild(plan.getAsDOM(document));
}
Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -30,6 +30,7 @@
import jason.stdlib.loop;
import java.util.Iterator;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -87,6 +88,21 @@
return super.apply(u);
}
+ @Override
+ public void countVars(Map<VarTerm, Integer> c) {
+ super.countVars(c);
+ if (this.ia != null && this.ia instanceof jason.stdlib.wait) {
+ // count the vars of first arg
+ if (getTerm(0).isString()) {
+ try {
+ Trigger te = Trigger.parseTrigger( ((StringTerm)getTerm(0)).getString() );
+ te.getLiteral().countVars(c);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
@SuppressWarnings("unchecked")
public Iterator<Unifier> logicalConsequence(Agent ag, Unifier un) {
Modified: trunk/src/jason/asSyntax/ListTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/ListTermImpl.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/asSyntax/ListTermImpl.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -87,6 +87,10 @@
return t;
}
+ public ListTermImpl copy() {
+ return (ListTermImpl)clone();
+ }
+
@Override
public boolean equals(Object t) {
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-05-03 14:16:12 UTC (rev 1285)
@@ -202,8 +202,8 @@
( b = belief() { if (a != null) {
if (b.isRule()) {
a.addInitialBel(b);
- if (!parsedFiles.contains(asSource))
- logger.warning(getSourceRef(b)+" warning: avoid to mix rules and plans ('"+b+"').");
+ //if (!parsedFiles.contains(asSource))
+ // logger.warning(getSourceRef(b)+" warning: avoid to mix rules and plans ('"+b+"').");
} else {
throw new ParseException(getSourceRef(b)+" The belief '"+b+"' is not in the begin of the source code!");
}
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -203,8 +203,8 @@
if (a != null) {
if (b.isRule()) {
a.addInitialBel(b);
- if (!parsedFiles.contains(asSource))
- logger.warning(getSourceRef(b)+" warning: avoid to mix rules and plans ('"+b+"').");
+ //if (!parsedFiles.contains(asSource))
+ // logger.warning(getSourceRef(b)+" warning: avoid to mix rules and plans ('"+b+"').");
} else {
{if (true) throw new ParseException(getSourceRef(b)+" The belief '"+b+"' is not in the begin of the source code!");}
}
Modified: trunk/src/jason/asSyntax/patterns/goal/EBDG.java
===================================================================
--- trunk/src/jason/asS...
[truncated message content] |
|
From: <jom...@us...> - 2008-05-03 20:26:42
|
Revision: 1286
http://jason.svn.sourceforge.net/jason/?rev=1286&view=rev
Author: jomifred
Date: 2008-05-03 13:26:40 -0700 (Sat, 03 May 2008)
Log Message:
-----------
jason team: new IA: cluster
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
trunk/src/jason/asSyntax/ListTermImpl.java
trunk/src/jason/asSyntax/ObjectTermImpl.java
Added Paths:
-----------
trunk/applications/jason-team/src/java/jia/cluster.java
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-05-03 14:16:12 UTC (rev 1285)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-05-03 20:26:40 UTC (rev 1286)
@@ -61,7 +61,8 @@
!decide_target.
+!decide_target
- : jia.herd_position(six,X,Y)
+ : jia.cluster(C) &
+ jia.herd_position(six,C,X,Y)
<- .print("COWS! going to ",X,",",Y); //," previous target ",TX,",",TY);
-+goal(herd);
-+target(X,Y).
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-03 14:16:12 UTC (rev 1285)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-03 20:26:40 UTC (rev 1286)
@@ -75,8 +75,10 @@
+!define_formation[scheme(Sch),mission(Mission)]
<- .print("ooo I should define the formation of my group!");
?my_group_players(G, herder);
- jia.herd_position(.length(G),L);
- .print("ooo Formation is ",L, " for agents ",G);
+ jia.cluster(Cluster,CAsList);
+ -+current_cluster(CAsList);
+ jia.herd_position(.length(G),Cluster,L);
+ .print("ooo Formation is ",L, " for agents ",G," in cluster ", Cluster);
!alloc_all(G,L).
{ end }
@@ -91,20 +93,20 @@
+!find_closest(Ag, ListPos, MinDist, Rest) // find the location in ListPos nearest to agent Ag
<- ?ally_pos(Ag,X,Y);
- ?calc_distances(ListPos,Distances,pos(X,Y));
- .print("Distances for ",ag_pos(Ag,X,Y)," are ",Distances);
- .min(Distances,d(_,MinDist));
- .delete(d(_,MinDist),Distances,Rest);
- .print("rest is ",Rest).
- //!closest(ListPos,[],Sorted,pos(X,Y),9999);
- //Sorted = [Alloc|Rest];
- //.print("FIND CLOSEST: ",Sorted).
+ .print("ooo try to alloc ",Ag," in ",X,Y," with ",ListPos);
+ //?calc_distances(ListPos,Distances,pos(X,Y));
+ //.print("Distances for ",ag_pos(Ag,X,Y)," are ",Distances);
+ //.min(Distances,d(_,MinDist));
+ //.delete(d(_,MinDist),Distances,Rest);
+ //.print("rest is ",Rest).
+ !closest(ListPos,[],[MinDist|Rest],pos(X,Y),9999).
+/*
calc_distances([],[],_) :- true.
calc_distances([pos(Fx,Fy)|TP], [d(D,pos(Fx,Fy))|TD], pos(AgX,AgY))
- :- jia.path_length(Fx,Fy,AgX,AgY,D) & calc_distances(TP, TD, pos(AgX,AgY)).
-
-/*
+ :- .print("calc dist from for ag ",pos(AgX,AgY)) & jia.path_length(Fx,Fy,AgX,AgY,D) & calc_distances(TP, TD, pos(AgX,AgY)).
+*/
+
+!closest([],S,S,_,_).
+!closest([pos(XH,YH)|T],Aux,S,pos(XP,YP),LD)
: jia.path_length(XH,YH,XP,YP,D) & D < LD
@@ -112,7 +114,6 @@
+!closest([pos(XH,YH)|T],Aux,S,pos(XP,YP),LD)
<- .concat(Aux,[pos(XH,YH)],Aux2);
!closest(T,Aux2,S,pos(XP,YP),LD).
-*/
/* -- plans for the goals of all roles (herder and herdboy) -- */
Added: trunk/applications/jason-team/src/java/jia/cluster.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/cluster.java (rev 0)
+++ trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-03 20:26:40 UTC (rev 1286)
@@ -0,0 +1,124 @@
+package jia;
+
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.ListTermImpl;
+import jason.asSyntax.NumberTermImpl;
+import jason.asSyntax.ObjectTermImpl;
+import jason.asSyntax.Structure;
+import jason.asSyntax.Term;
+import jason.environment.grid.Location;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+
+import arch.CowboyArch;
+import arch.LocalWorldModel;
+import env.WorldModel;
+
+/**
+ * Computes a cluster of cows for the agent
+ *
+ * @author jomi
+ */
+public class cluster extends DefaultInternalAction {
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ CowboyArch arch = (CowboyArch)ts.getUserAgArch();
+ LocalWorldModel model = arch.getModel();
+ if (model == null)
+ return false;
+ //Location agLoc = model.getAgPos(arch.getMyId());
+
+ List<Location> locs = getCluster(model, WorldModel.cowPerceptionRatio);
+
+ if (args.length == 1) {
+ return un.unifies(args[0], new ObjectTermImpl(locs));
+ } else {
+ ListTerm r = new ListTermImpl();
+ ListTerm tail = r;
+ for (Location l: locs) {
+ Structure p = new Structure("pos",2);
+ p.addTerms(new NumberTermImpl(l.x), new NumberTermImpl(l.y));
+ tail = tail.append(p);
+ }
+ return un.unifies(args[0], new ObjectTermImpl(locs)) &&
+ un.unifies(args[1], r);
+ }
+ } catch (Throwable e) {
+ ts.getLogger().log(Level.SEVERE, "cluster error: "+e, e);
+ }
+ return false;
+ }
+
+ public static List<Location> getCluster(LocalWorldModel model, int maxDist) {
+ /*
+ Vs = set of all seen cows (sorted by distance to the centre of cluster)
+ Cs = { the cow near to the center of Vs }
+
+ add = true
+ while (add)
+ add = false
+ for all v in Vs
+ if (some cow in Cs sees v)
+ move v from Vs to Cs
+ add = true
+ */
+ Collection<Vec> cows = model.getCows();
+ Vec mean = Vec.mean( cows );
+ List<Vec> vs = new ArrayList<Vec>();
+ // place all cows in ref to mean
+ for (Vec v: cows)
+ vs.add(v.sub(mean));
+
+ Collections.sort(vs);
+
+ List<Vec> cs = new ArrayList<Vec>();
+ if (!vs.isEmpty())
+ cs.add(vs.remove(0));
+
+ boolean add = true;
+ while (add) {
+ add = false;
+ Iterator<Vec> i = vs.iterator();
+ while (i.hasNext()) {
+ Vec v = i.next();
+
+ Iterator<Vec> j = cs.iterator();
+ while (j.hasNext()) {
+ Vec c = j.next();
+ if (c.sub(v).magnitude() < maxDist) {
+ cs.add(v);
+ i.remove();
+ add = true;
+ break;
+ }
+ }
+ }
+ }
+
+ List<Location> clusterLocs = new ArrayList<Location>();
+ for (Vec v: cs) {
+ // place all cows in ref to 0,0
+ clusterLocs.add(v.add(mean).getLocation(model));
+ }
+
+ return clusterLocs;
+ }
+
+ public static List<Vec> location2vec(LocalWorldModel model, List<Location> clusterLocs) {
+ List<Vec> cows = new ArrayList<Vec>();
+ for (Location l: clusterLocs)
+ cows.add( new Vec(model, l));
+ return cows;
+ }
+}
+
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-03 14:16:12 UTC (rev 1285)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-03 20:26:40 UTC (rev 1286)
@@ -7,14 +7,12 @@
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
+import jason.asSyntax.ObjectTerm;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.environment.grid.Location;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
@@ -28,14 +26,18 @@
*
* the first argument is the formation id (one, two, ... 1, 2, ....)
*
- * if it is called with 3 args, returns the a free location in the formation
- * otherwise return a list of location for the formation
+ * the second is the cluster [ pos(X,Y), ..... ] (the term returned by jia.cluster)
+ *
+ * if it is called with 3 args, returns in the thrid arg the formation, a list
+ * in the format [pos(X,Y), .....]
+ *
+ * if it is called with 4 args, returns the a free location in the formation
+ * otherwise (3rd is X and 4th is Y)
*
* @author jomi
*/
public class herd_position extends DefaultInternalAction {
- public static final double maxStdDev = 3;
public static final int agDistanceInFormation = 4;
public enum Formation {
@@ -57,6 +59,7 @@
this.model = model;
}
+ @SuppressWarnings("unchecked")
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
@@ -75,23 +78,26 @@
formation = Formation.valueOf(args[0].toString());
}
+ // get the cluster
+ List<Location> clusterLocs = (List<Location>)((ObjectTerm)args[1]).getObject();
+
// update GUI
if (arch.hasGUI())
- setFormationLoc(formation);
+ setFormationLoc(clusterLocs, formation);
// if the return is a location for one agent
- if (args.length == 3) {
- Location agTarget = getAgTarget(formation, agLoc);
+ if (args.length == 4) {
+ Location agTarget = getAgTarget(clusterLocs, formation, agLoc);
if (agTarget != null) {
- return un.unifies(args[1], new NumberTermImpl(agTarget.x)) &&
- un.unifies(args[2], new NumberTermImpl(agTarget.y));
+ return un.unifies(args[2], new NumberTermImpl(agTarget.x)) &&
+ un.unifies(args[3], new NumberTermImpl(agTarget.y));
} else {
- ts.getLogger().info("No target! I am at "+agLoc+" places are "+formationPlaces(formation)+" cluster is "+lastCluster);
+ ts.getLogger().info("No target! I am at "+agLoc+" places are "+formationPlaces(clusterLocs, formation)+" cluster is "+lastCluster);
}
} else {
// return all the locations for the formation
- List<Location> locs = formationPlaces(formation);
- if (locs != null) {
+ List<Location> locs = formationPlaces(clusterLocs, formation);
+ if (locs != null && locs.size() > 0) {
ListTerm r = new ListTermImpl();
ListTerm tail = r;
for (Location l: locs) {
@@ -99,9 +105,9 @@
p.addTerms(new NumberTermImpl(l.x), new NumberTermImpl(l.y));
tail = tail.append(p);
}
- return un.unifies(args[1], r);
+ return un.unifies(args[2], r);
} else {
- ts.getLogger().info("No formation possible! I am at "+agLoc+" places are "+formationPlaces(formation));
+ ts.getLogger().info("No possible formation! I am at "+agLoc+" places are "+formationPlaces(clusterLocs, formation));
}
}
} catch (Throwable e) {
@@ -110,9 +116,9 @@
return false;
}
- public Location getAgTarget(Formation formation, Location ag) throws Exception {
+ public Location getAgTarget(List<Location> clusterLocs, Formation formation, Location ag) throws Exception {
Location r = null;
- List<Location> locs = formationPlaces(formation);
+ List<Location> locs = formationPlaces(clusterLocs, formation);
if (locs != null) {
for (Location l : locs) {
if (ag.equals(l) || // I am there
@@ -128,9 +134,9 @@
return r;
}
- public void setFormationLoc(Formation formation) throws Exception {
+ public void setFormationLoc(List<Location> clusterLocs, Formation formation) throws Exception {
model.removeAll(WorldModel.FORPLACE);
- List<Location> locs = formationPlaces(formation);
+ List<Location> locs = formationPlaces(clusterLocs, formation);
if (locs != null) {
for (Location l : locs) {
if (model.inGrid(l)) {
@@ -140,17 +146,11 @@
}
}
- private List<Location> formationPlaces(Formation formation) throws Exception {
- //cows = Vec.cluster(cows, 2); // find center/clusterise
-
- List<Vec>cows = cluster(model.getCows(), WorldModel.cowPerceptionRatio);
-
- List<Location> clusterLocs = new ArrayList<Location>();
- for (Vec v: cows) {
- clusterLocs.add(v.getLocation(model));
- }
+ private List<Location> formationPlaces(List<Location> clusterLocs, Formation formation) throws Exception {
lastCluster = clusterLocs;
+ List<Vec> cows = cluster.location2vec(model, clusterLocs);
+
if (cows.isEmpty())
return null;
@@ -240,59 +240,6 @@
return t;
}
- public static List<Vec> cluster(Collection<Vec> cows, int maxDist) {
- /*
- Vs = set of all seen cows (sorted by distance to the centre of cluster)
- Cs = { the cow near to the center of Vs }
-
- add = true
- while (add)
- add = false
- for all v in Vs
- if (some cow in Cs sees v)
- move v from Vs to Cs
- add = true
- */
- Vec mean = Vec.mean(cows);
- List<Vec> vs = new ArrayList<Vec>();
- // place all cows in ref to mean
- for (Vec v: cows)
- vs.add(v.sub(mean));
-
- Collections.sort(vs);
-
- List<Vec> cs = new ArrayList<Vec>();
- if (!vs.isEmpty())
- cs.add(vs.remove(0));
-
- boolean add = true;
- while (add) {
- add = false;
- Iterator<Vec> i = vs.iterator();
- while (i.hasNext()) {
- Vec v = i.next();
-
- Iterator<Vec> j = cs.iterator();
- while (j.hasNext()) {
- Vec c = j.next();
- if (c.sub(v).magnitude() < maxDist) {
- cs.add(v);
- i.remove();
- add = true;
- break;
- }
- }
- }
- }
-
- List<Vec> r = new ArrayList<Vec>();
- // place all cows in ref to 0,0
- for (Vec v: cs)
- r.add(v.add(mean));
- return r;
- }
-
-
/*
public Location nearFreeForAg(LocalWorldModel model, Location ag, Location t) throws Exception {
// run A* to get the path from ag to t
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-03 14:16:12 UTC (rev 1285)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-03 20:26:40 UTC (rev 1286)
@@ -9,6 +9,7 @@
import jia.Search;
import jia.Vec;
+import jia.cluster;
import jia.herd_position;
import jia.scouter_pos;
import jia.herd_position.Formation;
@@ -69,7 +70,7 @@
}
}
- List<Vec> cowsl = herd_position.cluster(model.getCows(), WorldModel.cowPerceptionRatio);
+ List<Location> cowsl = cluster.getCluster(model, WorldModel.cowPerceptionRatio);
assertEquals(model.getCows().size(), cowsl.size());
}
@@ -156,7 +157,8 @@
scenario1();
// find center/clusterise
- List<Vec> cowsl = herd_position.cluster(model.getCows(), WorldModel.cowPerceptionRatio);
+ List<Location> clusterLocs = cluster.getCluster(model, WorldModel.cowPerceptionRatio);
+ List<Vec> cowsl = cluster.location2vec(model, clusterLocs);
//Vec stddev = Vec.stddev(cowsl, Vec.mean(cowsl));
assertEquals(3, cowsl.size());
@@ -172,30 +174,30 @@
herd_position hp = new herd_position();
hp.setModel(model);
- Location byIA = hp.getAgTarget(Formation.one, cowboy.getLocation(model));
+ Location byIA = hp.getAgTarget(clusterLocs, Formation.one, cowboy.getLocation(model));
assertEquals(new Location(6,38), byIA);
- byIA = hp.getAgTarget(Formation.six, cowboy.getLocation(model));
+ byIA = hp.getAgTarget(clusterLocs, Formation.six, cowboy.getLocation(model));
assertEquals(new Location(6,39), byIA);
// add an agent in 6,39
model.add(WorldModel.AGENT, 6,39);
- byIA = hp.getAgTarget(Formation.six, cowboy.getLocation(model));
+ byIA = hp.getAgTarget(clusterLocs, Formation.six, cowboy.getLocation(model));
assertEquals(new Location(5,38), byIA);
// add an agent in 5,38
model.add(WorldModel.AGENT, 5,38);
- byIA = hp.getAgTarget(Formation.six,cowboy.getLocation(model));
+ byIA = hp.getAgTarget(clusterLocs, Formation.six,cowboy.getLocation(model));
assertEquals(new Location(7,42), byIA);
// add an agent in 7,42
model.add(WorldModel.AGENT, 7,42);
- byIA = hp.getAgTarget(Formation.six,cowboy.getLocation(model));
+ byIA = hp.getAgTarget(clusterLocs, Formation.six,cowboy.getLocation(model));
assertEquals(new Location(4,38), byIA);
// add an agent in 4,38
model.add(WorldModel.AGENT, 4,38);
- byIA = hp.getAgTarget(Formation.six,cowboy.getLocation(model));
+ byIA = hp.getAgTarget(clusterLocs, Formation.six,cowboy.getLocation(model));
assertEquals(null, byIA);
// add an agent in 5,37
@@ -209,13 +211,14 @@
scenario2();
model.add(WorldModel.ENEMY, 11,48);
- List<Vec> cowsl = herd_position.cluster(model.getCows(), WorldModel.cowPerceptionRatio);
+ List<Location> clusterLocs = cluster.getCluster(model, WorldModel.cowPerceptionRatio);
+ List<Vec> cowsl = cluster.location2vec(model, clusterLocs);
assertEquals(9, cowsl.size());
herd_position hp = new herd_position();
hp.setModel(model);
- Location byIA = hp.getAgTarget(Formation.one, cowboy.getLocation(model));
+ Location byIA = hp.getAgTarget(clusterLocs, Formation.one, cowboy.getLocation(model));
assertEquals(new Location(11,49), byIA);
}
Modified: trunk/src/jason/asSyntax/ListTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/ListTermImpl.java 2008-05-03 14:16:12 UTC (rev 1285)
+++ trunk/src/jason/asSyntax/ListTermImpl.java 2008-05-03 20:26:40 UTC (rev 1286)
@@ -137,7 +137,6 @@
return null;
}
-
// for unifier compatibility
@Override
public int getArity() {
@@ -160,7 +159,7 @@
@Override
public void setTerm(int i, Term t) {
if (i == 0) term = t;
- if (i == 1) System.out.println("Should not set next of list!");
+ if (i == 1) next = t;
}
/** return the this ListTerm elements (0=Term, 1=ListTerm) */
Modified: trunk/src/jason/asSyntax/ObjectTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/ObjectTermImpl.java 2008-05-03 14:16:12 UTC (rev 1285)
+++ trunk/src/jason/asSyntax/ObjectTermImpl.java 2008-05-03 20:26:40 UTC (rev 1286)
@@ -27,6 +27,8 @@
@Override
public boolean equals(Object o) {
+ if (this.o == null) return false;
+ if (o == null) return false;
return this.o.equals(o);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-04 08:55:06
|
Revision: 1287
http://jason.svn.sourceforge.net/jason/?rev=1287&view=rev
Author: jomifred
Date: 2008-05-04 01:55:03 -0700 (Sun, 04 May 2008)
Log Message:
-----------
jason team: basic herding working
Modified Paths:
--------------
trunk/applications/as-unit-test/build.xml
trunk/applications/jason-team/readme.txt
trunk/applications/jason-team/src/asl/goto.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/src/jason/stdlib/delete.java
trunk/src/jason/stdlib/min.java
Modified: trunk/applications/as-unit-test/build.xml
===================================================================
--- trunk/applications/as-unit-test/build.xml 2008-05-03 20:26:40 UTC (rev 1286)
+++ trunk/applications/as-unit-test/build.xml 2008-05-04 08:55:03 UTC (rev 1287)
@@ -42,7 +42,7 @@
</target>
<target name="test" depends="jar">
- <ant dir="../.." target="jar" />
+ <ant dir="../.." target="jar" inheritall="false"/>
<junit printsummary="yes" failureProperty="test.failure">
<classpath refid="project.classpath" />
<classpath path="${build.dir}" />
Modified: trunk/applications/jason-team/readme.txt
===================================================================
--- trunk/applications/jason-team/readme.txt 2008-05-03 20:26:40 UTC (rev 1286)
+++ trunk/applications/jason-team/readme.txt 2008-05-04 08:55:03 UTC (rev 1287)
@@ -17,13 +17,13 @@
svn update
ant plugin
- cd applications/jason-moise
- ant jar
-
2. run massim-server
cd applications/jason-team/massim-server
./startServer.sh
-
+
+ or some configuration for test
+ ./startServerTest.sh conf/<some conf file>.xml
+
3. run dummies (written in Jason)
ant -f dummies.xml
@@ -44,10 +44,15 @@
6. you can get the agents location with the command
- tail -f world-status.txt
+ tail -f world-status.txt
+
+ you can see the agent mind state with
+
+ ant -f gauchos.xml mind-view
+
-7. the get the graphical view of some agent, add gui=yes in
- the agent's option (.mas2j file)
+7. to enable/disable the graphical view of some agent, add gui=yes
+ or gui=no in the agent's option (.mas2j file)
Modified: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl 2008-05-03 20:26:40 UTC (rev 1286)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-05-04 08:55:03 UTC (rev 1287)
@@ -24,6 +24,9 @@
-at_target;
!!move.
+-target(_,_) // if I receive a message untell for my target, remove all target from BB
+ <- .abolish(target(_,_)).
+
// I still do not know my location
/*
+!move
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-03 20:26:40 UTC (rev 1286)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-04 08:55:03 UTC (rev 1287)
@@ -87,26 +87,26 @@
+!alloc_all([HA|TA],LA)
<- !find_closest(HA,LA,pos(X,Y),NLA);
.print("ooo Alocating position ",pos(X,Y)," to agent ",HA);
+ .send(HA,untell,target(_,_));
.send(HA,tell,target(X,Y));
//-+alloc_target(HA,Alloc);
!alloc_all(TA,NLA).
+!find_closest(Ag, ListPos, MinDist, Rest) // find the location in ListPos nearest to agent Ag
<- ?ally_pos(Ag,X,Y);
- .print("ooo try to alloc ",Ag," in ",X,Y," with ",ListPos);
- //?calc_distances(ListPos,Distances,pos(X,Y));
- //.print("Distances for ",ag_pos(Ag,X,Y)," are ",Distances);
- //.min(Distances,d(_,MinDist));
- //.delete(d(_,MinDist),Distances,Rest);
- //.print("rest is ",Rest).
- !closest(ListPos,[],[MinDist|Rest],pos(X,Y),9999).
+ //.print("ooo try to alloc ",Ag," in ",X,Y," with ",ListPos);
+ ?calc_distances(ListPos,Distances,pos(X,Y));
+ .print("Distances for ",ag_pos(Ag,X,Y)," are ",Distances);
+ .min(Distances,d(_,MinDist));
+ .delete(MinDist,ListPos,Rest).
+ //!closest(ListPos,[],[MinDist|Rest],pos(X,Y),9999).
-/*
+
calc_distances([],[],_) :- true.
calc_distances([pos(Fx,Fy)|TP], [d(D,pos(Fx,Fy))|TD], pos(AgX,AgY))
- :- .print("calc dist from for ag ",pos(AgX,AgY)) & jia.path_length(Fx,Fy,AgX,AgY,D) & calc_distances(TP, TD, pos(AgX,AgY)).
-*/
+ :- jia.path_length(Fx,Fy,AgX,AgY,D) & calc_distances(TP, TD, pos(AgX,AgY)).
+/*
+!closest([],S,S,_,_).
+!closest([pos(XH,YH)|T],Aux,S,pos(XP,YP),LD)
: jia.path_length(XH,YH,XP,YP,D) & D < LD
@@ -114,6 +114,7 @@
+!closest([pos(XH,YH)|T],Aux,S,pos(XP,YP),LD)
<- .concat(Aux,[pos(XH,YH)],Aux2);
!closest(T,Aux2,S,pos(XP,YP),LD).
+*/
/* -- plans for the goals of all roles (herder and herdboy) -- */
Modified: trunk/src/jason/stdlib/delete.java
===================================================================
--- trunk/src/jason/stdlib/delete.java 2008-05-03 20:26:40 UTC (rev 1286)
+++ trunk/src/jason/stdlib/delete.java 2008-05-04 08:55:03 UTC (rev 1287)
@@ -113,7 +113,7 @@
if (u)
un = bak.copy();
else
- last = last.append(t);
+ last = last.append((Term)t.clone());
}
return r;
}
@@ -124,7 +124,7 @@
int i = 0;
for (Term t: l) {
if ((i++) != index)
- last = last.append(t);
+ last = last.append((Term)t.clone());
}
return r;
}
Modified: trunk/src/jason/stdlib/min.java
===================================================================
--- trunk/src/jason/stdlib/min.java 2008-05-03 20:26:40 UTC (rev 1286)
+++ trunk/src/jason/stdlib/min.java 2008-05-04 08:55:03 UTC (rev 1287)
@@ -87,7 +87,7 @@
min = t;
}
}
- return un.unifies(args[1], min);
+ return un.unifies(args[1], (Term)min.clone());
} catch (ArrayIndexOutOfBoundsException e) {
throw new JasonException("The internal action 'max/min' has not received two arguments.");
} catch (JasonException e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-04 21:50:38
|
Revision: 1290
http://jason.svn.sourceforge.net/jason/?rev=1290&view=rev
Author: jomifred
Date: 2008-05-04 14:50:33 -0700 (Sun, 04 May 2008)
Log Message:
-----------
use the xsl stored in SF in the XML file generated on for the agent's mind
Modified Paths:
--------------
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
trunk/src/jason/asSemantics/Agent.java
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-04 21:17:05 UTC (rev 1289)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-04 21:50:33 UTC (rev 1290)
@@ -109,7 +109,8 @@
// store the agent'd mind
if (dirmind != null) {
String agmind = new asl2xml().transform(owner.getTS().getAg().getAgState());
- FileWriter outmind = new FileWriter(new File(dirmind.getName()+"/"+owner.getCycle()+".xml"));
+ String filename = String.format("%5d.xml",owner.getCycle()).replaceAll(" ","0");
+ FileWriter outmind = new FileWriter(new File(dirmind.getName()+"/"+filename));
outmind.write(agmind);
outmind.close();
}
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-05-04 21:17:05 UTC (rev 1289)
+++ trunk/src/jason/asSemantics/Agent.java 2008-05-04 21:50:33 UTC (rev 1290)
@@ -679,7 +679,7 @@
}
}
Document document = builder.newDocument();
- document.appendChild(document.createProcessingInstruction("xml-stylesheet", "href='agInspection.xsl' type='text/xsl' "));
+ document.appendChild(document.createProcessingInstruction("xml-stylesheet", "href='http://jason.sf.net/xml/agInspection.xsl' type='text/xsl' "));
Element ag = getAsDOM(document);
document.appendChild(ag);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-06 22:06:59
|
Revision: 1292
http://jason.svn.sourceforge.net/jason/?rev=1292&view=rev
Author: jomifred
Date: 2008-05-06 15:06:56 -0700 (Tue, 06 May 2008)
Log Message:
-----------
jason team: merge of herding team (does not work correctly yet)
Modified Paths:
--------------
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/arch/ACProxy.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
trunk/applications/jason-team/src/team-os.xml
trunk/src/jason/environment/grid/GridWorldView.java
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-06 22:06:56 UTC (rev 1292)
@@ -18,32 +18,44 @@
host="localhost", port=12300, username=participant1, password="1"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
+ "target(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "group_area(key, _, _)");
gaucho2 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant2, password="2"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
+ "target(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "group_area(key, _, _)");
gaucho3 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant3, password="3"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
+ "target(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "group_area(key, _, _)");
gaucho4 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant4, password="4"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
+ "target(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "group_area(key, _, _)");
gaucho5 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant5, password="5"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
+ "target(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "group_area(key, _, _)");
gaucho6 gaucho.asl
[verbose=1,host="localhost", port=12300, username=participant6, password="6"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
+ "target(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "group_area(key, _, _)");
directives: maintenance_goal = agent.OrgMaintenanceGoal;
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-06 22:06:56 UTC (rev 1292)
@@ -5,7 +5,7 @@
/* -- initial goals -- */
-!create_team_group.
+//!create_team_group.
/*
-- plans for new match
@@ -15,48 +15,49 @@
/* plans for the team's groups creation */
+/*
+!create_team_group
: .my_name(gaucho1)
<- .print("oooo creating new team group ------------------------------------------------- ");
!remove_org;
jmoise.create_group(team).
+!create_team_group.
+*/
-+group(team,GId) // agent 1 is responsible for the creation of exploration groups
+/*+group(team,GId) // agent 1 is responsible for the creation of exploration groups
: .my_name(gaucho1)
<- jmoise.create_group(exploration_grp,GId);
jmoise.create_group(exploration_grp,GId);
- jmoise.create_group(exploration_grp,GId).
-+group(exploration_grp,_) // compute the area of the groups
- : .my_name(gaucho1) &
- group(team,TeamId) &
- .findall(GId, group(exploration_grp,GId)[super_gr(TeamId)], LG) &
- LG = [G1,G2,G3] // there are three groups
- <- ?gsize(W,H);
- X = math.round(((W*H)/3)/H);
- +group_area(0, G1, area(0, 0, X, H-1));
- +group_area(1, G2, area(X+1, 0, W-1, H/2));
- +group_area(2, G3, area(X+1, (H/2)+1, W-1, H-1)).
+ jmoise.create_group(exploration_grp,GId). */
+
-
-+group_area(ID,G,A)[source(self)]
- <- .broadcast(tell, group_area(ID,G,A)).
-
-
/* plans for agents with odd id */
+gsize(_,_) // new match has started
: .my_name(Me) &
agent_id(Me,AgId) &
AgId mod 2 == 1 // I have an odd Id
- <- //.if( .my_name(gaucho1) ) {
- // !create_team_group
- //};
+ <- !create_exploration_gr.
- .print("ooo Recruiting scouters for my explorer group....");
++!create_exploration_gr
+ <- .my_name(Me);
+
+ // create the team
+ .if( Me == gaucho1 & not group(team,_) ) {
+ jmoise.create_group(team)
+ };
+
+ // wait the team creation
+ ?group(team,TeamGroup);
+
+ .if( not group(exploration_grp,_)[owner(Me)]) {
+ jmoise.create_group(exploration_grp,TeamGroup);
+ .wait("+group(exploration_grp,G)[owner(Me)]")
+ };
+
+ .print("ooo Recruiting scouters for my explorer group ",G);
- // wait my pos
- ?pos(MyX,MyY,_);
+ ?pos(MyX,MyY,_); // wait my pos
// wait others pos
.while( .count(ally_pos(_,_,_), N) & N < 5 ) {
@@ -71,8 +72,8 @@
.sort(LOdd, LSOdd);
// test if I received the area of my group
- ?group_area(AgId div 2,G,A);
- .print("ooo Scouters candidates =", LSOdd," in area ",group_area(AgId div 2,G,A));
+ ?group_area(AreaId,G,A);
+ .print("ooo Scouters candidates =", LSOdd," in area ",group_area(AreaId,G,A));
// adopt role explorer in the group
jmoise.adopt_role(explorer,G);
@@ -94,7 +95,31 @@
not scheme_group(_,G)
<- jmoise.create_scheme(explore_sch, [G]).
+// If I stop playing explorer, destroy the explore groups I've created
+-play(Ag,explorer,_)
+ : .my_name(Ag)
+ <- .wait(4000);
+ .for( group(exploration_grp,G)[owner(Me)] ) {
+ jmoise.remove_group(G);
+ .wait(4000)
+ }.
+
++group(exploration_grp,_) // compute the area of the groups
+ : .my_name(gaucho1) &
+ group(team,TeamId) &
+ .findall(GId, group(exploration_grp,GId)[super_gr(TeamId)], LG) &
+ LG = [G1,G2,G3] // there are three groups
+ <- ?gsize(W,H);
+ X = math.round(((W*H)/3)/H);
+ +group_area(0, G1, area(0, 0, X, H-1));
+ +group_area(1, G2, area(X+1, 0, W-1, H/2));
+ +group_area(2, G3, area(X+1, (H/2)+1, W-1, H-1)).
+
++group_area(ID,G,A)[source(self)]
+ <- .broadcast(tell, group_area(ID,G,A)).
+
+
/* -- plans for the goals of role explorer -- */
{ begin maintenance_goal("+pos(_,_,_)") }
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-06 22:06:56 UTC (rev 1292)
@@ -42,20 +42,20 @@
+?pos(X, Y, S) <- .wait("+pos(X,Y,S)").
+?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
+?gsize(W,H) <- .wait("+gsize(W,H)").
++?group(T,G) <- .wait("+group(T,G)").
+?ally_pos(Name,X,Y) : .my_name(Name) <- ?pos(X,Y,_).
+end_of_simulation(_Result)
- <- .abolish(group_area(_,_,_));
+ <- -end_of_simulation(_);
+ .drop_all_desires;
!remove_org.
-+!restart.
-
-/* <- .print("*** restart ***").
++!restart
+ <- //.print("*** restart ***");
//.drop_all_desires;
- //.abolish(target(_,_)).
+ .abolish(cow(_,_,_)).
// TODO: what to do?
//!decide_target.
-*/
/* -- plans for the goals of all roles -- */
@@ -77,7 +77,8 @@
+!remove_org
: .my_name(gaucho1)
<- .if( group(team,Old) ) {
- jmoise.remove_group(Old)
+ jmoise.remove_group(Old);
+ .wait("-group(team,_)")
};
.for( scheme(_,SchId)) {
@@ -98,6 +99,43 @@
?play(Me,R,Gid);
.findall(P, play(P,_,Gid), G).
+
++!change_role(R,G)
+ : .my_name(Me) & play(Me, R,G).
+
++!change_role(NewRole,GT)[source(S)]
+ : not .desire(change_role(_,_)) // to not trigger two change of role
+ <- .my_name(Me);
+ .print("ooo Adopting the role ",NewRole," in group ",GT,", as asked by ",S);
+
+ // give up all missions
+ .while( commitment(Me,M,Sch) ) {
+ jmoise.remove_mission(M,Sch);
+ .wait("-commitment(Me,M,Sch)")
+ };
+
+ // if I play herder in another group, ...
+ .if( play(Me,herder,G) & G \== GT) {
+ // ask all herdboys to also change the group
+ ?my_group_players(HerdBoys, herder);
+ .send(HerdBoys, achieve, change_role(herdboy,GT))
+ };
+
+ // if I play any other role, give it up
+ .while( play(Me,R,OG) & OG \== GT) {
+ jmoise.remove_role(R,OG);
+ .wait("-play(Me,R,OG)")
+ };
+
+ jmoise.adopt_role(NewRole,GT);
+ .wait("+play(Me,NewRole,GT)").
+
++!change_role(NewRole,GT)[source(S)]
+ <- .print("ooo I cannot adopt the role ",NewRole," in group ",GT,", as asked by ",S).
+
+
++!play_role(Role,Group)
+ : .my_name(Me) & play(Me,R,G).
+!play_role(Role,Group)[source(Ag)]
<- .print("ooo Adopting role ",Role," in group ",Group,", asked by ",Ag);
jmoise.adopt_role(Role, Group).
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-06 22:06:56 UTC (rev 1292)
@@ -5,7 +5,6 @@
/* -- plans for herding groups creation -- */
// if see cow and is not herding, create the herding group and change roles
-@lcs[atomic]
+cow(_,_,_)
: .my_name(Me) &
play(Me,explorer,_) &
@@ -20,44 +19,38 @@
?group(team,TeamId);
jmoise.create_group(herding_grp, TeamId);
.wait("+group(herding_grp, HG)[owner(Me)]", 4000);
+ .print("ooo Group ",HG," created.");
// store the list of scouter in my group
?play(Me,explorer,EG);
.findall(Scouter,play(Scouter,scouter,EG),LScouters);
!change_role(herder,HG);
+ .wait("+play(Me,herder,FinalHerdingGroup)");
// ask scouters to change role
- .print("ooo Asking ",LScouters," to adopt the herdboy role");
- .send(LScouters,achieve,change_role(herdboy,HG)).
-
-
-+!change_role(herder,HG)
- <- .my_name(Me);
- .if (commitment(Me,explore,Sch)) {
- jmoise.remove_mission(explore,Sch)
- };
- .if (play(Me,explorer,EG)) {
- jmoise.remove_role(explorer,EG)
- };
- jmoise.adopt_role(herder,HG).
+ .print("ooo Asking ",LScouters," to adopt the herdboy role in ",FinalHerdingGroup);
+ .send(LScouters,achieve,change_role(herdboy,FinalHerdingGroup)).
-+!change_role(herdboy,HG)
- <- .my_name(Me);
- .if (commitment(Me,scout,Sch)) {
- jmoise.remove_mission(scout,Sch)
- };
- .if (play(Me,scouter,EG)) {
- jmoise.remove_role(scouter,EG)
- };
- jmoise.adopt_role(herdboy,HG).
-
// If if start playing explorer in a group that has no scheme, create the scheme
-+play(Ag,herder,G)
- : .my_name(Ag) &
++play(Me,herder,G)
+ : .my_name(Me) &
not scheme_group(_,G)
- <- jmoise.create_scheme(herd_sch, [G]).
+ <- jmoise.create_scheme(herd_sch, [G]);
+ +group_leader(G,Me);
+ .broadcast(tell, group_leader(G,Me)).
+
+// If I stop playing herder, destroy the herding groups I've created
+-play(Ag,herder,_)
+ : .my_name(Ag)
+ <- .wait(4000);
+ .for( group(herding_grp,G)[owner(Me)] ) {
+ -group_leader(G,Me);
+ .broadcast(untell, group_leader(G,Me));
+ jmoise.remove_group(G);
+ .wait(4000)
+ }.
/* -- plans for the goals of role herder -- */
@@ -65,11 +58,29 @@
{ begin maintenance_goal("+pos(_,_,_)") }
+!recruit[scheme(Sch),mission(Mission)]
- <- .print("ooo I should revise the size of the cluster and recruit!").
+ <- .print("ooo I should revise the size of the cluster and recruit!");
+ !check_merge.
{ end }
-
++!check_merge
+ : .my_name(Me) &
+ play(Me, herder, Gi) &
+ current_cluster(MyC)
+ <- // for all other groups
+ .for( group_leader(Gj, L) & L \== Me & Me < L) {
+ .print("ooo Checking merging with ",Gj);
+ // ask their cluster
+ .send(L, askOne, current_cluster(_), current_cluster(TC));
+ .intersection(MyC,TC,I);
+
+ .if (.length(I) > 0) {
+ .print("ooo Merging my herding group ",Gi," with ",Gj, " lead by ",L);
+ .send(L, achieve, change_role(herdboy,Gi))
+ }
+ }.
++!check_merge.
+
{ begin maintenance_goal("+pos(_,_,_)") }
+!define_formation[scheme(Sch),mission(Mission)]
@@ -116,6 +127,7 @@
!closest(T,Aux2,S,pos(XP,YP),LD).
*/
+
/* -- plans for the goals of all roles (herder and herdboy) -- */
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-05-06 22:06:56 UTC (rev 1292)
@@ -203,12 +203,12 @@
}
}
+ //if (logger.isLoggable(Level.FINE))
+ logger.info("Request action for "+lpos+" / rid: "+rid+" / percepts: "+percepts);
//arq.sendCowsToTeam();
arq.startNextStep(step, percepts);
- //if (logger.isLoggable(Level.FINE))
- logger.info("Request action for "+lpos+" / rid: "+rid+" / percepts: "+percepts);
} catch (Exception e) {
logger.log(Level.SEVERE, "error processing request",e);
}
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-06 22:06:56 UTC (rev 1292)
@@ -146,7 +146,7 @@
}
}
- private List<Location> formationPlaces(List<Location> clusterLocs, Formation formation) throws Exception {
+ public List<Location> formationPlaces(List<Location> clusterLocs, Formation formation) throws Exception {
lastCluster = clusterLocs;
List<Vec> cows = cluster.location2vec(model, clusterLocs);
@@ -180,8 +180,12 @@
Location l = findFirstFreeLocTowardsTarget(agTarget, mean.add(agsTarget), initAgTS, dist, model);
//System.out.println(" = "+dist+" result "+l);
- if (l != null)
- r.add(pathToNearCow(l, clusterLocs));
+ if (l != null) {
+ l = pathToNearCow(l, clusterLocs);
+ if ( ! model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l))
+ l = model.nearFree(l);
+ r.add( l );
+ }
/*
Location lastloc = null;
@@ -210,7 +214,7 @@
public static Location findFirstFreeLocTowardsTarget(Vec target, Vec ref, int initialSize, int maxSize, LocalWorldModel model) {
Location lastloc = null;
maxSize = Math.abs(maxSize);
- Location l = ref.getLocation(model);;
+ Location l = ref.getLocation(model);
for (int s = initialSize; s <= maxSize; s++) {
l = target.newMagnitude(s).add(ref).getLocation(model);
//System.out.println("pos angle "+s+" = "+l);
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-06 22:06:56 UTC (rev 1292)
@@ -220,6 +220,9 @@
Location byIA = hp.getAgTarget(clusterLocs, Formation.one, cowboy.getLocation(model));
assertEquals(new Location(11,49), byIA);
+
+ List<Location> form = hp.formationPlaces(clusterLocs, Formation.four);
+ assertEquals("[6,48, 11,49, 6,48, 11,49]", form.toString());
}
@Test
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-06 22:06:56 UTC (rev 1292)
@@ -95,10 +95,10 @@
<scheme id="herd_sch" >
<goal id="herd_cows" >
<plan operator="parallel">
- <goal id="recruit" ds="recruit more herdboys depending on the size of the cows cluster" type="maintenance"/>
- <goal id="define_formation" ds="compute the ideal location of each member of the group and share this information with them" type="maintenance"/>
- <goal id="be_in_formation" ds="go to the place allocated to the agent in the formation" type="maintenance"/>
- <goal id="share_seen_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/>
+ <goal id="recruit" ds="recruit more herdboys depending on the size of the cows cluster" type="maintenance"/>
+ <goal id="define_formation" ds="compute the ideal location of each member of the group and share this information with them" type="maintenance"/>
+ <goal id="be_in_formation" ds="go to the place allocated to the agent in the formation" type="maintenance"/>
+ <goal id="share_seen_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/>
</plan>
</goal>
Modified: trunk/src/jason/environment/grid/GridWorldView.java
===================================================================
--- trunk/src/jason/environment/grid/GridWorldView.java 2008-05-05 18:33:43 UTC (rev 1291)
+++ trunk/src/jason/environment/grid/GridWorldView.java 2008-05-06 22:06:56 UTC (rev 1292)
@@ -56,8 +56,10 @@
/** updates only one position of the grid */
public void update(int x, int y) {
- drawEmpty(drawArea.getGraphics(), x, y);
- draw(drawArea.getGraphics(), x, y);
+ Graphics g = drawArea.getGraphics();
+ if (g == null) return;
+ drawEmpty(g, x, y);
+ draw(g, x, y);
}
public void drawObstacle(Graphics g, int x, int y) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-07 08:15:40
|
Revision: 1293
http://jason.svn.sourceforge.net/jason/?rev=1293&view=rev
Author: jomifred
Date: 2008-05-07 01:15:38 -0700 (Wed, 07 May 2008)
Log Message:
-----------
fix bug in desire (related to source(self) in goals)
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/stdlib/desire.java
trunk/src/jason/stdlib/wait.java
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-06 22:06:56 UTC (rev 1292)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-07 08:15:38 UTC (rev 1293)
@@ -38,7 +38,7 @@
agent_id(Me,AgId) &
AgId mod 2 == 1 // I have an odd Id
<- !create_exploration_gr.
-
+
+!create_exploration_gr
<- .my_name(Me);
@@ -61,8 +61,8 @@
// wait others pos
.while( .count(ally_pos(_,_,_), N) & N < 5 ) {
- .print("ooo waiting others pos ");
- .wait("+ally_pos(_,_,_)", 500, nofail)
+ .print("ooo waiting others pos ");
+ .wait("+ally_pos(_,_,_)", 500, _)
};
// find distance to even agents
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-06 22:06:56 UTC (rev 1292)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-07 08:15:38 UTC (rev 1293)
@@ -101,7 +101,7 @@
+!change_role(R,G)
- : .my_name(Me) & play(Me, R,G).
+ : .my_name(Me) & play(Me,R,G).
+!change_role(NewRole,GT)[source(S)]
: not .desire(change_role(_,_)) // to not trigger two change of role
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-06 22:06:56 UTC (rev 1292)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-07 08:15:38 UTC (rev 1293)
@@ -81,6 +81,7 @@
}.
+!check_merge.
+
{ begin maintenance_goal("+pos(_,_,_)") }
+!define_formation[scheme(Sch),mission(Mission)]
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-05-06 22:06:56 UTC (rev 1292)
+++ trunk/src/jason/asSemantics/Agent.java 2008-05-07 08:15:38 UTC (rev 1293)
@@ -353,6 +353,8 @@
public void addInitialGoalsInTS() {
for (Literal g: initialGoals) {
g.makeVarsAnnon();
+ if (! g.hasSource())
+ g.addAnnot(BeliefBase.TSelf);
getTS().getC().addAchvGoal(g,Intention.EmptyInt);
}
}
Modified: trunk/src/jason/stdlib/desire.java
===================================================================
--- trunk/src/jason/stdlib/desire.java 2008-05-06 22:06:56 UTC (rev 1292)
+++ trunk/src/jason/stdlib/desire.java 2008-05-07 08:15:38 UTC (rev 1293)
@@ -79,7 +79,7 @@
public boolean desires(Circumstance C, Literal l, Unifier un) {
Trigger teFromL = new Trigger(TEOperator.add, TEType.achieve, l);
- // we need to check the slected event in this cycle (already removed from E)
+ // we need to check the selected event in this cycle (already removed from E)
if (C.getSelectedEvent() != null) {
Trigger t = C.getSelectedEvent().getTrigger();
Intention i = C.getSelectedEvent().getIntention();
@@ -87,7 +87,7 @@
t = (Trigger) t.clone();
t.apply(i.peek().getUnif());
}
- if (un.unifies(t, teFromL)) {
+ if (un.unifies(teFromL, t)) {
return true;
}
}
@@ -99,7 +99,7 @@
t = (Trigger) t.clone();
t.apply(i.peek().getUnif());
}
- if (un.unifies(t, teFromL)) {
+ if (un.unifies(teFromL, t)) {
return true;
}
}
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-05-06 22:06:56 UTC (rev 1292)
+++ trunk/src/jason/stdlib/wait.java 2008-05-07 08:15:38 UTC (rev 1293)
@@ -237,7 +237,6 @@
e.printStackTrace();
}
}
- //elapseTime = System.currentTimeMillis() - init;
}
synchronized public void eventAdded(Event e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-07 10:12:31
|
Revision: 1294
http://jason.svn.sourceforge.net/jason/?rev=1294&view=rev
Author: jomifred
Date: 2008-05-07 03:12:25 -0700 (Wed, 07 May 2008)
Log Message:
-----------
jason team: fix some bugs, improve merging
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
trunk/src/jason/stdlib/foreach.java
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-07 08:15:38 UTC (rev 1293)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-07 10:12:25 UTC (rev 1294)
@@ -90,16 +90,17 @@
!find_scouter(LSOdd,GId).
// If if start playing explorer in a group that has no scheme, create the scheme
-+play(Ag,explorer,G)
- : .my_name(Ag) &
++play(Me,explorer,G)
+ : .my_name(Me) &
not scheme_group(_,G)
<- jmoise.create_scheme(explore_sch, [G]).
// If I stop playing explorer, destroy the explore groups I've created
--play(Ag,explorer,_)
- : .my_name(Ag)
+-play(Me,explorer,_)
+ : .my_name(Me)
<- .wait(4000);
.for( group(exploration_grp,G)[owner(Me)] ) {
+ .print("ooo Removing group ",G," since I am not in the group anymore");
jmoise.remove_group(G);
.wait(4000)
}.
@@ -131,7 +132,8 @@
?group_area(_,GroupId, Area); // get the area of this group
?pos(MeX, MeY, _); // get my location
jia.near_least_visited(MeX, MeY, Area, TargetX, TargetY);
- -+target(TargetX, TargetY).
+ -+target(TargetX, TargetY);
+ .wait("+at_target",10000,_).
/* added by the pattern
.wait("+pos(_,_,_)"); // wait next cycle
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-07 08:15:38 UTC (rev 1293)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-07 10:12:25 UTC (rev 1294)
@@ -81,7 +81,7 @@
.wait("-group(team,_)")
};
- .for( scheme(_,SchId)) {
+ .for( scheme(_,SchId) ) {
jmoise.remove_scheme(SchId)
}.
+!remove_org.
@@ -104,7 +104,6 @@
: .my_name(Me) & play(Me,R,G).
+!change_role(NewRole,GT)[source(S)]
- : not .desire(change_role(_,_)) // to not trigger two change of role
<- .my_name(Me);
.print("ooo Adopting the role ",NewRole," in group ",GT,", as asked by ",S);
@@ -117,7 +116,7 @@
// if I play herder in another group, ...
.if( play(Me,herder,G) & G \== GT) {
// ask all herdboys to also change the group
- ?my_group_players(HerdBoys, herder);
+ .findall(Boy,play(Boy,herdboy,G),HerdBoys);
.send(HerdBoys, achieve, change_role(herdboy,GT))
};
@@ -130,11 +129,11 @@
jmoise.adopt_role(NewRole,GT);
.wait("+play(Me,NewRole,GT)").
-+!change_role(NewRole,GT)[source(S)]
- <- .print("ooo I cannot adopt the role ",NewRole," in group ",GT,", as asked by ",S).
+//+!change_role(NewRole,GT)[source(S)]
+// <- .print("ooo I cannot adopt the role ",NewRole," in group ",GT,", as asked by ",S).
-+!play_role(Role,Group)
++!play_role(R,G)
: .my_name(Me) & play(Me,R,G).
+!play_role(Role,Group)[source(Ag)]
<- .print("ooo Adopting role ",Role," in group ",Group,", asked by ",Ag);
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-07 08:15:38 UTC (rev 1293)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-07 10:12:25 UTC (rev 1294)
@@ -26,11 +26,11 @@
.findall(Scouter,play(Scouter,scouter,EG),LScouters);
!change_role(herder,HG);
- .wait("+play(Me,herder,FinalHerdingGroup)");
+ //?play(Me,herder,FinalHerdingGroup);
// ask scouters to change role
- .print("ooo Asking ",LScouters," to adopt the herdboy role in ",FinalHerdingGroup);
- .send(LScouters,achieve,change_role(herdboy,FinalHerdingGroup)).
+ .print("ooo Asking ",LScouters," to adopt the herdboy role in ",HG);
+ .send(LScouters,achieve,change_role(herdboy,HG)).
// If if start playing explorer in a group that has no scheme, create the scheme
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-07 08:15:38 UTC (rev 1293)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-07 10:12:25 UTC (rev 1294)
@@ -192,8 +192,11 @@
public void incVisited(Location l) {
incVisited(l.x,l.y);
}
+
public void incVisited(int x, int y) {
visited[x][y] += 2;
+ increp(visited, x, y, 4, 1);
+ /*
if (x > 0) visited[x-1][y ]++;
if (y > 0) visited[x ][y-1]++;
if (y > 0 && x > 0) visited[x-1][y-1]++;
@@ -202,6 +205,7 @@
if (x+1 < getWidth()) visited[x+1][y ]++;
if (x+1 < getWidth() && y > 0) visited[x+1][y-1]++;
if (x+1 < getWidth() && y+1 < getHeight()) visited[x+1][y+1]++;
+ */
}
/** returns the near location of x,y that was least visited */
Modified: trunk/src/jason/stdlib/foreach.java
===================================================================
--- trunk/src/jason/stdlib/foreach.java 2008-05-07 08:15:38 UTC (rev 1293)
+++ trunk/src/jason/stdlib/foreach.java 2008-05-07 10:12:25 UTC (rev 1294)
@@ -38,7 +38,9 @@
import jason.asSyntax.Term;
import jason.asSyntax.PlanBody.BodyType;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
// TODO: comments
public class foreach extends DefaultInternalAction {
@@ -66,9 +68,14 @@
if ( !args[1].isPlanBody())
throw new JasonException("The second argument of .for must be a plan body term.");
- // get the solutions for the loop
+ // get all solutions for the loop
+ // Note: you should get all solutions here, otherwise I concurrent modification will occur for the iterator
LogicalFormula logExpr = (LogicalFormula)args[0];
iu = logExpr.logicalConsequence(ts.getAg(), un.copy());
+ List<Unifier> allsol = new ArrayList<Unifier>();
+ while (iu.hasNext())
+ allsol.add(iu.next());
+ iu = allsol.iterator();
((Structure)foria.getBodyTerm()).addTerm(new ObjectTermImpl(iu));
} else {
// restore the solutions
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-07 16:55:32
|
Revision: 1295
http://jason.svn.sourceforge.net/jason/?rev=1295&view=rev
Author: jomifred
Date: 2008-05-07 08:59:20 -0700 (Wed, 07 May 2008)
Log Message:
-----------
make all jmoise actions "synchronous" (the intention is suspended until
the end of the execution of the action)
Modified Paths:
--------------
trunk/applications/jason-moise/example/writePaper/jaime.asl
trunk/applications/jason-moise/src/jmoise/MoiseBaseIA.java
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-moise/src/jmoise/adopt_role.java
trunk/applications/jason-moise/src/jmoise/create_group.java
trunk/applications/jason-moise/src/jmoise/create_scheme.java
trunk/applications/jason-moise/src/jmoise/link.java
trunk/applications/jason-moise/src/jmoise/set_org_manager.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/stdlib/suspend.java
Modified: trunk/applications/jason-moise/example/writePaper/jaime.asl
===================================================================
--- trunk/applications/jason-moise/example/writePaper/jaime.asl 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/example/writePaper/jaime.asl 2008-05-07 15:59:20 UTC (rev 1295)
@@ -15,7 +15,8 @@
// create a group to write a paper
+!create_group : true
<- //.send(orgManager, achieve, create_group(wpgroup)).
- jmoise.create_group(wpgroup).
+ jmoise.create_group(wpgroup,G);
+ .print("Group ",G," created").
@@ -35,7 +36,8 @@
// when a scheme has finished, start another
-scheme(writePaperSch,_)
: group(wpgroup,GId)
- <- jmoise.create_scheme(writePaperSch, [GId]).
+ <- jmoise.create_scheme(writePaperSch, [GId], SchId);
+ .print("Scheme ",SchId," created").
// include common plans for MOISE+ agents
{ include("moise-common.asl") }
Modified: trunk/applications/jason-moise/src/jmoise/MoiseBaseIA.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/MoiseBaseIA.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/src/jmoise/MoiseBaseIA.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -2,6 +2,7 @@
import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.Intention;
import jason.asSemantics.Message;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
@@ -26,6 +27,10 @@
String acName = this.getClass().getSimpleName(); // remove the package name "jmoise"
Structure acTerm = new Structure(acName);
acTerm.addTerms(args);
+ // remove the last arg if unground (the return of the IA)
+ if (!acTerm.getTerm(args.length-1).isGround()) {
+ acTerm.delTerm(args.length-1);
+ }
if (logger.isLoggable(Level.FINE)) logger.fine("sending: "+acTerm);
// send acTerm as message to OrgManager
@@ -33,6 +38,12 @@
OrgAgent oag = (OrgAgent)ts.getUserAgArch();
Message m = new Message("achieve", null, oag.getOrgManagerName(), acTerm);
oag.sendMsg(m);
+
+ if (suspendIntention()) {
+ Intention i = ts.getC().getSelectedIntention();
+ i.setSuspended(true);
+ ts.getC().getPendingIntentions().put("om/"+m.getMsgId(), i);
+ }
return true;
} catch (JasonException e) {
throw e;
@@ -41,4 +52,10 @@
}
return false;
}
+
+ @Override
+ public boolean suspendIntention() {
+ return true;
+ }
+
}
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -4,13 +4,17 @@
import jason.RevisionFailedException;
import jason.architecture.AgArch;
import jason.asSemantics.Agent;
+import jason.asSemantics.Circumstance;
import jason.asSemantics.Event;
import jason.asSemantics.Intention;
import jason.asSemantics.Message;
import jason.asSemantics.Unifier;
import jason.asSyntax.Atom;
import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.Literal;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Pred;
import jason.asSyntax.PredicateIndicator;
import jason.asSyntax.Structure;
@@ -18,6 +22,7 @@
import jason.asSyntax.Trigger;
import jason.asSyntax.UnnamedVar;
import jason.asSyntax.VarTerm;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.mas2j.ClassParameters;
@@ -87,8 +92,8 @@
public void checkMail() {
super.checkMail(); // get the messages from arch to circumstance
-
- Iterator<Message> i = getTS().getC().getMailBox().iterator();
+ Circumstance C = getTS().getC();
+ Iterator<Message> i = C.getMailBox().iterator();
boolean updateGoalBels = false;
boolean updateGoalEvt = false;
while (i.hasNext()) {
@@ -138,6 +143,33 @@
String schId = Pred.parsePred(content).getTerm(1).toString();
removeAchieveGoalsOfSch(schId);
removeBeliefs(schId);
+
+ // test if it is the result of some org action
+ } else if (m.getInReplyTo() != null) {
+ // find the intention
+ Intention pi = C.getPendingIntentions().remove("om/"+m.getInReplyTo());
+ if (pi != null) {
+ i.remove();
+ pi.setSuspended(false);
+ C.addIntention(pi); // add it back in I
+ Structure body = (Structure)pi.peek().removeCurrentStep(); // remove the internal action
+
+ if (content.startsWith("error")) {
+ // fail the IA
+ PlanBody pbody = pi.peek().getPlan().getBody();
+ pbody.add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
+ getTS().getLogger().warning("Error in organisational action: "+content);
+ } else {
+ // try to unify the return value
+ //System.out.println("answer is "+content+" or "+DefaultTerm.parse(content)+" with body "+body);
+ // if the last arg of body is a free var
+ Term lastTerm = body.getTerm(body.getArity()-1);
+ if (!lastTerm.isGround()) {
+ pi.peek().getUnif().unifies(lastTerm, DefaultTerm.parse(content));
+ //System.out.println("un = "+pi.peek().getUnif());
+ }
+ }
+ }
}
}
} catch (Exception e) {
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -205,6 +205,7 @@
updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + grId + ")", false, true);
}
}
+ sendReply(sender, mId, "ok");
}
}
@@ -231,6 +232,7 @@
updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + gr.getId() + ")", false, false);
}
}
+ sendReply(sender, mId, "ok");
}
}
@@ -259,6 +261,7 @@
updateMembersOE(sch.getOwner(), "sch_players(" + sch.getId() + ",NP)", false, false);
}
updateMembersOE(sch.getOwner(), "sch_players(" + sch.getId() + "," + sch.getPlayersQty() + ")", false, true);
+ sendReply(sender, mId, "ok");
}
}
@@ -305,6 +308,7 @@
// notify owner that it can finish the scheme
updateMembersOE(sch.getOwner(), "sch_players(" + sch.getId() + ",NP)", false, false);
updateMembersOE(sch.getOwner(), "sch_players(" + sch.getId() + "," + sch.getPlayersQty() + ")", false, true);
+ sendReply(sender, mId, "ok");
}
}
@@ -333,6 +337,7 @@
newGr.setOwner(sender);
updateMembersOE(currentOE.getAgents(), "group(" + specId + "," + newGr.getId() + ")[owner(" + sender + ")," + annot + "]", false, true);
+ sendReply(sender, mId, newGr.getId());
}
}
@@ -389,6 +394,7 @@
// sent a new copy of OE
updateMembersOE(currentOE.getAgents(), "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")", true, false);
+ sendReply(sender, mId, "ok");
}
}
@@ -429,6 +435,7 @@
updateMembersOE(gi.getPlayers(), "scheme_group(" + sch.getId() + "," + gi.getId() + ")", true, true);
}
}
+ sendReply(sender, mId, sch.getId());
}
}
@@ -457,6 +464,7 @@
sch.addResponsibleGroup(gr);
updateMembersOE(gr.getPlayers(), "scheme_group(" + schId + "," + grId + ")", true, true);
+ sendReply(sender, mId, "ok");
}
}
@@ -479,6 +487,7 @@
act(currentOE, sch);
// send untell to agents
updateMembersOE(currentOE.getAgents(), "scheme(" + sch.getSpec().getId() + "," + sch.getId() + ")[owner(" + sch.getOwner() + ")]", false, false);
+ sendReply(sender, mId, "ok");
}
protected void act(OE currentOE, SchemeInstance sch) throws MoiseException {
currentOE.finishScheme(sch);
@@ -526,6 +535,7 @@
gi.setImpossible(sender);
}
updateMembersOE(sch.getPlayers(), "goal_state(" + gi.getScheme().getId() + "," + gi.getSpec().getId() + ")", true, true);
+ sendReply(sender, mId, "ok");
}
}
@@ -565,6 +575,7 @@
gi.setArgumentValue(arg, value);
updateMembersOE(sch.getPlayers(), "goal_state(" + gi.getScheme().getId() + "," + gi.getSpec().getId() + ")", true, true);
+ sendReply(sender, mId, "ok");
}
}
Modified: trunk/applications/jason-moise/src/jmoise/adopt_role.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/adopt_role.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/src/jmoise/adopt_role.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -49,5 +49,5 @@
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
return super.execute(ts,un,args);
- }
+ }
}
Modified: trunk/applications/jason-moise/src/jmoise/create_group.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/create_group.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/src/jmoise/create_group.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -29,8 +29,12 @@
<ul>
<li> <code>jmoise.create_group(team)</code>:
creates a new root group based on specification of a team.</li>
+<li> <code>jmoise.create_group(team,G)</code>:
+ creates a new root group based on specification of a team and unifies in G the identification of the new group.</li>
<li> <code>jmoise.create_group(defence, team0)</code>:
creates a sub-group of group team0 based on specification defence.</li>
+<li> <code>jmoise.create_group(defence, team0, G)</code>:
+ creates a sub-group of group team0 based on specification defence and unifies in G the identification of the new group.</li>
</ul>
@see jmoise.remove_group
Modified: trunk/applications/jason-moise/src/jmoise/create_scheme.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/create_scheme.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/src/jmoise/create_scheme.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -22,9 +22,12 @@
<ul>
<li> <code>jmoise.create_scheme(wp)</code>:
creates new scheme based on specification wp.</li>
-<li> <code>jmoise.create_scheme(wp, [ g1, g2])</code>:
+<li> <code>jmoise.create_scheme(wp, [g1, g2])</code>:
creates new scheme based on specification wp and set g1 and g2 as responsible
groups.</li>
+<li> <code>jmoise.create_scheme(wp, [g1, g2], S)</code>:
+ creates new scheme based on specification wp and set g1 and g2 as responsible
+ groups. The identification of the new group will be unified with G.</li>
</ul>
@see jmoise.remove_scheme
Modified: trunk/applications/jason-moise/src/jmoise/link.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/link.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/src/jmoise/link.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -1,5 +1,6 @@
package jmoise;
+import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Atom;
@@ -37,7 +38,7 @@
@author Jomi
*/
-public class link extends MoiseBaseIA {
+public class link extends DefaultInternalAction {
private static Logger logger = Logger.getLogger(link.class.getName());
Modified: trunk/applications/jason-moise/src/jmoise/set_org_manager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/set_org_manager.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/applications/jason-moise/src/jmoise/set_org_manager.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -1,5 +1,6 @@
package jmoise;
+import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Term;
@@ -8,7 +9,7 @@
import java.util.logging.Logger;
/** Changes the name of the OrgManager agent, the default name is "orgManager" */
-public class set_org_manager extends MoiseBaseIA {
+public class set_org_manager extends DefaultInternalAction {
private static Logger logger = Logger.getLogger(set_org_manager.class.getName());
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/src/jason/asSyntax/Structure.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -224,6 +224,10 @@
resetHashCodeCache();
}
+ public void delTerm(int index) {
+ terms.remove(index);
+ }
+
public void addTerms(Term ... ts ) {
for (Term t: ts) {
terms.add(t);
Modified: trunk/src/jason/stdlib/suspend.java
===================================================================
--- trunk/src/jason/stdlib/suspend.java 2008-05-07 10:12:25 UTC (rev 1294)
+++ trunk/src/jason/stdlib/suspend.java 2008-05-07 15:59:20 UTC (rev 1295)
@@ -85,9 +85,7 @@
Intention i = C.getSelectedIntention();
suspendIntention = true;
i.setSuspended(true);
- //i.peek().removeCurrentStep();
- C.getPendingIntentions().put(SELF_SUSPENDED_INT, i); //
-
+ C.getPendingIntentions().put(SELF_SUSPENDED_INT, i);
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-07 21:24:48
|
Revision: 1296
http://jason.svn.sourceforge.net/jason/?rev=1296&view=rev
Author: jomifred
Date: 2008-05-07 14:24:45 -0700 (Wed, 07 May 2008)
Log Message:
-----------
update jason team for new version of IA of jason-moise
Modified Paths:
--------------
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/goto.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
trunk/applications/jason-team/src/java/jia/direction.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSyntax/Structure.java
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-07 21:24:45 UTC (rev 1296)
@@ -92,6 +92,7 @@
public void checkMail() {
super.checkMail(); // get the messages from arch to circumstance
+
Circumstance C = getTS().getC();
Iterator<Message> i = C.getMailBox().iterator();
boolean updateGoalBels = false;
@@ -104,72 +105,52 @@
currentOE = (OE) m.getPropCont();
i.remove();
} else if (m.getSender().equals(getOrgManagerName())) {
+
// the content is a normal predicate
final String content = m.getPropCont().toString();
- final boolean isTell = m.getIlForce().equals("tell");
- final boolean isUntell = m.getIlForce().equals("untell");
- if (isTell && content.startsWith("scheme(")) {
- i.remove();
- addAsBel(content);
- //} else if (content.startsWith("update_goals")) {
- // // I need to generate AS Triggers like !<orggoal>
- // i.remove();
- // updateGoalBels = true;
- // updateGoalEvt = true;
- } else if (content.startsWith("goal_state")) {
- // the state of a scheme i belong to has changed
- i.remove();
- updateGoalBels(Pred.parsePred(content));
- updateGoalEvt = true;
- } else if (content.startsWith("scheme_group")) {
- i.remove();
- if (isTell) {
- // this message is generated when my group becomes
- // responsible for a scheme
- Literal l = addAsBel(content);
- generateObligationPermissionEvents(l);
- } else if (isUntell) {
- Literal l = delAsBel(content);
- removeObligationPermissionBeliefs(l, "obligation");
- removeObligationPermissionBeliefs(l, "permission");
- }
- } else if (isTell && content.startsWith("commitment")) {
- i.remove();
- addAsBel(content);
- // I need to generate AS Triggers like !<orggoal> since some scheme becomes well formed
- updateGoalEvt = true;
+
+ // test if it is the result of some org action
+ if (m.getInReplyTo() != null) {
+ // find the intention
+ Intention pi = C.getPendingIntentions().remove("om/"+m.getInReplyTo());
+ if (pi != null) {
+ i.remove();
+ resumeIntention(pi, content, C);
+ }
+ } else {
+ // add all tells directly in the memory
+ if (m.getIlForce().equals("tell")) {
+ i.remove();
+ if (content.startsWith("goal_state")) {
+ // the state of a scheme i belong to has changed
+ updateGoalBels( Pred.parsePred(content) );
+ updateGoalEvt = true;
+ } else {
+ Literal cl = addAsBel(content);
+
+ if (content.startsWith("scheme_group")) {
+ // this message is generated when my group becomes
+ // responsible for a scheme
+ generateObligationPermissionEvents(cl);
+ } else if (content.startsWith("commitment")) {
+ // I need to generate AS Triggers like !<orggoal> since some scheme becomes well formed
+ updateGoalEvt = true;
+ }
+ }
- } else if (m.getIlForce().equals("untell") && content.startsWith("scheme")) {
- String schId = Pred.parsePred(content).getTerm(1).toString();
- removeAchieveGoalsOfSch(schId);
- removeBeliefs(schId);
-
- // test if it is the result of some org action
- } else if (m.getInReplyTo() != null) {
- // find the intention
- Intention pi = C.getPendingIntentions().remove("om/"+m.getInReplyTo());
- if (pi != null) {
- i.remove();
- pi.setSuspended(false);
- C.addIntention(pi); // add it back in I
- Structure body = (Structure)pi.peek().removeCurrentStep(); // remove the internal action
-
- if (content.startsWith("error")) {
- // fail the IA
- PlanBody pbody = pi.peek().getPlan().getBody();
- pbody.add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
- getTS().getLogger().warning("Error in organisational action: "+content);
- } else {
- // try to unify the return value
- //System.out.println("answer is "+content+" or "+DefaultTerm.parse(content)+" with body "+body);
- // if the last arg of body is a free var
- Term lastTerm = body.getTerm(body.getArity()-1);
- if (!lastTerm.isGround()) {
- pi.peek().getUnif().unifies(lastTerm, DefaultTerm.parse(content));
- //System.out.println("un = "+pi.peek().getUnif());
- }
- }
- }
+ } else if ( m.getIlForce().equals("untell") ) {
+ i.remove();
+ Literal cl = delAsBel(content);
+
+ if (content.startsWith("scheme")) {
+ String schId = cl.getTerm(1).toString();
+ removeAchieveGoalsOfSch(schId);
+ removeBeliefs(schId);
+ } else if (content.startsWith("scheme_group")) {
+ removeObligationPermissionBeliefs(cl, "obligation");
+ removeObligationPermissionBeliefs(cl, "permission");
+ }
+ }
}
}
} catch (Exception e) {
@@ -184,7 +165,6 @@
} catch (Exception e) {
logger.log(Level.SEVERE, "Error!", e);
}
-
}
private Literal addAsBel(String b) throws RevisionFailedException {
@@ -199,6 +179,29 @@
getTS().getAg().delBel(l);
return l;
}
+
+ private void resumeIntention(Intention pi, String content, Circumstance C) {
+ pi.setSuspended(false);
+ C.addIntention(pi); // add it back in I
+ Structure body = (Structure)pi.peek().removeCurrentStep(); // remove the internal action
+
+ if (content.startsWith("error")) {
+ // fail the IA
+ PlanBody pbody = pi.peek().getPlan().getBody();
+ pbody.add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
+ getTS().getLogger().warning("Error in organisational action: "+content);
+ } else {
+ // try to unify the return value
+ //System.out.println("answer is "+content+" or "+DefaultTerm.parse(content)+" with body "+body);
+ // if the last arg of body is a free var
+ Term lastTerm = body.getTerm(body.getArity()-1);
+ if (!lastTerm.isGround()) {
+ pi.peek().getUnif().unifies(lastTerm, DefaultTerm.parse(content));
+ //System.out.println("un = "+pi.peek().getUnif());
+ }
+ }
+
+ }
private void generateObligationPermissionEvents(Pred m) throws RevisionFailedException {
// computes this agent obligations in the scheme
@@ -344,24 +347,25 @@
/** removes all bels related to a Scheme */
void removeBeliefs(String schId) throws RevisionFailedException {
Agent ag = getTS().getAg();
- ag.abolish(buildLiteralToCleanBB(schId, obligationLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(schId, permissionLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(schId, schemeGroupLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(schId, goalStateLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(schId, schPlayersLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(schId, commitmentLiteral, true), null);
+ Atom aSchId = new Atom(schId);
+ ag.abolish(buildLiteralToCleanBB(aSchId, obligationLiteral, false), null);
+ ag.abolish(buildLiteralToCleanBB(aSchId, permissionLiteral, false), null);
+ ag.abolish(buildLiteralToCleanBB(aSchId, schemeGroupLiteral, false), null);
+ ag.abolish(buildLiteralToCleanBB(aSchId, goalStateLiteral, false), null);
+ ag.abolish(buildLiteralToCleanBB(aSchId, schPlayersLiteral, false), null);
+ ag.abolish(buildLiteralToCleanBB(aSchId, commitmentLiteral, true), null);
}
- private Literal buildLiteralToCleanBB(String schId, PredicateIndicator pred, boolean schInEnd) {
+ private Literal buildLiteralToCleanBB(Atom aSchId, PredicateIndicator pred, boolean schInEnd) {
Literal l = new Literal(pred.getFunctor());
if (!schInEnd) {
- l.addTerm(new Atom(schId));
+ l.addTerm(aSchId);
}
for (int i=1;i<pred.getArity();i++) {
l.addTerm(new UnnamedVar());
}
if (schInEnd) {
- l.addTerm(new Atom(schId));
+ l.addTerm(aSchId);
}
return l;
}
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-07 21:24:45 UTC (rev 1296)
@@ -42,17 +42,17 @@
+!create_exploration_gr
<- .my_name(Me);
- // create the team
+ // create the team, if necessary
.if( Me == gaucho1 & not group(team,_) ) {
- jmoise.create_group(team)
+ jmoise.create_group(team)
};
-
- // wait the team creation
- ?group(team,TeamGroup);
-
- .if( not group(exploration_grp,_)[owner(Me)]) {
- jmoise.create_group(exploration_grp,TeamGroup);
- .wait("+group(exploration_grp,G)[owner(Me)]")
+
+ .if( not group(exploration_grp,_)[owner(Me)] ) {
+ ?group(team,TeamGroup); // get the team Id
+ jmoise.create_group(exploration_grp,TeamGroup,G);
+ .print("ooo Group ",G," created")
+ } {
+ ?group(exploration_grp,G)[owner(Me)]
};
.print("ooo Recruiting scouters for my explorer group ",G);
@@ -123,7 +123,7 @@
/* -- plans for the goals of role explorer -- */
-{ begin maintenance_goal("+pos(_,_,_)") }
+{ begin maintenance_goal("+at_target") }
+!goto_near_unvisited[scheme(Sch),mission(Mission)]
<- .print("ooo I should find the nearest unvisited location and go there!");
@@ -132,11 +132,11 @@
?group_area(_,GroupId, Area); // get the area of this group
?pos(MeX, MeY, _); // get my location
jia.near_least_visited(MeX, MeY, Area, TargetX, TargetY);
- -+target(TargetX, TargetY);
- .wait("+at_target",10000,_).
+ -+target(TargetX, TargetY).
/* added by the pattern
- .wait("+pos(_,_,_)"); // wait next cycle
+ .wait("+at_target").
+ //.wait("+pos(_,_,_)"); // wait next cycle
!!goto_near_unvisited[scheme(Sch),mission(Mission)]
*/
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-07 21:24:45 UTC (rev 1296)
@@ -42,7 +42,7 @@
+?pos(X, Y, S) <- .wait("+pos(X,Y,S)").
+?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
+?gsize(W,H) <- .wait("+gsize(W,H)").
-+?group(T,G) <- .wait("+group(T,G)").
++?group(team,G) <- .wait("+group(team,G)", 500, _); ?group(team,G).
+?ally_pos(Name,X,Y) : .my_name(Name) <- ?pos(X,Y,_).
+end_of_simulation(_Result)
@@ -77,8 +77,7 @@
+!remove_org
: .my_name(gaucho1)
<- .if( group(team,Old) ) {
- jmoise.remove_group(Old);
- .wait("-group(team,_)")
+ jmoise.remove_group(Old)
};
.for( scheme(_,SchId) ) {
@@ -109,8 +108,7 @@
// give up all missions
.while( commitment(Me,M,Sch) ) {
- jmoise.remove_mission(M,Sch);
- .wait("-commitment(Me,M,Sch)")
+ jmoise.remove_mission(M,Sch)
};
// if I play herder in another group, ...
@@ -122,12 +120,10 @@
// if I play any other role, give it up
.while( play(Me,R,OG) & OG \== GT) {
- jmoise.remove_role(R,OG);
- .wait("-play(Me,R,OG)")
+ jmoise.remove_role(R,OG)
};
- jmoise.adopt_role(NewRole,GT);
- .wait("+play(Me,NewRole,GT)").
+ jmoise.adopt_role(NewRole,GT).
//+!change_role(NewRole,GT)[source(S)]
// <- .print("ooo I cannot adopt the role ",NewRole," in group ",GT,", as asked by ",S).
Modified: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-05-07 21:24:45 UTC (rev 1296)
@@ -24,18 +24,7 @@
-at_target;
!!move.
-//-target(_,_) // if I receive a message untell for my target, remove all target from BB
-// <- .abolish(target(_,_)).
-
-// I still do not know my location
-/*
+!move
- : not pos(_,_,_)
- <- .print("waiting my location....");
- .wait("+pos(_,_,_)");
- !move.
-*/
-+!move
: not target(_,_)
<- .print("waiting my target....");
.wait("+target(_,_)");
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-07 21:24:45 UTC (rev 1296)
@@ -8,7 +8,7 @@
+cow(_,_,_)
: .my_name(Me) &
play(Me,explorer,_) &
- not .desire(create_herding_gr) // to avoid crating several groups
+ not .desire(create_herding_gr) // to avoid creating several groups
<- !create_herding_gr.
+!create_herding_gr
@@ -17,8 +17,7 @@
// create the new group
?group(team,TeamId);
- jmoise.create_group(herding_grp, TeamId);
- .wait("+group(herding_grp, HG)[owner(Me)]", 4000);
+ jmoise.create_group(herding_grp, TeamId, HG);
.print("ooo Group ",HG," created.");
// store the list of scouter in my group
@@ -26,7 +25,6 @@
.findall(Scouter,play(Scouter,scouter,EG),LScouters);
!change_role(herder,HG);
- //?play(Me,herder,FinalHerdingGroup);
// ask scouters to change role
.print("ooo Asking ",LScouters," to adopt the herdboy role in ",HG);
@@ -42,8 +40,8 @@
.broadcast(tell, group_leader(G,Me)).
// If I stop playing herder, destroy the herding groups I've created
--play(Ag,herder,_)
- : .my_name(Ag)
+-play(Me,herder,_)
+ : .my_name(Me)
<- .wait(4000);
.for( group(herding_grp,G)[owner(Me)] ) {
-group_leader(G,Me);
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-07 21:24:45 UTC (rev 1296)
@@ -6,6 +6,7 @@
import jason.environment.grid.Location;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -145,26 +146,31 @@
m[c][l] += value;
}
- public Location nearFree(Location l) throws Exception {
+ // occupied means the places that can not be considered as nearFree
+ public Location nearFree(Location l, List<Location> occupied) throws Exception {
int w = 0;
+ Location newl;
+ if (occupied == null) occupied = Collections.emptyList();
List<Location> options = new ArrayList<Location>();
while (true) {
options.clear();
for (int y=l.y-w+1; y<l.y+w; y++) {
//System.out.println(" "+(l.x+w)+" "+y);
//System.out.println(" "+(l.x-w)+" "+y);
- if (isFree(l.x-w,y))
- options.add(new Location(l.x-w,y));
- if (isFree(l.x+w,y))
- options.add(new Location(l.x+w,y));
+ newl = new Location(l.x-w,y);
+ if (isFree(newl) && !occupied.contains(newl))
+ options.add(newl);
+ newl = new Location(l.x+w,y);
+ if (isFree(newl) && !occupied.contains(newl))
+ options.add(newl);
}
for (int x=l.x-w; x<=l.x+w;x++) {
- //System.out.println(" "+x+" "+(l.y-w));
- //System.out.println(" "+x+" "+(l.y+w));
- if (isFree(x,l.y-w))
- options.add(new Location(x,l.y-w));
- if (isFree(x,l.y+w))
- options.add(new Location(x,l.y+w));
+ newl = new Location(x,l.y-w);
+ if (isFree(newl) && !occupied.contains(newl))
+ options.add(newl);
+ newl = new Location(x,l.y+w);
+ if (isFree(newl) && !occupied.contains(newl))
+ options.add(newl);
}
//System.out.println(w + " " + options);
if (!options.isEmpty())
Modified: trunk/applications/jason-team/src/java/jia/direction.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/direction.java 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-team/src/java/jia/direction.java 2008-05-07 21:24:45 UTC (rev 1296)
@@ -73,7 +73,7 @@
// if search is null, it is impossible in the scenario to goto n, set it as obstacle
ts.getLogger().info("[direction] No possible path to "+to+" setting as obstacle.");
model.add(WorldModel.OBSTACLE, to);
- to = model.nearFree(to);
+ to = model.nearFree(to, null);
s = new Search(model, from, to, ts.getUserAgArch());
}
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-07 21:24:45 UTC (rev 1296)
@@ -130,7 +130,7 @@
}
}
if (r != null)
- r = model.nearFree(r);
+ r = model.nearFree(r, null);
return r;
}
@@ -182,8 +182,8 @@
//System.out.println(" = "+dist+" result "+l);
if (l != null) {
l = pathToNearCow(l, clusterLocs);
- if ( ! model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l))
- l = model.nearFree(l);
+ if ( !model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l) || r.contains(l))
+ l = model.nearFree(l, r);
r.add( l );
}
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-07 21:24:45 UTC (rev 1296)
@@ -198,7 +198,7 @@
// add an agent in 4,38
model.add(WorldModel.AGENT, 4,38);
byIA = hp.getAgTarget(clusterLocs, Formation.six,cowboy.getLocation(model));
- assertEquals(null, byIA);
+ //assertEquals(null, byIA);
// add an agent in 5,37
//model.add(WorldModel.AGENT, 5,37);
@@ -222,7 +222,7 @@
assertEquals(new Location(11,49), byIA);
List<Location> form = hp.formationPlaces(clusterLocs, Formation.four);
- assertEquals("[6,48, 11,49, 6,48, 11,49]", form.toString());
+ assertEquals("[6,48, 11,49, 6,49, 12,48]", form.toString());
}
@Test
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/src/jason/asSemantics/Agent.java 2008-05-07 21:24:45 UTC (rev 1296)
@@ -648,14 +648,14 @@
*/
public void abolish(Literal bel, Unifier un) throws RevisionFailedException {
List<Literal> toDel = new ArrayList<Literal>();
-
+ if (un == null) un = new Unifier();
Iterator<Literal> il = getBB().getCandidateBeliefs(bel, un);
if (il != null) {
while (il.hasNext()) {
Literal inBB = il.next();
if (!inBB.isRule()) {
// need to clone unifier since it is changed in previous iteration
- Unifier unC = (un == null ? new Unifier() : un.copy());
+ Unifier unC = un.copy();
if (unC.unifiesNoUndo(bel, inBB)) {
toDel.add(inBB);
}
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-05-07 21:24:45 UTC (rev 1296)
@@ -335,8 +335,13 @@
function.put( (VarTerm)k.clone(), (Term)u.function.get(k).clone());
}
+ public Object clone() {
+ return copy();
+ }
+
+ /** same as clone but with typed return */
@SuppressWarnings("unchecked")
- public Object clone() {
+ public Unifier copy() {
try {
Unifier newUn = new Unifier();
newUn.function = (HashMap)function.clone();
@@ -348,11 +353,6 @@
}
}
- /** same as clone but with typed return */
- public Unifier copy() {
- return (Unifier)clone();
- }
-
public boolean equals(Object o) {
if (o == null) return false;
if (o == this) return true;
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-05-07 15:59:20 UTC (rev 1295)
+++ trunk/src/jason/asSyntax/Structure.java 2008-05-07 21:24:45 UTC (rev 1296)
@@ -226,6 +226,8 @@
public void delTerm(int index) {
terms.remove(index);
+ predicateIndicatorCache = null;
+ resetHashCodeCache();
}
public void addTerms(Term ... ts ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-18 14:57:22
|
Revision: 1298
http://jason.svn.sourceforge.net/jason/?rev=1298&view=rev
Author: jomifred
Date: 2008-05-18 07:57:19 -0700 (Sun, 18 May 2008)
Log Message:
-----------
change the syntax of if/while/loop to not use ".", as in
if( test ) { ... } ;
but it is still an internal action.
jason team: some minor test
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java
trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
trunk/applications/jason-team/src/java/jia/cluster.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/jia/scouter_pos.java
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
trunk/applications/jason-team/src/team-os.xml
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/asSyntax/PlanBody.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/stdlib/at.java
trunk/src/jason/stdlib/suspend.java
trunk/src/jason/stdlib/wait.java
trunk/src/jeditPlugin/agentSpeak.xml
Modified: trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -18,13 +18,13 @@
ag.parseAScode(
"b(1). "+
"p(1,a). p(2,a). p(3,b). p(4,b). p(6,a). "+
- "+!test1 <- .while( .count(b(_),N) & N < 4, {+b(N+1) })."+
+ "+!test1 <- while( .count(b(_),N) & N < 4, {+b(N+1) })."+
- "+!test2 <- L=4; .while( .count(b(_)) < L) { ?b(X); +b(X+1) }; jason.asunit.print(end). "+
+ "+!test2 <- L=4; while( .count(b(_)) < L) { ?b(X); +b(X+1) }; jason.asunit.print(end). "+
- "+!test3 <- L=4; .for( p(N,a) & N < L) { jason.asunit.print(N) }; jason.asunit.print(end). "+
+ "+!test3 <- L=4; for( p(N,a) & N < L) { jason.asunit.print(N) }; jason.asunit.print(end). "+
- "+!test4 <- .for( .member(N, [1,3,4]), { jason.asunit.print(N) }); jason.asunit.print(end). "
+ "+!test4 <- for( .member(N, [1,3,4]), { jason.asunit.print(N) }); jason.asunit.print(end). "
);
}
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-18 14:57:19 UTC (rev 1298)
@@ -5,7 +5,6 @@
/* -- initial goals -- */
-//!create_team_group.
/*
-- plans for new match
@@ -13,24 +12,6 @@
*/
-/* plans for the team's groups creation */
-
-/*
-+!create_team_group
- : .my_name(gaucho1)
- <- .print("oooo creating new team group ------------------------------------------------- ");
- !remove_org;
- jmoise.create_group(team).
-+!create_team_group.
-*/
-
-/*+group(team,GId) // agent 1 is responsible for the creation of exploration groups
- : .my_name(gaucho1)
- <- jmoise.create_group(exploration_grp,GId);
- jmoise.create_group(exploration_grp,GId);
- jmoise.create_group(exploration_grp,GId). */
-
-
/* plans for agents with odd id */
+gsize(_,_) // new match has started
@@ -43,11 +24,11 @@
<- .my_name(Me);
// create the team, if necessary
- .if( Me == gaucho1 & not group(team,_) ) {
+ if( Me == gaucho1 & not group(team,_) ) {
jmoise.create_group(team)
};
- .if( not group(exploration_grp,_)[owner(Me)] ) {
+ if( not group(exploration_grp,_)[owner(Me)] ) {
?group(team,TeamGroup); // get the team Id
jmoise.create_group(exploration_grp,TeamGroup,G);
.print("ooo Group ",G," created")
@@ -60,7 +41,7 @@
?pos(MyX,MyY,_); // wait my pos
// wait others pos
- .while( .count(ally_pos(_,_,_), N) & N < 5 ) {
+ while( .count(ally_pos(_,_,_), N) & N < 5 ) {
.print("ooo waiting others pos ");
.wait("+ally_pos(_,_,_)", 500, _)
};
@@ -99,7 +80,7 @@
-play(Me,explorer,_)
: .my_name(Me)
<- .wait(4000);
- .for( group(exploration_grp,G)[owner(Me)] ) {
+ for( group(exploration_grp,G)[owner(Me)] ) {
.print("ooo Removing group ",G," since I am not in the group anymore");
jmoise.remove_group(G);
.wait(4000)
@@ -151,7 +132,18 @@
*/
+{ begin maintenance_goal("+pos(_,_,_)") }
++!change_to_herding[scheme(Sch),mission(Mission)]
+ : cow(_,_,_)
+ <- .print("ooo I see some cow, create the herding group");
+ !!create_herding_gr.
+
++!change_to_herding[scheme(Sch),mission(Mission)].
+
+{ end }
+
+
/* -- plans for the goals of role scouter -- */
{ begin maintenance_goal("+pos(_,_,_)") }
@@ -165,7 +157,7 @@
jia.dist(MyX, MyY, LX, LY, DistanceToLeader);
// If I am far from him, go to him
- .if( DistanceToLeader > (AGPR * 2) -3) {
+ if( DistanceToLeader > (AGPR * 2) -3) {
.print("ooo Approaching leader.");
-+target(LX,LY)
}{
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-18 14:57:19 UTC (rev 1298)
@@ -68,11 +68,11 @@
// remove all groups and schemes (only agent1 does that)
+!remove_org
: .my_name(gaucho1)
- <- .if( group(team,Old) ) {
+ <- if( group(team,Old) ) {
jmoise.remove_group(Old)
};
- .for( scheme(_,SchId) ) {
+ for( scheme(_,SchId) ) {
jmoise.remove_scheme(SchId)
}.
+!remove_org.
@@ -93,20 +93,20 @@
.print("ooo Adopting the role ",NewRole," in group ",GT,", as asked by ",S);
// give up all missions
- .while( commitment(Me,M,Sch) ) {
+ while( commitment(Me,M,Sch) ) {
.print("ooo removing my mission ",M," in ",Sch);
jmoise.remove_mission(M,Sch)
};
// if I play herder in another group, ...
- .if( play(Me,herder,G) & G \== GT) {
+ if( play(Me,herder,G) & G \== GT) {
// ask all herdboys to also change the group
.findall(Boy,play(Boy,herdboy,G),HerdBoys);
.send(HerdBoys, achieve, change_role(herdboy,GT))
};
// if I play any other role, give it up
- .while( play(Me,R,OG) & OG \== GT) {
+ while( play(Me,R,OG) & OG \== GT) {
jmoise.remove_role(R,OG)
};
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-18 14:57:19 UTC (rev 1298)
@@ -4,13 +4,7 @@
/* -- plans for herding groups creation -- */
-// if see cow and is not herding, create the herding group and change roles
-+cow(_,_,_)
- : .my_name(Me) &
- play(Me,explorer,_) &
- not .desire(create_herding_gr) // to avoid creating several groups
- <- !create_herding_gr.
-
+
+!create_herding_gr
: not .intend(create_herding_gr)
<- .print("ooo Creating herding group.");
@@ -44,7 +38,7 @@
-play(Me,herder,_)
: .my_name(Me)
<- .wait(4000);
- .for( group(herding_grp,G)[owner(Me)] ) {
+ for( group(herding_grp,G)[owner(Me)] ) {
-group_leader(G,Me);
.broadcast(untell, group_leader(G,Me));
jmoise.remove_group(G);
@@ -67,13 +61,13 @@
play(Me, herder, Gi) &
current_cluster(MyC)
<- // for all other groups
- .for( group_leader(Gj, L) & L \== Me & Me < L & not play(L,herdboy,Gi)) {
+ for( group_leader(Gj, L) & L \== Me & Me < L & not play(L,herdboy,Gi)) {
.print("ooo Checking merging with ",Gj);
// ask their cluster
.send(L, askOne, current_cluster(_), current_cluster(TC));
.intersection(MyC,TC,I);
- .if (.length(I) > 0) {
+ if (.length(I) > 0) {
.print("ooo Merging my herding group ",Gi," with ",Gj, " lead by ",L);
.send(L, achieve, change_role(herdboy,Gi))
}
@@ -154,12 +148,8 @@
/* -- plans for the goals of all roles (herder and herdboy) -- */
-//{ begin maintenance_goal("+pos(_,_,_)") }
-
// This goal behaviour is set by the message "tell target" of the leader of the group
+!be_in_formation[scheme(Sch),mission(Mission)]
<- .print("ooo I should be in formation!");
.suspend.
-
-// { end }
Modified: trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/java/agent/OrgMaintenanceGoal.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -20,7 +20,7 @@
try {
Agent newAg = new Agent();
- PlanBody endofplan = null;
+ PlanBodyImpl endofplan = null;
Literal goal = null;
//ListTerm annots = ListTermImpl.parseList("[scheme(SchId),mission(MissionId),group(GroupId)]");
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -5,7 +5,6 @@
import jason.bb.BeliefBase;
import jason.environment.grid.Location;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@@ -151,30 +150,33 @@
int w = 0;
Location newl;
if (occupied == null) occupied = Collections.emptyList();
- List<Location> options = new ArrayList<Location>();
+ //List<Location> options = new ArrayList<Location>();
while (true) {
- options.clear();
+ //options.clear();
for (int y=l.y-w+1; y<l.y+w; y++) {
//System.out.println(" "+(l.x+w)+" "+y);
//System.out.println(" "+(l.x-w)+" "+y);
newl = new Location(l.x-w,y);
if (isFree(newl) && !occupied.contains(newl))
- options.add(newl);
+ //options.add(newl);
+ return newl;
newl = new Location(l.x+w,y);
if (isFree(newl) && !occupied.contains(newl))
- options.add(newl);
+ //options.add(newl);
+ return newl;
}
for (int x=l.x-w; x<=l.x+w;x++) {
newl = new Location(x,l.y-w);
if (isFree(newl) && !occupied.contains(newl))
- options.add(newl);
+ //options.add(newl);
+ return newl;
newl = new Location(x,l.y+w);
if (isFree(newl) && !occupied.contains(newl))
- options.add(newl);
+ //options.add(newl);
+ return newl;
}
- //System.out.println(w + " " + options);
- if (!options.isEmpty())
- return options.get(random.nextInt(options.size()));
+ //if (!options.isEmpty())
+ // return options.get(random.nextInt(options.size()));
w++;
}
}
Modified: trunk/applications/jason-team/src/java/jia/cluster.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -80,7 +80,7 @@
vs.add(v.sub(mean));
Collections.sort(vs);
-
+
List<Vec> cs = new ArrayList<Vec>();
if (!vs.isEmpty())
cs.add(vs.remove(0));
@@ -104,7 +104,6 @@
}
}
}
-
List<Location> clusterLocs = new ArrayList<Location>();
for (Vec v: cs) {
// place all cows in ref to 0,0
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -155,7 +155,7 @@
return null;
Vec mean = Vec.mean(cows);
- int stepsFromCenter = (int)Math.round(Vec.max(cows).sub(mean).magnitude())+1;
+ int stepsFromCenter = Math.max(4, (int)Math.round(Vec.max(cows).sub(mean).magnitude())+1);
//Vec max = Vec.max(cows);
// run A* to see the cluster target in n steps
@@ -165,21 +165,19 @@
int n = Math.min(stepsFromCenter, np.size());
Vec cowstarget = new Vec(model, s.getNodeLocation(np.get(n)));
-
// find cow farthest of corral
Vec farcow = null;
for (Vec c: cows)
if (farcow == null || farcow.getLocation(model).maxBorder(model.getCorralCenter()) < c.getLocation(model).maxBorder(model.getCorralCenter()))
farcow = c;
-
Vec agsTarget = mean.sub(cowstarget).newMagnitude(farcow.sub(mean).magnitude()+1);
//System.out.println("Ags target = "+agsTarget+" mean = "+mean + " far cow is "+farcow);
List<Location> r = new ArrayList<Location>();
for (Vec position: formation.getDistances()) { // 2, -2, 6, -6, ....
//System.out.println("....... "+position+" + "+agsTarget+" = " + agTarget);
Location l = findFirstFreeLocTowardsTarget(agsTarget, position, mean, model);
- //System.out.println(" = "+dist+" result "+l);
+ //System.out.println(" = "+position+" result "+l);
if (l == null) {
l = model.nearFree(agsTarget.add(mean).getLocation(model), r);
} else {
@@ -200,8 +198,10 @@
//System.out.println(start + " to "+ direction + " = " + end);
Location l = start.add(ref).getLocation(model);
- Location lastloc = null;
+ //Location lastloc = null;
int maxSize = (int)direction.magnitude();
+ l = t.newMagnitude(maxSize).add(startandref).getLocation(model);
+ /*
for (int s = 1; s <= maxSize; s++) {
l = t.newMagnitude(s).add(startandref).getLocation(model);
//System.out.println(" test "+s+" = "+l+" -- ");
@@ -209,6 +209,7 @@
return lastloc;
lastloc = l;
}
+ */
return l;
}
Modified: trunk/applications/jason-team/src/java/jia/scouter_pos.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/scouter_pos.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/java/jia/scouter_pos.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -57,7 +57,7 @@
Vec leader = new Vec(model, leaderPos);
Vec target = new Vec(model, leaderTarget).sub(leader);
Vec me = new Vec(WorldModel.agPerceptionRatio*2-3,0);
- return herd_position.findFirstFreeLocTowardsTarget(target, me, leader, model);
+ return model.nearFree(herd_position.findFirstFreeLocTowardsTarget(target, me, leader, model), null);
}
}
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -29,7 +29,7 @@
@Before
public void scenario() {
- model = new LocalWorldModel(50,50, WorldModel.agPerceptionRatio, null);
+ model = new LocalWorldModel(50,50, WorldModel.agsByTeam, null);
model.setCorral(new Location(0,49), new Location(2,49));
model.wall(7, 44, 7, 49);
}
@@ -38,7 +38,7 @@
cowboy = new Vec(3,5);
model.add(WorldModel.AGENT, cowboy.getLocation(model));
- addToModel(
+ addCowsToModel(
new Vec(6,7),
new Vec(5,30),
new Vec(4,8),
@@ -50,7 +50,7 @@
cowboy = new Vec(11,3);
model.add(WorldModel.AGENT, cowboy.getLocation(model));
- addToModel(
+ addCowsToModel(
new Vec(8,0),
new Vec(9,0),
new Vec(10,0),
@@ -62,12 +62,31 @@
new Vec(10,2));
}
+ public void scenario3() {
+ model = new LocalWorldModel(50,19, WorldModel.agsByTeam, null);
+ model.setCorral(new Location(8,0), new Location(12,2));
+ model.wall(7, 0, 7, 2);
+ cowboy = new Vec(10,12);
+ model.add(WorldModel.AGENT, cowboy.getLocation(model));
+
+ addCowsToModel(
+ new Vec(1,16),
+ new Vec(2,14),
+ new Vec(3,13),
+ new Vec(5,14),
+ new Vec(6,12),
+ new Vec(6,13),
+ new Vec(20,2),
+ new Vec(20,3),
+ new Vec(20,4));
+ }
+
@Test
public void bigCluster() {
// big cluster
for (int x = 10; x < 30; x++) {
for (int y = 5; y < 20; y++) {
- addToModel(new Vec(model,x,y));
+ addCowsToModel(new Vec(model,x,y));
}
}
@@ -75,7 +94,7 @@
assertEquals(model.getCows().size(), cowsl.size());
}
- private void addToModel(Vec... cows) {
+ private void addCowsToModel(Vec... cows) {
for (int i=0; i<cows.length; i++) {
Location l = cows[i].getLocation(model);
model.addCow(l.x, l.y);
@@ -183,7 +202,7 @@
byIA = hp.getAgTarget(clusterLocs, Formation.six, cowboy.getLocation(model));
assertEquals(new Location(8,39), byIA);
- assertEquals("[8,39, 5,37, 10,43, 1,37, 12,46, 0,37]", hp.formationPlaces(clusterLocs, Formation.six).toString());
+ assertEquals("[8,39, 5,37, 10,43, 1,37, 12,46, 0,34]", hp.formationPlaces(clusterLocs, Formation.six).toString());
/*
// add an agent in 6,39
@@ -231,15 +250,32 @@
List<Location> form = hp.formationPlaces(clusterLocs, Formation.four);
assertTrue(form.contains(new Location(11,49)));
assertTrue(form.contains(new Location(6,49)));
- assertTrue(form.contains(new Location(6,48)));
+ assertTrue(form.contains(new Location(3,48)));
assertTrue(form.contains(new Location(15,48)));
}
@Test
+ public void formationSc3() throws Exception {
+ scenario3();
+
+ List<Location> clusterLocs = cluster.getCluster(model, WorldModel.cowPerceptionRatio);
+ assertEquals(6, clusterLocs.size());
+
+ herd_position hp = new herd_position();
+ hp.setModel(model);
+
+ List<Location> form = hp.formationPlaces(clusterLocs, Formation.four);
+ assertTrue(form.contains(new Location(0,4)) || form.contains(new Location(0,3)));
+ assertTrue(form.contains(new Location(0,8)));
+ assertTrue(form.contains(new Location(0,1)) || form.contains(new Location(0,0)));
+ assertTrue(form.contains(new Location(4,11)));
+ }
+
+ @Test
public void scouterPos() throws Exception {
scenario1();
Location byIA = new scouter_pos().getScouterTarget(model, new Location(2,46), new Location(5,44));
- assertEquals(new Location(6,46), byIA);
+ assertEquals(new Location(6,49), byIA);
byIA = new scouter_pos().getScouterTarget(model, new Location(9,46), new Location(9,42));
assertEquals(new Location(22,42), byIA);
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-18 14:57:19 UTC (rev 1298)
@@ -79,12 +79,14 @@
<goal id="goto_near_unvisited" ds="go to the near unvisited location inside the area of the group" type="maintenance"/>
<goal id="share_seen_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/>
<goal id="follow_leader" ds="follows the leader of the scheme/group" type="maintenance"/>
+ <goal id="change_to_herding" ds="verify if necessary to create the herding group" type="maintenance"/>
</plan>
</goal>
<mission id="explore" min="1">
<goal id="goto_near_unvisited" />
<goal id="share_seen_cows" />
+ <goal id="change_to_herding" />
</mission>
<mission id="scout" >
<goal id="follow_leader" />
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/asSemantics/Agent.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -31,7 +31,6 @@
import jason.asSyntax.Plan;
import jason.asSyntax.PlanLibrary;
import jason.asSyntax.Rule;
-import jason.asSyntax.Structure;
import jason.asSyntax.Trigger;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
@@ -44,9 +43,6 @@
import jason.functions.Count;
import jason.functions.RuleToFunction;
import jason.runtime.Settings;
-import jason.stdlib.conditional;
-import jason.stdlib.foreach;
-import jason.stdlib.loop;
import java.io.File;
import java.io.FileInputStream;
@@ -242,14 +238,7 @@
}
@SuppressWarnings("unchecked")
- public InternalAction getIA(Structure action) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
- String iaName = action.getFunctor();
- if (iaName.equals(".if"))
- return conditional.create();
- if (iaName.equals(".while"))
- return loop.create();
- if (iaName.equals(".for"))
- return foreach.create();
+ public InternalAction getIA(String iaName) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
if (iaName.charAt(0) == '.')
iaName = "jason.stdlib" + iaName;
InternalAction objIA = internalActions.get(iaName);
Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -62,7 +62,7 @@
public InternalActionLiteral(Pred p, Agent ag) throws Exception {
super(true,p);
if (ag != null)
- ia = ag.getIA(this);
+ ia = ag.getIA(getFunctor());
}
@Override
@@ -131,7 +131,7 @@
public InternalAction getIA(Agent ag) throws Exception {
if (ia == null && ag != null)
- ia = ag.getIA(this);
+ ia = ag.getIA(getFunctor());
return ia;
}
Modified: trunk/src/jason/asSyntax/PlanBody.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBody.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/asSyntax/PlanBody.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -32,5 +32,5 @@
public boolean add(PlanBody bl);
public boolean add(int index, PlanBody bl);
- public Term removeBody(int index);
-}
\ No newline at end of file
+ public Term removeBody(int index);
+}
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -154,6 +154,7 @@
public boolean add(PlanBody bl) {
if (term == null) {
+ bl = (PlanBody)bl.clone();
swap(bl);
this.next = bl.getBodyNext();
} else if (next == null)
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-05-18 14:57:19 UTC (rev 1298)
@@ -287,7 +287,8 @@
/* Plan */
-Plan plan() : { Token k; Pred L = null;
+Plan plan() : { Token k;
+ Pred L = null;
Trigger T;
Object C = null;
PlanBody B = null;
@@ -303,10 +304,6 @@
try { ial = checkInternalActionsInContext((LogicalFormula)C, curAg); } catch (Exception e) {}
if (ial != null)
throw new ParseException(getSourceRef(ial)+" The internal action '"+ial+"' can not be used in plan's context!");
- //if (B != null) {
- //if (!(B instanceof PlanBody))
- // throw new ParseException(getSourceRef(B)+" Unknown body formula:"+B);
- //bl = (PlanBody)B;
if (B != null && B.getBodyTerm().equals(Literal.LTrue))
B = (PlanBody)B.getBodyNext();
Plan p = new Plan(L,T,(LogicalFormula)C, B);
@@ -400,11 +397,26 @@
/* Literal */
-Literal literal() : { Pred F; Token k; boolean type = Literal.LPos; }
+Literal literal() : { Pred F; Token k; boolean type = Literal.LPos; }
{
( ( [ <TK_NEG> { type = Literal.LNeg; }
]
- F=pred() { if (F.getFunctor().indexOf(".") >= 0) {
+ F=pred() {
+ if (F.getFunctor().equals("if")) {
+ Pred c = new Pred(".conditional");
+ c.setTerms(F.getTerms());
+ F = c;
+ } else if (F.getFunctor().equals("while")) {
+ Pred c = new Pred(".loop");
+ c.setTerms(F.getTerms());
+ F = c;
+ } else if (F.getFunctor().equals("for")) {
+ Pred c = new Pred(".foreach");
+ c.setTerms(F.getTerms());
+ F = c;
+ }
+
+ if (F.getFunctor().indexOf(".") >= 0) {
try {
return new InternalActionLiteral(F, curAg);
} catch (Exception e) {
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -314,7 +314,8 @@
/* Plan */
final public Plan plan() throws ParseException {
- Token k; Pred L = null;
+ Token k;
+ Pred L = null;
Trigger T;
Object C = null;
PlanBody B = null;
@@ -357,10 +358,6 @@
try { ial = checkInternalActionsInContext((LogicalFormula)C, curAg); } catch (Exception e) {}
if (ial != null)
{if (true) throw new ParseException(getSourceRef(ial)+" The internal action '"+ial+"' can not be used in plan's context!");}
- //if (B != null) {
- //if (!(B instanceof PlanBody))
- // throw new ParseException(getSourceRef(B)+" Unknown body formula:"+B);
- //bl = (PlanBody)B;
if (B != null && B.getBodyTerm().equals(Literal.LTrue))
B = (PlanBody)B.getBodyNext();
Plan p = new Plan(L,T,(LogicalFormula)C, B);
@@ -534,7 +531,7 @@
/* Literal */
final public Literal literal() throws ParseException {
- Pred F; Token k; boolean type = Literal.LPos;
+ Pred F; Token k; boolean type = Literal.LPos;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case TK_NEG:
case TK_BEGIN:
@@ -550,6 +547,20 @@
;
}
F = pred();
+ if (F.getFunctor().equals("if")) {
+ Pred c = new Pred(".conditional");
+ c.setTerms(F.getTerms());
+ F = c;
+ } else if (F.getFunctor().equals("while")) {
+ Pred c = new Pred(".loop");
+ c.setTerms(F.getTerms());
+ F = c;
+ } else if (F.getFunctor().equals("for")) {
+ Pred c = new Pred(".foreach");
+ c.setTerms(F.getTerms());
+ F = c;
+ ...
[truncated message content] |
|
From: <jom...@us...> - 2008-05-24 13:26:52
|
Revision: 1300
http://jason.svn.sourceforge.net/jason/?rev=1300&view=rev
Author: jomifred
Date: 2008-05-24 06:26:51 -0700 (Sat, 24 May 2008)
Log Message:
-----------
jason team: fix some bugs...
Modified Paths:
--------------
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-team/gauchos.xml
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/goto.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
trunk/applications/jason-team/src/java/env/WorldModel.java
trunk/applications/jason-team/src/java/jia/direction.java
trunk/applications/jason-team/todo.org
trunk/src/jason/asSemantics/Intention.java
trunk/src/jason/stdlib/drop_intention.java
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-team/gauchos.xml
===================================================================
--- trunk/applications/jason-team/gauchos.xml 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/gauchos.xml 2008-05-24 13:26:51 UTC (rev 1300)
@@ -31,9 +31,8 @@
<copy file="../jason-moise/lib/jmoise.jar" todir="lib" />
<copy file="../jason-moise/lib/moise.jar" todir="lib" />
- <mkdir dir="tmp-ag-mind" />
<delete failonerror="no" includeEmptyDirs="true" verbose="false">
- <fileset dir="massim-server/backup" includes="*"/>
+ <fileset dir="massim-server/backup" includes="**/*.xml"/>
</delete>
</target>
<target name="user-end">
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-24 13:26:51 UTC (rev 1300)
@@ -141,7 +141,7 @@
+!change_to_herding[scheme(Sch),mission(Mission)]
: cow(_,_,_)
- <- .print("ooo I see some cow, create the herding group");
+ <- .print("ooo I see some cows, create the herding group");
!!create_herding_gr.
+!change_to_herding[scheme(Sch),mission(Mission)].
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-24 13:26:51 UTC (rev 1300)
@@ -52,7 +52,7 @@
/* -- plans for the goals of all roles -- */
-+!share_seen_cows <- .print("ooo start sharing cows."); .suspend.
++!share_seen_cows[scheme(Sch)] <- .print("ooo start sharing cows in scheme ",Sch); .suspend.
// simple implementation of share_cows (see TODO above)
+cow(Id,X,Y)[source(percept)]
@@ -98,7 +98,7 @@
jmoise.remove_mission(M,Sch)
};
- // if I play herder in another group, ...
+ // if I play herder in another group, and my new role is herdboy (the groups are merging)...
if( NewRole == herdboy & play(Me,herder,G) & G \== GT) {
// ask all herdboys to also change the group
.findall(Boy,play(Boy,herdboy,G),HerdBoys);
@@ -130,10 +130,10 @@
// when I have an obligation or permission to a mission, commit to it
+obligation(Sch, Mission)
- <- .print("ooo Obligation to commit to mission ",Mission);
+ <- .print("ooo Obligation to commit to mission ",Mission, " in scheme ", Sch);
jmoise.commit_mission(Mission,Sch).
+permission(Sch, Mission)
- <- .print("ooo Permission to commit to mission ",Mission);
+ <- .print("ooo Permission to commit to mission ",Mission, " in scheme ", Sch);
jmoise.commit_mission(Mission,Sch).
// when I am not obligated to a mission anymore, uncommit
@@ -149,11 +149,13 @@
// when I am not committed to a mission anymore, remove all goals based on that mission
-commitment(Me,Mission,Sch)
: .my_name(Me)
- <- .drop_desire(_[scheme(Sch),mission(Mission)]).
+ <- .print("ooo Removing all desires related to scheme ",Sch," and mission ",Mission);
+ .drop_desire(_[scheme(Sch),mission(Mission)]).
// if some scheme is finished, drop all intentions related to it.
--scheme(_Spec,Id)
- <- .drop_desire(_[scheme(Id)]).
+-scheme(_Spec,Sch)
+ <- .print("ooo Removing all desires related to scheme ",Sch);
+ .drop_desire(_[scheme(Sch)]).
/* -- includes -- */
Modified: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-05-24 13:26:51 UTC (rev 1300)
@@ -4,15 +4,16 @@
/* -- useful rules */
-// find a free random location
+// find a free random location
+/*
random_pos(X,Y) :-
pos(AgX,AgY,_) &
jia.random(RX,40) & RX > 5 & X = (RX-20)+AgX & X > 0 &
jia.random(RY,40,5) & RY > 5 & Y = (RY-20)+AgY &
not jia.obstacle(X,Y).
+*/
-
/* -- plans to move to a destination represented in the belief target(X,Y)
-- (it is a kind of persistent goal)
*/
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-24 13:26:51 UTC (rev 1300)
@@ -42,13 +42,14 @@
.wait(4000)
}.
-// If I stop playing herboy (because the group was destroied by the herder),
+// If I stop playing herdboy (because the group was destroied by the herder),
// I should try yo create my new exploration group
+/* This plan does not work with merging!
-play(Me,herdboy,_)
: .my_name(Me)
<- .print("ooo I do not play herdboy anymore, try to play a role in an exploration group.");
!create_exploration_gr.
-
+*/
/* -- plans for the goals of role herder -- */
@@ -152,17 +153,20 @@
{ begin maintenance_goal("+pos(_,_,_)") }
-+!change_to_exploring[scheme(Sch),mission(Mission)]
++!change_to_exploring[scheme(Sch),mission(Mission),group(Gr)]
: not cow(_,_,_)
<- .print("ooo I see no cow anymore");
// wait two cycles to decide to change the formation (due to fault perception we may not see the cows)
.wait("+pos(_,_,_)");
.wait("+pos(_,_,_)");
if (not cow(_,_,_)) {
- !!create_exploration_gr
+ .findall(P, play(P,herdboy,Gr), ListBoys);
+ !!create_exploration_gr;
+ // ask helpers in my group to change the role (or create a exploration group if we merged)
+ .send(ListBoys, achieve, create_exploration_gr)
}.
-+!change_to_exploring[scheme(Sch),mission(Mission)].
++!change_to_exploring[scheme(Sch),mission(Mission),group(Gr)].
{ end }
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-24 13:26:51 UTC (rev 1300)
@@ -141,7 +141,7 @@
}
/** update the model with obstacle and share them with the team mates */
- void obstaclePerceived(int x, int y, Literal p) {
+ public void obstaclePerceived(int x, int y, Literal p) {
if (! model.hasObject(WorldModel.OBSTACLE, x, y)) {
model.add(WorldModel.OBSTACLE, x, y);
if (acView != null) acView.addObject(WorldModel.OBSTACLE, x, y);
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-24 13:26:51 UTC (rev 1300)
@@ -68,17 +68,22 @@
PrintWriter out = null;
try {
out = new PrintWriter(fileName);
+ PrintWriter map = new PrintWriter("map-status.txt");
while (true) {
try {
+ // write map
+ map.println("\n\n** Agent "+owner.getAgName()+" in cycle "+owner.getCycle()+"\n");
+ //for (int i=0; i<model.getNbOfAgs(); i++) {
+ // out.println("miner"+(i+1)+" is carrying "+model.getGoldsWithAg(i)+" gold(s), at "+model.getAgPos(i));
+ //}
+ map.println(owner.getModel().toString());
+ map.flush();
+
+ // write location of the agents
long timebefore = System.currentTimeMillis();
waitNextCycle();
long cycletime = System.currentTimeMillis() - timebefore;
- //out.println("\n\n** Agent "+getAgName()+" in cycle "+cycle+"\n");
- //for (int i=0; i<model.getNbOfAgs(); i++) {
- // out.println("miner"+(i+1)+" is carrying "+model.getGoldsWithAg(i)+" gold(s), at "+model.getAgPos(i));
- //}
- //out.println(model.toString());
StringBuilder s = new StringBuilder(String.format("Step %5d : ", owner.getCycle()-1));
for (int agId=0; agId<WorldModel.agsByTeam; agId++) {
if (agents[agId] != null) {
@@ -119,6 +124,7 @@
return;
} catch (Exception e) {
System.out.println("error getting agent status "+e);
+ sleep(1000);
}
}
} catch (Exception e) {
Modified: trunk/applications/jason-team/src/java/env/WorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/env/WorldModel.java 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/src/java/env/WorldModel.java 2008-05-24 13:26:51 UTC (rev 1300)
@@ -164,28 +164,33 @@
}
public String toString() {
- StringBuilder s = new StringBuilder();
+ StringBuilder s = new StringBuilder("|");
- s.append("---------------------------------------------\n|");
+ for (int i = 0; i < getWidth(); i++) {
+ s.append('-');
+ }
+ s.append("|\n");
+ String bar = s.toString();
for (int j = 0; j < getHeight(); j++) {
+ s.append('|');
for (int i = 0; i < getWidth(); i++) {
if (hasObject(OBSTACLE, i, j)) {
s.append('X');
- } else if (hasObject(CORRAL, i, j)) {
- s.append('-');
} else if (hasObject(AGENT, i, j)) {
s.append((getAgAtPos(i, j)+1)+"");
} else if (hasObject(COW, i, j)) {
s.append('c');
} else if (hasObject(ENEMY, i, j)) {
s.append('E');
+ } else if (hasObject(CORRAL, i, j)) {
+ s.append('-');
} else {
s.append(' ');
}
}
- s.append("|\n|");
+ s.append("|\n");
}
- s.append("---------------------------------------------\n");
+ s.append(bar);
return s.toString();
}
Modified: trunk/applications/jason-team/src/java/jia/direction.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/direction.java 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/src/java/jia/direction.java 2008-05-24 13:26:51 UTC (rev 1300)
@@ -11,10 +11,9 @@
import java.util.Random;
import java.util.logging.Level;
-import busca.Nodo;
-
import arch.CowboyArch;
import arch.LocalWorldModel;
+import busca.Nodo;
import env.WorldModel;
/**
@@ -39,7 +38,8 @@
try {
String sAction = "skip";
- LocalWorldModel model = ((CowboyArch)ts.getUserAgArch()).getModel();
+ CowboyArch arch = (CowboyArch)ts.getUserAgArch();
+ LocalWorldModel model = arch.getModel();
int iagx = (int)((NumberTerm)terms[0]).solve();
int iagy = (int)((NumberTerm)terms[1]).solve();
@@ -61,24 +61,25 @@
actionsOrder[i2] = actionsOrder[i1];
actionsOrder[i1] = temp;
- Search astar = new Search(model, from, to, actionsOrder, true, false, true, false, ts.getUserAgArch());
+ Search astar = new Search(model, from, to, actionsOrder, true, false, true, false, arch);
Nodo solution = astar.search();
if (solution == null) {
// Test impossible path
- Search s = new Search(model, from, to, ts.getUserAgArch()); // search without agent/cows as obstacles
+ Search s = new Search(model, from, to, arch); // search without agent/cows as obstacles
int fixtimes = 0;
- while (s.search() == null && ts.getUserAgArch().isRunning() && fixtimes < 10) {
+ while (s.search() == null && arch.isRunning() && fixtimes < 10) {
fixtimes++; // to avoid being in this loop forever
// if search is null, it is impossible in the scenario to goto n, set it as obstacle
ts.getLogger().info("[direction] No possible path to "+to+" setting as obstacle.");
- model.add(WorldModel.OBSTACLE, to);
+ arch.obstaclePerceived(to.x, to.y, CowboyArch.createCellPerception(to.x, to.y, CowboyArch.aOBSTACLE));
+ //model.add(WorldModel.OBSTACLE, to);
to = model.nearFree(to, null);
- s = new Search(model, from, to, ts.getUserAgArch());
+ s = new Search(model, from, to, arch);
}
// run A* again
- astar = new Search(model, from, to, actionsOrder, true, false, true, false, ts.getUserAgArch());
+ astar = new Search(model, from, to, actionsOrder, true, false, true, false, arch);
solution = astar.search();
}
Modified: trunk/applications/jason-team/todo.org
===================================================================
--- trunk/applications/jason-team/todo.org 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/applications/jason-team/todo.org 2008-05-24 13:26:51 UTC (rev 1300)
@@ -3,12 +3,10 @@
** Functioning (we have noting, but I not sure we need...)
** computation of ideal locations of an agent to maintain a formation (can we use maintainance goal pattern?)
* herding strategy
- details
* exploration strategy
- details
-* new scenarios
* protocols
* faster simulator
+* DONE new scenarios
* DONE Vectors (operations)
CLOSED: [2008-04-20 Sun 22:23]
* DONE develop a team of dummies to play against
Modified: trunk/src/jason/asSemantics/Intention.java
===================================================================
--- trunk/src/jason/asSemantics/Intention.java 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/src/jason/asSemantics/Intention.java 2008-05-24 13:26:51 UTC (rev 1300)
@@ -129,18 +129,20 @@
/** returns the IntendedMeans with TE = g, returns null if there isn't one */
public IntendedMeans getIM(Trigger g, Unifier u) {
- for (IntendedMeans im : intendedMeans) {
+ for (IntendedMeans im : intendedMeans)
//System.out.println(g + " = "+ im.getTrigger()+" = "+u.unifies(g, im.getTrigger()));
- if (u.unifies(g, im.getTrigger())) {
+ if (u.unifies(g, im.getTrigger()))
return im;
- }
- }
return null;
}
/** returns true if the intention has an IM where TE = g, using u to verify equality */
public boolean hasTrigger(Trigger g, Unifier u) {
- return getIM(g,u) != null;
+ //return getIM(g,u) != null;
+ for (IntendedMeans im : intendedMeans)
+ if (u.unifies(g, im.getTrigger()))
+ return true;
+ return false;
}
/** remove all IMs until the IM with trigger te */
Modified: trunk/src/jason/stdlib/drop_intention.java
===================================================================
--- trunk/src/jason/stdlib/drop_intention.java 2008-05-20 21:35:50 UTC (rev 1299)
+++ trunk/src/jason/stdlib/drop_intention.java 2008-05-24 13:26:51 UTC (rev 1300)
@@ -111,7 +111,7 @@
// intention may be suspended in PI! (in the new semantics)
for (Intention i: C.getPendingIntentions().values()) {
- if (i != null && i.hasTrigger(g, un)) {
+ if (i.hasTrigger(g, un)) {
C.dropPendingIntention(i);
un = bak.copy();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-25 11:33:10
|
Revision: 1305
http://jason.svn.sourceforge.net/jason/?rev=1305&view=rev
Author: jomifred
Date: 2008-05-25 04:33:07 -0700 (Sun, 25 May 2008)
Log Message:
-----------
fix bug in jason-moisem
Modified Paths:
--------------
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-team/gauchos.xml
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/arch/ACProxy.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/jia/direction.java
trunk/release-notes.txt
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-25 11:33:07 UTC (rev 1305)
@@ -105,7 +105,6 @@
currentOE = (OE) m.getPropCont();
i.remove();
} else if (m.getSender().equals(getOrgManagerName())) {
-
// the content is a normal predicate
final String content = m.getPropCont().toString();
@@ -146,15 +145,16 @@
i.remove();
Literal cl = delAsBel(content);
- if (content.startsWith("scheme")) {
- String schId = cl.getTerm(1).toString();
- cleanGoalsOfSch(schId);
- removeBeliefs(schId);
- } else if (content.startsWith("scheme_group")) {
+ if (content.startsWith("scheme_group")) {
Term sch = cl.getTerm(0);
Term gr = cl.getTerm(1);
+ logger.info("***** xxxx removing sch grp "+content);
removeObligationPermissionBeliefs(sch, gr, "obligation");
removeObligationPermissionBeliefs(sch, gr, "permission");
+ } else if (content.startsWith("scheme")) {
+ String schId = cl.getTerm(1).toString();
+ cleanGoalsOfSch(schId);
+ removeBeliefs(schId);
} else if (content.startsWith("commitment")) {
// if I remove my commit, remove the goals from BB
String schId = cl.getTerm(2).toString();
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-25 11:33:07 UTC (rev 1305)
@@ -231,6 +231,10 @@
for (RolePlayer rp : gr.getPlayers()) {
updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + gr.getId() + ")", false, false);
}
+ for (SchemeInstance sch : gr.getRespSchemes()) {
+ logger.info("xxxx send remove sch grp "+sch.getId()+" to "+sender);
+ updateMembersOE(sender, "scheme_group(" + sch.getId() + "," + grId + ")", false, false);
+ }
}
sendReply(sender, mId, "ok");
}
@@ -360,6 +364,8 @@
// also send untell scheme_group (if it is the case)
for (SchemeInstance sch: gr.getRespSchemes()) {
+ logger.info("xxxx send remove sch grp "+sch.getId()+" to "+gr.getPlayers());
+
updateMembersOE(gr.getPlayers(), "scheme_group(" + sch.getId() + "," + grId + ")", false, false);
}
// untell players
Modified: trunk/applications/jason-team/gauchos.xml
===================================================================
--- trunk/applications/jason-team/gauchos.xml 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/applications/jason-team/gauchos.xml 2008-05-25 11:33:07 UTC (rev 1305)
@@ -32,7 +32,7 @@
<copy file="../jason-moise/lib/moise.jar" todir="lib" />
<delete failonerror="no" includeEmptyDirs="true" verbose="false">
- <fileset dir="massim-server/backup" includes="**/*.xml"/>
+ <fileset dir="massim-server/backup" includes="**/*"/>
</delete>
</target>
<target name="user-end">
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-25 11:33:07 UTC (rev 1305)
@@ -40,6 +40,7 @@
+end_of_simulation(_Result)
<- -end_of_simulation(_);
.drop_all_desires;
+ .abolish(cow(_,_,_));
!remove_org.
+!restart
@@ -50,13 +51,9 @@
!create_exploration_gr.
+!restart
<- .print("*** restart -- even ***");
+ !quite_all_missions_roles;
+
.my_name(Me);
-
- // if I play any role, give it up
- while( play(Me,R,OG) ) {
- jmoise.remove_role(R,OG)
- };
-
// try to adopt scouter in some exploration
.findall(GE, group(exploration_grp,GE), LGE);
!try_adopt(scouter,LGE);
@@ -67,7 +64,7 @@
!try_adopt(herdboy,LGH)
}.
-+!try_adopt(Role,[]).
++!try_adopt(_Role,[]).
+!try_adopt(Role,[G|_])
<- .print("ooo try role ",Role, " in ",G);
jmoise.adopt_role(Role,G).
@@ -81,17 +78,21 @@
//+!share_seen_cows[scheme(Sch)] <- .print("ooo start sharing cows in scheme ",Sch); .suspend.
// simple implementation of share_cows
-+cow(Id,X,Y)[source(percept)]
- : .my_name(Me) & play(Me,_,Gr) & (play(Leader,explorer,Gr) | play(Leader,herder,Gr)) // .intend(share_seen_cows)
- <- //.print("ooo broadcast ",cow(Id,X,Y));
++cow(Id,X,Y)[source(percept),step(C)]
+ : .my_name(Me) & play(Me,_,Gr) &
+ (play(Leader,explorer,Gr) | play(Leader,herder,Gr)) &
+ Leader \== Me // .intend(share_seen_cows)
+ <- //.print("ooo send cow ",cow(Id,X,Y));
//jmoise.broadcast(Gr, tell, cow(Id,X,Y)).
- .send(Leader, tell, cow(Id,X,Y)).
+ .send(Leader, tell, cow(Id,X,Y)[step(C)]).
-cow(Id,X,Y)[source(percept)]
- : .my_name(Me) & play(Me,_,Gr) //& (play(Leader,explorer,Gr) | play(Leader,herder,Gr)) // .intend(share_seen_cows)
- <- jmoise.broadcast(Gr, untell, cow(Id,X,Y)).
+ //: .my_name(Me) & play(Me,_,Gr) //& (play(Leader,explorer,Gr) | play(Leader,herder,Gr)) // .intend(share_seen_cows)
+ <- //.print("ooo broadcast untell cow ",cow(Id,X,Y));
+ .broadcast( untell, cow(Id,X,Y)).
//.send(Leader, untell, cow(Id,X,Y)).
+
/* -- general organisational plans -- */
// remove all groups and schemes (only agent1 does that)
@@ -121,24 +122,13 @@
<- .my_name(Me);
.print("ooo Changing to role ",NewRole," in group ",GT,", as asked by ",S);
- // give up all missions
- while( commitment(Me,M,Sch) ) {
- .print("ooo removing my mission ",M," in ",Sch);
- jmoise.remove_mission(M,Sch)
- };
-
// if I play herder in another group, and my new role is herdboy (the groups are merging)...
if( NewRole == herdboy & play(Me,herder,G) & G \== GT) {
// ask all herdboys to also change the group
.findall(Boy,play(Boy,herdboy,G),HerdBoys);
.send(HerdBoys, achieve, change_role(herdboy,GT))
};
-
- // if I play any other role, give it up
- while( play(Me,R,OG) & OG \== GT) {
- jmoise.remove_role(R,OG)
- };
-
+ !quite_all_missions_roles;
jmoise.adopt_role(NewRole,GT).
-!change_role(R,G)
@@ -149,6 +139,22 @@
+!play_role(Role,Group)[source(Ag)]
<- .print("ooo Adopting role ",Role," in group ",Group,", as asked by ",Ag);
jmoise.adopt_role(Role, Group).
+
++!quite_all_missions_roles
+ <- .my_name(Me);
+
+ // give up all missions
+ while( commitment(Me,M,Sch) ) {
+ .print("ooo removing my mission ",M," in ",Sch);
+ jmoise.remove_mission(M,Sch)
+ };
+
+ // if I play any other role, give it up
+ while( play(Me,R,OG) ) {
+ .print("ooo removing my role ",R," in ",OG);
+ jmoise.remove_role(R,OG)
+ }.
+
// finish the scheme if it has no more players
// and it was created by me
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-25 11:33:07 UTC (rev 1305)
@@ -38,6 +38,7 @@
<- for( group(herding_grp,G)[owner(Me)] ) {
-group_leader(G,Me);
.broadcast(untell, group_leader(G,Me));
+ .print("ooo removing the group ",G);
jmoise.remove_group(G);
.wait(4000)
}.
@@ -88,10 +89,14 @@
?my_group_players(G, herder);
jia.cluster(Cluster,CAsList);
-+current_cluster(CAsList);
- jia.herd_position(.length(G),Cluster,L);
- .reverse(L,RL); // use the reversed list so to priorise the border positions
- .print("ooo Formation is ",RL, " for agents ",G," in cluster ", Cluster);
- !alloc_all(G,RL).
+ if ( .length(CAsList) > 0) {
+ jia.herd_position(.length(G),Cluster,L);
+ .reverse(L,RL); // use the reversed list so to priorise the border positions
+ .print("ooo Formation is ",RL, " for agents ",G," in cluster ", Cluster);
+ !alloc_all(G,RL)
+ }{
+ .print("ooo No cluster to define the formation!")
+ }.
{ end }
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-05-25 11:33:07 UTC (rev 1305)
@@ -2,6 +2,7 @@
import jason.asSyntax.Literal;
import jason.asSyntax.NumberTermImpl;
+import jason.asSyntax.Structure;
import jason.environment.grid.Location;
import java.util.ArrayList;
@@ -187,7 +188,10 @@
int cowId = Integer.parseInt(type.getAttribute("ID"));
Literal lc = new Literal("cow");
lc.addTerms(new NumberTermImpl( cowId ), new NumberTermImpl( absx), new NumberTermImpl(absy));
- percepts.add( lc); //CowboyArch.createCellPerception(absx, absy, lc));
+ Structure stepannot = new Structure("step",1);
+ stepannot.addTerm(new NumberTermImpl(step));
+ lc.addAnnot(stepannot);
+ percepts.add(lc);
//arq.cowPerceived(absx, absy);
} else if (type.getNodeName().equals("obstacle")) {
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-25 11:33:07 UTC (rev 1305)
@@ -148,9 +148,7 @@
Message m = new Message("tell", null, null, p);
try {
broadcast(m);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ } catch (Exception e) { e.printStackTrace(); }
}
}
Modified: trunk/applications/jason-team/src/java/jia/direction.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/direction.java 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/applications/jason-team/src/java/jia/direction.java 2008-05-25 11:33:07 UTC (rev 1305)
@@ -68,7 +68,7 @@
// Test impossible path
Search s = new Search(model, from, to, arch); // search without agent/cows as obstacles
int fixtimes = 0;
- while (s.search() == null && arch.isRunning() && fixtimes < 10) {
+ while (s.search() == null && arch.isRunning() && fixtimes < 100) { // the number should be great enough to set all corral as obstacles
fixtimes++; // to avoid being in this loop forever
// if search is null, it is impossible in the scenario to goto n, set it as obstacle
ts.getLogger().info("[direction] No possible path to "+to+" setting as obstacle.");
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-05-25 10:27:28 UTC (rev 1304)
+++ trunk/release-notes.txt 2008-05-25 11:33:07 UTC (rev 1305)
@@ -7,6 +7,8 @@
Bugs fixed:
. BUF add annotation "source(percept)" in the perception deletion event
+. drop_desire does not remove desires in Circumstance.Event correctly
+ when annotations are used.
-------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-25 13:45:16
|
Revision: 1306
http://jason.svn.sourceforge.net/jason/?rev=1306&view=rev
Author: jomifred
Date: 2008-05-25 06:45:14 -0700 (Sun, 25 May 2008)
Log Message:
-----------
jason team: remove cows not seen from BB
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-team/src/java/agent/SelectEvent.java
trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java
trunk/applications/jason-team/src/java/arch/ACArchitecture.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
trunk/src/jason/asSemantics/Agent.java
Added Paths:
-----------
trunk/applications/jason-team/src/java/test/TestUniqueBB.java
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-25 11:33:07 UTC (rev 1305)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -148,7 +148,6 @@
if (content.startsWith("scheme_group")) {
Term sch = cl.getTerm(0);
Term gr = cl.getTerm(1);
- logger.info("***** xxxx removing sch grp "+content);
removeObligationPermissionBeliefs(sch, gr, "obligation");
removeObligationPermissionBeliefs(sch, gr, "permission");
} else if (content.startsWith("scheme")) {
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-25 11:33:07 UTC (rev 1305)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -232,7 +232,6 @@
updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + gr.getId() + ")", false, false);
}
for (SchemeInstance sch : gr.getRespSchemes()) {
- logger.info("xxxx send remove sch grp "+sch.getId()+" to "+sender);
updateMembersOE(sender, "scheme_group(" + sch.getId() + "," + grId + ")", false, false);
}
}
@@ -364,8 +363,6 @@
// also send untell scheme_group (if it is the case)
for (SchemeInstance sch: gr.getRespSchemes()) {
- logger.info("xxxx send remove sch grp "+sch.getId()+" to "+gr.getPlayers());
-
updateMembersOE(gr.getPlayers(), "scheme_group(" + sch.getId() + "," + grId + ")", false, false);
}
// untell players
Modified: trunk/applications/jason-team/src/java/agent/SelectEvent.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/SelectEvent.java 2008-05-25 11:33:07 UTC (rev 1305)
+++ trunk/applications/jason-team/src/java/agent/SelectEvent.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -4,9 +4,11 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Event;
import jason.asSemantics.Unifier;
+import jason.asSyntax.Literal;
import jason.asSyntax.Trigger;
import java.util.Iterator;
+import java.util.List;
import java.util.Queue;
/**
@@ -18,7 +20,8 @@
private Trigger cow = Trigger.parseTrigger("+cow(_,_,_)");
private Unifier un = new Unifier();
-
+ private boolean cleanCows = false;
+
public Event selectEvent(Queue<Event> events) {
Iterator<Event> ie = events.iterator();
while (ie.hasNext()) {
@@ -31,4 +34,19 @@
}
return super.selectEvent(events);
}
+
+ public void cleanCows() {
+ cleanCows = true;
+ }
+
+ @Override
+ public void buf(List<Literal> percepts) {
+ super.buf(percepts);
+ if (cleanCows) {
+ // remove old cows from the memory
+
+ ((UniqueBelsBB)getTS().getAg().getBB()).remove_old_bels(Literal.parseLiteral("cow(x,x,x)"), "step", 6, getTS().getUserAgArch().getCycleNumber());
+ cleanCows = false;
+ }
+ }
}
Modified: trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java 2008-05-25 11:33:07 UTC (rev 1305)
+++ trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -3,11 +3,15 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
+import jason.asSyntax.NumberTerm;
+import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.bb.DefaultBeliefBase;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
/**
@@ -27,8 +31,10 @@
Map<String,Literal> uniqueBels = new HashMap<String,Literal>();
Unifier u = new Unifier();
+ Agent myAgent;
public void init(Agent ag, String[] args) {
+ this.myAgent = ag;
for (int i=0; i<args.length; i++) {
Literal arg = Literal.parseLiteral(args[i]);
uniqueBels.put(arg.getFunctor(), arg);
@@ -76,5 +82,40 @@
}
return super.add(bel);
}
+
+ public void remove_old_bels(Literal bel, String timeAnnot, int maxAge, int curAge) {
+ Iterator<Literal> relevant = getCandidateBeliefs(bel, null);
+ if (relevant != null) {
+ List<Literal> toDel = new ArrayList<Literal>();
+ while (relevant.hasNext()) {
+ Literal linbb = relevant.next();
+ // find greatest timeAnnot
+ Structure bTime = null;
+ if (linbb.hasAnnot()) {
+ for (Term t: linbb.getAnnots()) {
+ if (t.isStructure()) {
+ Structure s = (Structure)t;
+ if (s.getFunctor().equals(timeAnnot)) {
+ if (bTime == null || bTime.compareTo(s) < 0)
+ bTime = s;
+ }
+ }
+ }
+
+ // if bTime was found
+ if (bTime != null) {
+ int age = (int)((NumberTerm)bTime.getTerm(0)).solve();
+ if (curAge - age > maxAge)
+ toDel.add(linbb);
+ }
+ }
+ }
+ for (Literal l: toDel) {
+ myAgent.getLogger().info("Removing "+l+" from BB because it is too old (current step is "+curAge+")");
+ remove(l);
+ }
+ }
+ }
+
}
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-05-25 11:33:07 UTC (rev 1305)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -82,7 +82,7 @@
percepts = p;
waitSleepThread.newCycle();
getTS().getUserAgArch().getArchInfraTier().wake();
- setCycle(step);
+ setSimStep(step);
}
/** all actions block its intention and succeed in the end of the cycle,
@@ -160,7 +160,7 @@
void newCycle() {
cycleCounter++;
- if (getCycle() == 1) cycleCounter = 1;
+ if (getSimStep() == 1) cycleCounter = 1;
StringBuilder notsent = new StringBuilder();
if (toExecute.size() > 1) {
@@ -192,7 +192,7 @@
}
timestartcycle = System.currentTimeMillis();
- logger.info(w+"Last sent action was "+lastActionInCurrentCycle+" for cycle "+getCycle()+ timetoact + notsent);
+ logger.info(w+"Last sent action was "+lastActionInCurrentCycle+" for cycle "+getSimStep()+ timetoact + notsent);
setLastAct(lastActionInCurrentCycle);
lastActionInCurrentCycle = null;
}
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-25 11:33:07 UTC (rev 1305)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -18,6 +18,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import agent.SelectEvent;
import env.ACViewer;
import env.WorldModel;
import env.WorldView;
@@ -40,7 +41,7 @@
String massimBackDir = null;
ACViewer acView = null;
- int cycle = 0;
+ int simStep = 0;
WriteStatusThread writeStatusThread = null;
@@ -175,8 +176,8 @@
return lastAct;
}
- public int getCycle() {
- return cycle;
+ public int getSimStep() {
+ return simStep;
}
@@ -240,21 +241,6 @@
model.clearCows();
}
- //void cowPerceived(int x, int y) {
- // model.addCow(x,y);
- //}
-
- /*
- void sendCowsToTeam() {
- try {
- Message m = new Message("tell-cows", null, null, new ArrayList<Location>(model.getCows()));
- broadcast(m);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- */
-
void enemyPerceived(int x, int y) {
model.add(WorldModel.ENEMY, x, y);
}
@@ -266,10 +252,11 @@
if (view != null) view.dispose();
}
- void setCycle(int s) {
- cycle = s;
- super.setCycleNumber(cycle);
- if (view != null) view.setCycle(cycle);
+ void setSimStep(int s) {
+ ((SelectEvent)getTS().getAg()).cleanCows();
+ simStep = s;
+ super.setCycleNumber(simStep);
+ if (view != null) view.setCycle(simStep);
if (writeStatusThread != null) writeStatusThread.go();
}
@@ -361,7 +348,7 @@
}
}
}
-
+
public static int getAgId(String agName) {
return (Integer.parseInt(agName.substring(agName.length()-1))) - 1;
}
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-25 11:33:07 UTC (rev 1305)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -67,7 +67,7 @@
while (true) {
try {
// write map
- map.println("\n\n** Agent "+owner.getAgName()+" in cycle "+owner.getCycle()+"\n");
+ map.println("\n\n** Agent "+owner.getAgName()+" in cycle "+owner.getSimStep()+"\n");
//for (int i=0; i<model.getNbOfAgs(); i++) {
// out.println("miner"+(i+1)+" is carrying "+model.getGoldsWithAg(i)+" gold(s), at "+model.getAgPos(i));
//}
@@ -79,7 +79,7 @@
waitNextCycle();
long cycletime = System.currentTimeMillis() - timebefore;
- StringBuilder s = new StringBuilder(String.format("Step %5d : ", owner.getCycle()-1));
+ StringBuilder s = new StringBuilder(String.format("Step %5d : ", owner.getSimStep()-1));
for (int agId=0; agId<WorldModel.agsByTeam; agId++) {
if (agents[agId] != null) {
Location agp = agents[agId].getLastLocation();
@@ -113,7 +113,7 @@
if (!dirmind.exists())
dirmind.mkdirs();
String agmind = transformer.transform(arch.getTS().getAg().getAgState());
- String filename = String.format("%5d.xml",arch.getCycle()).replaceAll(" ","0");
+ String filename = String.format("%5d.xml",arch.getSimStep()).replaceAll(" ","0");
FileWriter outmind = new FileWriter(new File(dirmind+"/"+filename));
outmind.write(agmind);
outmind.close();
Added: trunk/applications/jason-team/src/java/test/TestUniqueBB.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestUniqueBB.java (rev 0)
+++ trunk/applications/jason-team/src/java/test/TestUniqueBB.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -0,0 +1,28 @@
+package test;
+
+import static org.junit.Assert.assertEquals;
+import jason.asSyntax.Literal;
+
+import org.junit.Test;
+
+import agent.UniqueBelsBB;
+
+
+public class TestUniqueBB {
+
+ @Test
+ public void removeOldBB() {
+ UniqueBelsBB bb = new UniqueBelsBB();
+ bb.add(Literal.parseLiteral("cow(1,1,1)[step(3),step(1),step(6)]"));
+ bb.add(Literal.parseLiteral("cow(2,1,1)[step(10),step(1),step(6)]"));
+ bb.add(Literal.parseLiteral("cow(3,1,1)"));
+
+ bb.remove_old_bels(Literal.parseLiteral("cow(1,1,1)"), "step", 4, 11);
+
+ assertEquals(2, bb.size());
+
+ bb.remove_old_bels(Literal.parseLiteral("cow(1,1,1)"), "step", 4, 12);
+ bb.remove_old_bels(Literal.parseLiteral("cow(1,1,1)"), "step", 4, 15);
+ assertEquals(1, bb.size());
+ }
+}
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-05-25 11:33:07 UTC (rev 1305)
+++ trunk/src/jason/asSemantics/Agent.java 2008-05-25 13:45:14 UTC (rev 1306)
@@ -457,7 +457,7 @@
// if perception t is already in BB
if (l.equalsAsStructure(t) && l.negated() == t.negated()) {
wasPerceived = true;
- ip.remove(); // remove in percepts, since it already is in BB
+ // ip.remove(); // remove in percepts, since it already is in BB [can not be removed, since annots in this percepts should be added in BB/Jason team for AC, for example, use annots in perceptions]
break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|