You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
(35) |
Apr
(96) |
May
(39) |
Jun
(25) |
Jul
(7) |
Aug
(7) |
Sep
(44) |
Oct
(17) |
Nov
(14) |
Dec
(9) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(5) |
Feb
(28) |
Mar
(26) |
Apr
(14) |
May
(3) |
Jun
(3) |
Jul
(13) |
Aug
(41) |
Sep
(12) |
Oct
|
Nov
(2) |
Dec
(17) |
| 2010 |
Jan
(9) |
Feb
(5) |
Mar
(11) |
Apr
(3) |
May
(4) |
Jun
(2) |
Jul
(3) |
Aug
(8) |
Sep
(2) |
Oct
(11) |
Nov
(3) |
Dec
(1) |
| 2011 |
Jan
|
Feb
(1) |
Mar
(8) |
Apr
(4) |
May
(4) |
Jun
(5) |
Jul
(3) |
Aug
(2) |
Sep
(7) |
Oct
(4) |
Nov
(4) |
Dec
(2) |
| 2012 |
Jan
|
Feb
|
Mar
(4) |
Apr
(11) |
May
(8) |
Jun
(2) |
Jul
(7) |
Aug
(6) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(3) |
| 2013 |
Jan
|
Feb
(1) |
Mar
(7) |
Apr
(3) |
May
(1) |
Jun
(4) |
Jul
(8) |
Aug
(4) |
Sep
(4) |
Oct
(6) |
Nov
(8) |
Dec
(6) |
| 2014 |
Jan
|
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(10) |
Jul
|
Aug
(7) |
Sep
(15) |
Oct
(4) |
Nov
(1) |
Dec
(1) |
| 2015 |
Jan
|
Feb
(1) |
Mar
(10) |
Apr
(4) |
May
(6) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(5) |
Nov
(6) |
Dec
(12) |
| 2016 |
Jan
(1) |
Feb
(4) |
Mar
(7) |
Apr
(30) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
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.
|
|
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 10:27:30
|
Revision: 1304
http://jason.svn.sourceforge.net/jason/?rev=1304&view=rev
Author: jomifred
Date: 2008-05-25 03:27:28 -0700 (Sun, 25 May 2008)
Log Message:
-----------
fix small bug in drop_desire
Modified Paths:
--------------
trunk/src/jason/stdlib/drop_desire.java
Modified: trunk/src/jason/stdlib/drop_desire.java
===================================================================
--- trunk/src/jason/stdlib/drop_desire.java 2008-05-24 17:36:40 UTC (rev 1303)
+++ trunk/src/jason/stdlib/drop_desire.java 2008-05-25 10:27:28 UTC (rev 1304)
@@ -94,7 +94,7 @@
t = (Trigger) t.clone();
t.apply(ei.getIntention().peek().getUnif());
}
- if (un.copy().unifiesNoUndo(t, te)) {
+ if (un.copy().unifiesNoUndo(te, t)) {
// old implementation: t.setTrigType(Trigger.TEDel); // Just changing "+!g" to "-!g"
ie.remove();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-24 17:36:41
|
Revision: 1303
http://jason.svn.sourceforge.net/jason/?rev=1303&view=rev
Author: jomifred
Date: 2008-05-24 10:36:40 -0700 (Sat, 24 May 2008)
Log Message:
-----------
first implementation of restart
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-24 17:09:49 UTC (rev 1302)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-24 17:36:40 UTC (rev 1303)
@@ -42,23 +42,39 @@
.drop_all_desires;
!remove_org.
-+!restart.
++!restart
+ : .my_name(Me) &
+ agent_id(Me,AgId) &
+ AgId mod 2 == 1 // I have an odd Id
+ <- .print("*** restart -- odd ***");
+ !create_exploration_gr.
++!restart
+ <- .print("*** restart -- even ***");
+ .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);
+
+ // if I still have no role, try herdboy
+ if ( not play(Me,_,_) ) {
+ .findall(GH, group(herding_grp,GH), LGH);
+ !try_adopt(herdboy,LGH)
+ }.
-/*
-se for impar
- create_gr
-se for par
- 1. tenta entrar explorer
- 2.a tenta herding
- 2.b no que tem o menor nro de vacas
-*/
++!try_adopt(Role,[]).
++!try_adopt(Role,[G|_])
+ <- .print("ooo try role ",Role, " in ",G);
+ jmoise.adopt_role(Role,G).
+-!try_adopt(Role,[_|RG])
+ <- !try_adopt(Role,RG).
+
- //<- //.print("*** restart ***");
- //.drop_all_desires;
- //.abolish(cow(_,_,_)).
- // TODO: what to do?
- //!decide_target.
-
/* -- plans for the goals of all roles -- */
@@ -71,9 +87,9 @@
//jmoise.broadcast(Gr, tell, cow(Id,X,Y)).
.send(Leader, tell, cow(Id,X,Y)).
-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)).
- .send(Leader, untell, cow(Id,X,Y)).
+ : .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)).
+ //.send(Leader, untell, cow(Id,X,Y)).
/* -- general organisational plans -- */
Modified: trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java 2008-05-24 17:09:49 UTC (rev 1302)
+++ trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java 2008-05-24 17:36:40 UTC (rev 1303)
@@ -64,6 +64,7 @@
}
}
}
+ // TODO: prefer source(percept) info
if (equals) {
remove = true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-24 17:09:52
|
Revision: 1302
http://jason.svn.sourceforge.net/jason/?rev=1302&view=rev
Author: jomifred
Date: 2008-05-24 10:09:49 -0700 (Sat, 24 May 2008)
Log Message:
-----------
jason team: fix bug broacast cows
Modified Paths:
--------------
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-24 15:15:42 UTC (rev 1301)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-24 17:09:49 UTC (rev 1302)
@@ -19,42 +19,42 @@
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
- "target(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
+ "target(_,_)", "group_leader(key,_)", //"cow(key,_,_)",
"group_area(key, _)");
directives: maintenance_goal = agent.OrgMaintenanceGoal;
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-24 15:15:42 UTC (rev 1301)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-24 17:09:49 UTC (rev 1302)
@@ -43,6 +43,16 @@
!remove_org.
+!restart.
+
+/*
+se for impar
+ create_gr
+se for par
+ 1. tenta entrar explorer
+ 2.a tenta herding
+ 2.b no que tem o menor nro de vacas
+*/
+
//<- //.print("*** restart ***");
//.drop_all_desires;
//.abolish(cow(_,_,_)).
@@ -54,13 +64,16 @@
//+!share_seen_cows[scheme(Sch)] <- .print("ooo start sharing cows in scheme ",Sch); .suspend.
-// simple implementation of share_cows (see TODO above)
+// simple implementation of share_cows
+cow(Id,X,Y)[source(percept)]
- : .my_name(Me) & play(Me,_,Gr) // .intend(share_seen_cows)
- <- jmoise.broadcast(Gr, tell, 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 ",cow(Id,X,Y));
+ //jmoise.broadcast(Gr, tell, cow(Id,X,Y)).
+ .send(Leader, tell, cow(Id,X,Y)).
-cow(Id,X,Y)[source(percept)]
- : .my_name(Me) & play(Me,_,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)
+ <- //jmoise.broadcast(Gr, untell, cow(Id,X,Y)).
+ .send(Leader, untell, cow(Id,X,Y)).
/* -- general organisational plans -- */
Modified: trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java 2008-05-24 15:15:42 UTC (rev 1301)
+++ trunk/applications/jason-team/src/java/agent/UniqueBelsBB.java 2008-05-24 17:09:49 UTC (rev 1302)
@@ -51,6 +51,9 @@
while (relevant.hasNext() && !remove) {
linbb = relevant.next();
+ // check equality of all terms that are "key"
+ // if some key is different, no problem
+ // otherwise, remove the current bel
boolean equals = true;
for (int i = 0; i<kbArity; i++) {
Term kbt = kb.getTerm(i);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-24 15:15:45
|
Revision: 1301
http://jason.svn.sourceforge.net/jason/?rev=1301&view=rev
Author: jomifred
Date: 2008-05-24 08:15:42 -0700 (Sat, 24 May 2008)
Log Message:
-----------
jason team: dump the mind of all agents
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/java/arch/WriteStatusThread.java
trunk/applications/jason-team/src/team-os.xml
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-24 13:26:51 UTC (rev 1300)
+++ trunk/applications/jason-team/gauchos.xml 2008-05-24 15:15:42 UTC (rev 1301)
@@ -93,7 +93,7 @@
<target name="run" depends="compile" >
<delete failonerror="no" includeEmptyDirs="true" verbose="false">
- <fileset dir="mind-ag-gaucho1" includes="*.xml"/>
+ <fileset dir="mind-ag" includes="**/*.xml"/>
</delete>
<echo message="Running project ${ant.project.name}" />
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-24 13:26:51 UTC (rev 1300)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-24 15:15:42 UTC (rev 1301)
@@ -23,9 +23,7 @@
agent_id(Me,AgId) &
AgId mod 2 == 1 & // I have an odd Id and thus have to create a exploring group
not .intend(create_exploration_gr)
- <- .my_name(Me);
-
- // create the team, if necessary
+ <- // create the team, if necessary
if( Me == gaucho1 & not group(team,_) ) {
jmoise.create_group(team)
};
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-24 13:26:51 UTC (rev 1300)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-24 15:15:42 UTC (rev 1301)
@@ -52,14 +52,14 @@
/* -- plans for the goals of all roles -- */
-+!share_seen_cows[scheme(Sch)] <- .print("ooo start sharing cows in scheme ",Sch); .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)]
- : .intend(share_seen_cows) & .my_name(Me) & play(Me,_,Gr)
+ : .my_name(Me) & play(Me,_,Gr) // .intend(share_seen_cows)
<- jmoise.broadcast(Gr, tell, cow(Id,X,Y)).
-cow(Id,X,Y)[source(percept)]
- : .intend(share_seen_cows) & .my_name(Me) & play(Me,_,Gr)
+ : .my_name(Me) & play(Me,_,Gr) // .intend(share_seen_cows)
<- jmoise.broadcast(Gr, untell, cow(Id,X,Y)).
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-24 13:26:51 UTC (rev 1300)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-24 15:15:42 UTC (rev 1301)
@@ -57,16 +57,11 @@
reset();
String fileName = "world-status.txt";
- File dirmind = null;
- try {
- dirmind = new File("mind-ag-"+owner.getAgName());
- dirmind.mkdir();
- } catch (Exception e) {
- dirmind = null;
- }
PrintWriter out = null;
try {
+ asl2xml transformer = new asl2xml();
+
out = new PrintWriter(fileName);
PrintWriter map = new PrintWriter("map-status.txt");
while (true) {
@@ -111,19 +106,26 @@
out.flush();
- // store the agent'd mind
- if (dirmind != null) {
- String agmind = new asl2xml().transform(owner.getTS().getAg().getAgState());
- String filename = String.format("%5d.xml",owner.getCycle()).replaceAll(" ","0");
- FileWriter outmind = new FileWriter(new File(dirmind.getName()+"/"+filename));
- outmind.write(agmind);
- outmind.close();
+ // store the agents' mind
+ for (CowboyArch arch : agents) {
+ try {
+ File dirmind = new File("mind-ag/"+arch.getAgName());
+ if (!dirmind.exists())
+ dirmind.mkdirs();
+ String agmind = transformer.transform(arch.getTS().getAg().getAgState());
+ String filename = String.format("%5d.xml",arch.getCycle()).replaceAll(" ","0");
+ FileWriter outmind = new FileWriter(new File(dirmind+"/"+filename));
+ outmind.write(agmind);
+ outmind.close();
+ } catch (Exception e) {
+ System.out.println("error getting agent status "+e);
+ }
}
} catch (InterruptedException e) { // no problem, quit the thread
return;
} catch (Exception e) {
- System.out.println("error getting agent status "+e);
+ System.out.println("error in writing status "+e);
sleep(1000);
}
}
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-05-24 13:26:51 UTC (rev 1300)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-24 15:15:42 UTC (rev 1301)
@@ -92,12 +92,12 @@
<mission id="explore" min="1">
<goal id="find_scouter" />
<goal id="goto_near_unvisited" />
- <goal id="share_seen_cows" />
+ <!--goal id="share_seen_cows" /-->
<goal id="change_to_herding" />
</mission>
<mission id="scout" >
<goal id="follow_leader" />
- <goal id="share_seen_cows" />
+ <!--goal id="share_seen_cows" /-->
</mission>
</scheme>
@@ -116,12 +116,12 @@
<goal id="recruit" />
<goal id="define_formation" />
<goal id="be_in_formation" />
- <goal id="share_seen_cows" />
+ <!--goal id="share_seen_cows" /-->
<goal id="change_to_exploring" />
</mission>
<mission id="help_herder" >
<goal id="be_in_formation" />
- <goal id="share_seen_cows" />
+ <!--goal id="share_seen_cows" /-->
</mission>
</scheme>
</functional-specification>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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-20 21:35:56
|
Revision: 1299
http://jason.svn.sourceforge.net/jason/?rev=1299&view=rev
Author: jomifred
Date: 2008-05-20 14:35:50 -0700 (Tue, 20 May 2008)
Log Message:
-----------
jason team: change from herding group to exploration group
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/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/gauchos.xml
trunk/applications/jason-team/readme.txt
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/WriteStatusThread.java
trunk/applications/jason-team/src/team-os.xml
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-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-20 21:35:50 UTC (rev 1299)
@@ -123,8 +123,10 @@
i.remove();
if (content.startsWith("goal_state")) {
// the state of a scheme i belong to has changed
- updateGoalBels( Pred.parsePred(content) );
+ // add all goals of the scheme in BB
+ updateGoalBels = true;
updateGoalEvt = true;
+ // Note: must change all goals, because the state of others may also change (waiting->possible)
} else {
Literal cl = addAsBel(content);
@@ -132,7 +134,9 @@
// this message is generated when my group becomes
// responsible for a scheme
generateObligationPermissionEvents(cl);
- } else if (content.startsWith("commitment")) {
+ } else if (content.startsWith("commitment")) {
+ // add all goals of the scheme in BB
+ updateGoalBels = true;
// I need to generate AS Triggers like !<orggoal> since some scheme becomes well formed
updateGoalEvt = true;
}
@@ -144,11 +148,21 @@
if (content.startsWith("scheme")) {
String schId = cl.getTerm(1).toString();
- removeAchieveGoalsOfSch(schId);
+ cleanGoalsOfSch(schId);
removeBeliefs(schId);
} else if (content.startsWith("scheme_group")) {
- removeObligationPermissionBeliefs(cl, "obligation");
- removeObligationPermissionBeliefs(cl, "permission");
+ Term sch = cl.getTerm(0);
+ Term gr = cl.getTerm(1);
+ removeObligationPermissionBeliefs(sch, gr, "obligation");
+ removeObligationPermissionBeliefs(sch, gr, "permission");
+ } else if (content.startsWith("commitment")) {
+ // if I remove my commit, remove the goals from BB
+ String schId = cl.getTerm(2).toString();
+ SchemeInstance sch = currentOE.findScheme(schId);
+ if (sch != null && !sch.isPlayer(getMyOEAgent())) {
+ cleanGoalsOfSch(schId);
+ removeBeliefs(schId);
+ }
}
}
}
@@ -237,13 +251,10 @@
}
- private void removeObligationPermissionBeliefs(Pred m, String type) throws RevisionFailedException {
+ private void removeObligationPermissionBeliefs(Term sch, Term gr, 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);
+ giAnnot.addTerm(gr);
Literal obl = new Literal(type);
obl.addTerms(sch,new UnnamedVar());
@@ -327,7 +338,7 @@
return null;
}
- void removeAchieveGoalsOfSch(String schId) {
+ void cleanGoalsOfSch(String schId) {
Iterator<GoalInstance> i = alreadyGeneratedEvents.iterator();
while (i.hasNext()) {
GoalInstance gi = i.next();
@@ -377,7 +388,7 @@
/** add/remove bel regarding the goals' state */
void updateGoalBels() throws RevisionFailedException {
// for all missions
- // for all goals
+ // for all goals of the mission's scheme
// if not in BB, add
// if different from BB, remove/add
for (MissionPlayer mp : getMyOEAgent().getMissions()) {
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-20 21:35:50 UTC (rev 1299)
@@ -191,20 +191,20 @@
sender.adoptRole(roleId, grId);
GroupInstance gr = currentOE.findGroup(grId);
- // send schemes of this group to sender
- for (SchemeInstance sch : gr.getRespSchemes()) {
- updateMembersOE(sender, "scheme_group(" + sch.getId() + "," + grId + ")", true, true);
- }
-
// notify others in the group about this new player
updateMembersOE(gr.getAgents(true), "play(" + sender + "," + roleId + "," + grId + ")", true, true);
- // send players of this group to sender
+ // send players of the group to the sender
for (RolePlayer rp : gr.getPlayers(null, true)) {
- if (!rp.getPlayer().getId().equals(sender)) {
+ if (!rp.getPlayer().equals(sender)) {
updateMembersOE(sender, "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + grId + ")", false, true);
}
}
+
+ // send schemes of this group to sender
+ for (SchemeInstance sch : gr.getRespSchemes()) {
+ updateMembersOE(sender, "scheme_group(" + sch.getId() + "," + grId + ")", false, true);
+ }
sendReply(sender, mId, "ok");
}
}
@@ -252,7 +252,7 @@
// notify to the sender the other commitments of the scheme
for (MissionPlayer mp : sch.getPlayers()) {
- if (!mp.getPlayer().getId().equals(sender)) {
+ if (!mp.getPlayer().equals(sender)) {
updateMembersOE(sender, "commitment(" + mp.getPlayer().getId() + "," + mp.getMission().getId() + "," + sch.getId() + ")", false, true);
}
}
@@ -358,15 +358,6 @@
gr.checkRemove();
- /*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);
-
// 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);
@@ -606,22 +597,12 @@
Iterator iAgs = ags.iterator();
while (iAgs.hasNext()) {
Object next = iAgs.next();
- OEAgent ag = null;
- try {
- // check if it is a list of OEAgents
- ag = (OEAgent) next;
- } catch (ClassCastException e) {
- try {
- // check if it is a list of Players
- ag = ((Player) next).getPlayer();
- } catch (ClassCastException e2) {
- }
- }
+ if (next instanceof OEAgent) // check if it is a list of OEAgents
+ all.add((OEAgent) next);
+ else if (next instanceof Player) // check if it is a list of Players
+ all.add(((Player) next).getPlayer());
- if (ag != null) {
- all.add(ag);
- }
}
for (OEAgent ag : all) {
updateMembersOE(ag, pEnv, sendOE, tell);
@@ -633,7 +614,7 @@
try {
if (sendOE) {
Message moe = new Message("tell", null, ag.getId(), null);
- moe.setPropCont(currentOE.partialOE(ag));
+ moe.setPropCont(currentOE); //partialOE(ag)); // TODO: the clone of OE is not working!
sendMsg(moe);
}
if (pEnv != null) {
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-20 21:35:50 UTC (rev 1299)
@@ -20,42 +20,42 @@
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
"target(_,_)", "group_leader(key,_)", "cow(key,_,_)",
- "group_area(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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
- "group_area(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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
- "group_area(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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
- "group_area(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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
- "group_area(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(_,_)", "group_leader(key,_)", "cow(key,_,_)",
- "group_area(key, _, _)");
+ "group_area(key, _)");
directives: maintenance_goal = agent.OrgMaintenanceGoal;
Modified: trunk/applications/jason-team/gauchos.xml
===================================================================
--- trunk/applications/jason-team/gauchos.xml 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-team/gauchos.xml 2008-05-20 21:35:50 UTC (rev 1299)
@@ -94,7 +94,7 @@
<target name="run" depends="compile" >
<delete failonerror="no" includeEmptyDirs="true" verbose="false">
- <fileset dir="tmp-ag-mind" includes="*.xml"/>
+ <fileset dir="mind-ag-gaucho1" includes="*.xml"/>
</delete>
<echo message="Running project ${ant.project.name}" />
Modified: trunk/applications/jason-team/readme.txt
===================================================================
--- trunk/applications/jason-team/readme.txt 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-team/readme.txt 2008-05-20 21:35:50 UTC (rev 1299)
@@ -45,7 +45,8 @@
you can see the agent mind state with
ant -f gauchos.xml mind-view
-
+
+ or in the files stored in directory mind-ag-gaucho1
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/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-20 21:35:50 UTC (rev 1299)
@@ -1,26 +1,28 @@
/* -- plans for exploration phase -- */
-/* -- initial beliefs -- */
-
-/* -- initial goals -- */
-
-
/*
-- plans for new match
-- create the initial exploration groups and areas
*/
-/* plans for agents with odd id */
++gsize(_,_) // new match has started
+ <- !define_areas;
+ !create_exploration_gr.
-+gsize(_,_) // new match has started
++!define_areas
+ <- ?gsize(W,H);
+ X = math.round(((W*H)/3)/H);
+ +group_area(0, area(0, 0, X, H-1));
+ +group_area(1, area(X+1, 0, W-1, H/2));
+ +group_area(2, area(X+1, (H/2)+1, W-1, H-1)).
+
++!create_exploration_gr
: .my_name(Me) &
agent_id(Me,AgId) &
- AgId mod 2 == 1 // I have an odd Id
- <- !create_exploration_gr.
-
-+!create_exploration_gr
+ AgId mod 2 == 1 & // I have an odd Id and thus have to create a exploring group
+ not .intend(create_exploration_gr)
<- .my_name(Me);
// create the team, if necessary
@@ -28,6 +30,7 @@
jmoise.create_group(team)
};
+ // create the exploration group
if( not group(exploration_grp,_)[owner(Me)] ) {
?group(team,TeamGroup); // get the team Id
jmoise.create_group(exploration_grp,TeamGroup,G);
@@ -35,41 +38,11 @@
} {
?group(exploration_grp,G)[owner(Me)]
};
-
- .print("ooo Recruiting scouters for my explorer group ",G);
-
- ?pos(MyX,MyY,_); // wait my pos
- // wait others pos
- while( .count(ally_pos(_,_,_), N) & N < 5 ) {
- .print("ooo waiting others pos ");
- .wait("+ally_pos(_,_,_)", 500, _)
- };
-
- // find distance to even agents
- .findall(ag_d(D,AgName),
- ally_pos(AgName,X,Y) & agent_id(AgName,Id) & Id mod 2 == 0 & jia.path_length(MyX, MyY, X, Y, D),
- LOdd);
- .sort(LOdd, LSOdd);
-
- // test if I received the area of my group
- ?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);
- !find_scouter(LSOdd, G).
+ !change_role(explorer,G).
++!create_exploration_gr.
-+!find_scouter([],_)
- <- .print("ooo I did not find a scouter to work with me!").
-+!find_scouter([ag_d(_,AgName)|_],GId)
- <- .print("ooo Ask ",AgName," to play scouter");
- .send(AgName, achieve, play_role(scouter,GId));
- .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).
-
// If if start playing explorer in a group that has no scheme, create the scheme
+play(Me,explorer,G)
: .my_name(Me) &
@@ -79,38 +52,70 @@
// If I stop playing explorer, destroy the explore groups I've created
-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)
}.
-+group(exploration_grp,_) // compute the area of the groups
+/*+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 -- */
++!find_scouter[scheme(Sch),group(G)]
+ <- .print("ooo Recruiting scouters for my explorer group ",G);
+
+ // test if I received the area of my group
+ //?group_area(AreaId,G,A);
+ //.print("ooo Scouters candidates =", LSOdd," in area ",group_area(AreaId,G,A));
+
+ !find_scouter([], G);
+ jmoise.set_goal_state(Sch, find_scouter, satisfied).
+
++!find_scouter(_,G) // if someone plays scouter in my group, it is ok.
+ : play(_,scouter,G).
++!find_scouter([],G)
+ <- ?pos(MyX,MyY,_); // wait my pos
+
+ // wait others pos
+ while( .count(ally_pos(_,_,_), N) & N < 5 ) {
+ .print("ooo waiting others pos ");
+ .wait("+ally_pos(_,_,_)", 500, _)
+ };
+
+ // find distance to even agents
+ .findall(ag_d(D,AgName),
+ ally_pos(AgName,X,Y) & agent_id(AgName,Id) & Id mod 2 == 0 & jia.path_length(MyX, MyY, X, Y, D),
+ LOdd);
+ .sort(LOdd, LSOdd);
+ !find_scouter(LSOdd,G).
++!find_scouter([ag_d(_,AgName)|_],GId)
+ <- .print("ooo Ask ",AgName," to play scouter");
+ .send(AgName, achieve, play_role(scouter,GId));
+ .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).
+
+
+
{ begin maintenance_goal("+at_target") }
+!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
- ?group_area(_,GroupId, Area); // get the area of this group
+ ?agent_id(Me,MyId);
+ ?group_area(MyId div 2, Area); // get the area of my group
+
?pos(MeX, MeY, _); // get my location
jia.near_least_visited(MeX, MeY, Area, TargetX, TargetY);
-+target(TargetX, TargetY).
@@ -160,7 +165,7 @@
if( DistanceToLeader > (AGPR * 2) -3) {
.print("ooo Approaching leader.");
-+target(LX,LY)
- }{
+ } {
.print("ooo being in formation with leader.");
.send(Leader,askOne,target(_,_),target(TX,TY));
jia.scouter_pos(LX, LY, TX, TY, SX, SY);
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-20 21:35:50 UTC (rev 1299)
@@ -32,7 +32,7 @@
/* -- plans -- */
+?pos(X, Y, S) <- .wait("+pos(X,Y,S)").
-+?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
+//+?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
+?gsize(W,H) <- .wait("+gsize(W,H)").
+?group(team,G) <- .wait("+group(team,G)", 500, _); ?group(team,G).
+?ally_pos(Name,X,Y) : .my_name(Name) <- ?pos(X,Y,_).
@@ -90,7 +90,7 @@
+!change_role(NewRole,GT)[source(S)]
<- .my_name(Me);
- .print("ooo Adopting the role ",NewRole," in group ",GT,", as asked by ",S);
+ .print("ooo Changing to role ",NewRole," in group ",GT,", as asked by ",S);
// give up all missions
while( commitment(Me,M,Sch) ) {
@@ -99,7 +99,7 @@
};
// if I play herder in another group, ...
- if( play(Me,herder,G) & G \== GT) {
+ 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))
@@ -112,11 +112,13 @@
jmoise.adopt_role(NewRole,GT).
+-!change_role(R,G)
+ <- !change_role(R,G).
+!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);
+ <- .print("ooo Adopting role ",Role," in group ",Group,", as asked by ",Ag);
jmoise.adopt_role(Role, Group).
// finish the scheme if it has no more players
@@ -128,17 +130,21 @@
// when I have an obligation or permission to a mission, commit to it
+obligation(Sch, Mission)
- <- jmoise.commit_mission(Mission,Sch).
+ <- .print("ooo Obligation to commit to mission ",Mission);
+ jmoise.commit_mission(Mission,Sch).
+permission(Sch, Mission)
- <- jmoise.commit_mission(Mission,Sch).
+ <- .print("ooo Permission to commit to mission ",Mission);
+ jmoise.commit_mission(Mission,Sch).
// when I am not obligated to a mission anymore, uncommit
-obligation(Sch, Mission)
: .my_name(Me) & commitment(Me,Mission,Sch)
- <- jmoise.remove_mission(Mission,Sch).
+ <- .print("ooo I don't have obligation for the mission ",Mission," anymore, remove the commit");
+ jmoise.remove_mission(Mission,Sch).
-permission(Sch, Mission)
: .my_name(Me) & commitment(Me,Mission,Sch)
- <- jmoise.remove_mission(Mission,Sch).
+ <- .print("ooo I don't have permission for the mission ",Mission," anymore, remove the commit");
+ jmoise.remove_mission(Mission,Sch).
// when I am not committed to a mission anymore, remove all goals based on that mission
-commitment(Me,Mission,Sch)
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-20 21:35:50 UTC (rev 1299)
@@ -1,10 +1,8 @@
/* -- plans for herding phase -- */
-/* -- initial beliefs -- */
/* -- plans for herding groups creation -- */
-
+!create_herding_gr
: not .intend(create_herding_gr)
<- .print("ooo Creating herding group.");
@@ -37,15 +35,21 @@
// If I stop playing herder, destroy the herding groups I've created
-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);
.wait(4000)
}.
+
+// If I stop playing herboy (because the group was destroied by the herder),
+// I should try yo create my new exploration group
+-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 -- */
{ begin maintenance_goal("+pos(_,_,_)") }
@@ -84,8 +88,9 @@
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).
+ .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).
{ end }
@@ -145,6 +150,23 @@
*/
+{ begin maintenance_goal("+pos(_,_,_)") }
+
++!change_to_exploring[scheme(Sch),mission(Mission)]
+ : 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
+ }.
+
++!change_to_exploring[scheme(Sch),mission(Mission)].
+
+{ end }
+
+
/* -- plans for the goals of all roles (herder and herdboy) -- */
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-20 21:35:50 UTC (rev 1299)
@@ -59,7 +59,7 @@
String fileName = "world-status.txt";
File dirmind = null;
try {
- dirmind = new File("tmp-ag-mind");
+ dirmind = new File("mind-ag-"+owner.getAgName());
dirmind.mkdir();
} catch (Exception e) {
dirmind = null;
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-05-18 14:57:19 UTC (rev 1298)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-20 21:35:50 UTC (rev 1299)
@@ -71,19 +71,26 @@
<properties>
<property id="check-players-in-remove-responsible-group" value="false" />
<property id="only-owner-can-remove-scheme" value="false" />
+ <!--property id="check-goals-in-remove-mission" value="false" /-->
</properties>
<scheme id="explore_sch" >
<goal id="find_cows" >
<plan operator="parallel">
+ <goal id="init_scheme">
+ <plan operator="sequence">
+ <goal id="find_scouter" ds="find a scouter to help in the exploration" />
+ <goal id="change_to_herding" ds="verify if necessary to create the herding group" type="maintenance"/>
+ </plan>
+ </goal>
<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="find_scouter" />
<goal id="goto_near_unvisited" />
<goal id="share_seen_cows" />
<goal id="change_to_herding" />
@@ -97,10 +104,11 @@
<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"/>
+ <goal id="change_to_exploring" ds="verify if necessary to finish the herding group and create the exploring groups" type="maintenance"/>
</plan>
</goal>
@@ -109,6 +117,7 @@
<goal id="define_formation" />
<goal id="be_in_formation" />
<goal id="share_seen_cows" />
+ <goal id="change_to_exploring" />
</mission>
<mission id="help_herder" >
<goal id="be_in_formation" />
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;
+ }
+
if (F.getFunctor().indexOf(".") >= 0) {
try {
{if (true) return new InternalActionLiteral(F, curAg);}
@@ -1199,8 +1210,8 @@
finally { jj_save(0, xla); }
}
- final private boolean jj_3R_16() {
- if (jj_scan_token(27)) return true;
+ final private boolean jj_3R_15() {
+ if (jj_3R_17()) return true;
return false;
}
@@ -1212,8 +1223,8 @@
return false;
}
- final private boolean jj_3R_15() {
- if (jj_3R_17()) return true;
+ final private boolean jj_3R_16() {
+ if (jj_scan_token(27)) return true;
return false;
}
Modified: trunk/src/jason/stdlib/at.java
===================================================================
--- trunk/src/jason/stdlib/at.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/stdlib/at.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -31,7 +31,6 @@
import jason.asSemantics.Intention;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
-import jason.asSyntax.Atom;
import jason.asSyntax.StringTerm;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
@@ -72,7 +71,7 @@
*/
public class at extends DefaultInternalAction {
- public static final Atom atAtom = new Atom(".at");
+ public static final String atAtom = ".at";
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
Modified: trunk/src/jason/stdlib/suspend.java
===================================================================
--- trunk/src/jason/stdlib/suspend.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/stdlib/suspend.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -125,7 +125,6 @@
if (i.hasTrigger(g, un)) {
suspendIntention = true;
i.setSuspended(true);
- //i.peek().removeCurrentStep();
C.getPendingIntentions().put(SELF_SUSPENDED_INT, i);
}
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jason/stdlib/wait.java 2008-05-18 14:57:19 UTC (rev 1298)
@@ -30,7 +30,6 @@
import jason.asSemantics.Intention;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
-import jason.asSyntax.Atom;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
@@ -88,7 +87,7 @@
*/
public class wait extends DefaultInternalAction {
- public static final Atom waitAtom = new Atom(".wait");
+ public static final String waitAtom = ".wait";
//static Logger logger = Logger.getLogger(wait.class.getName());
@Override
Modified: trunk/src/jeditPlugin/agentSpeak.xml
===================================================================
--- trunk/src/jeditPlugin/agentSpeak.xml 2008-05-08 15:50:39 UTC (rev 1297)
+++ trunk/src/jeditPlugin/agentSpeak.xml 2008-05-18 14:57:19 UTC (rev 1298)
@@ -40,6 +40,10 @@
<END>]</END>
</SPAN>
+ <SEQ TYPE="OPERATOR">if</SEQ>
+ <SEQ TYPE="OPERATOR">while</SEQ>
+ <SEQ TYPE="OPERATOR">for</SEQ>
+
<!-- special reserved words and operators -->
<SEQ TYPE="LITERAL2">true</SEQ>
<SEQ TYPE="OPERATOR">not</SEQ>
@@ -206,6 +210,11 @@
<END>]</END>
</SPAN>
+ <SEQ TYPE="OPERATOR">if</SEQ>
+ <SEQ TYPE="OPERATOR">while</SEQ>
+ <SEQ TYPE="OPERATOR">for</SEQ>
+
+
<!-- special reserved words and operators -->
<SEQ TYPE="LITERAL2">true</SEQ>
<SEQ TYPE="OPERATOR">not</SEQ>
@@ -355,6 +364,11 @@
<END>"</END>
</SPAN>
+ <SEQ TYPE="OPERATOR">if</SEQ>
+ <SEQ TYPE="OPERATOR">while</SEQ>
+ <SEQ TYPE="OPERATOR">for</SEQ>
+
+
<!-- Reserved Terms -->
<SEQ TYPE="LITERAL2">true</SEQ>
<SEQ TYPE="LITERAL2">tell</SEQ>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-08 15:50:58
|
Revision: 1297
http://jason.svn.sourceforge.net/jason/?rev=1297&view=rev
Author: jomifred
Date: 2008-05-08 08:50:39 -0700 (Thu, 08 May 2008)
Log Message:
-----------
jason team: improve merging of teams and formation
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
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/LocalWorldModel.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
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-08 15:50:39 UTC (rev 1297)
@@ -189,7 +189,7 @@
// 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);
+ getTS().getLogger().warning("Error in organisational action '"+body+"': "+content);
} else {
// try to unify the return value
//System.out.println("answer is "+content+" or "+DefaultTerm.parse(content)+" with body "+body);
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-08 15:50:39 UTC (rev 1297)
@@ -289,18 +289,18 @@
mpi = sender.getMissions().iterator();
String evUnCom = "commitment(" + sender + "," + mp.getMission().getId() + "," + sch.getId() + ")";
updateMembersOE(sch.getPlayers(), evUnCom, false, false);
- if (!sch.isPlayer(sender)) {
+ //if (!sch.isPlayer(sender)) {
updateMembersOE(sender, evUnCom, false, false);
- }
+ //}
}
} else {
sch = currentOE.findScheme(schId);
sender.removeMission(misId, schId);
String evUnCom = "commitment(" + sender + "," + misId + "," + sch.getId() + ")";
updateMembersOE(sender, evUnCom, false, false);
- if (!sch.isPlayer(sender)) {
+ //if (!sch.isPlayer(sender)) {
updateMembersOE(sch.getPlayers(), evUnCom, false, false);
- }
+ //}
}
updateMembersOE(sender, (String) null, true, true);
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-08 15:50:39 UTC (rev 1297)
@@ -29,14 +29,6 @@
/* -- initial goals -- */
-/* Testing alloc
-alloc_target(a1,pos(10,10)).
-alloc_target(a2,pos(20,20)).
-alloc_target(a3,pos(30,30)).
-!test.
-+!test <- !alloc_all([a1,a2,a3],[pos(31,31),pos(21,21),pos(11,11)]).
-*/
-
/* -- plans -- */
+?pos(X, Y, S) <- .wait("+pos(X,Y,S)").
@@ -50,10 +42,10 @@
.drop_all_desires;
!remove_org.
-+!restart
- <- //.print("*** restart ***");
++!restart.
+ //<- //.print("*** restart ***");
//.drop_all_desires;
- .abolish(cow(_,_,_)).
+ //.abolish(cow(_,_,_)).
// TODO: what to do?
//!decide_target.
@@ -85,12 +77,6 @@
}.
+!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)
@@ -108,6 +94,7 @@
// give up all missions
.while( commitment(Me,M,Sch) ) {
+ .print("ooo removing my mission ",M," in ",Sch);
jmoise.remove_mission(M,Sch)
};
@@ -125,16 +112,20 @@
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).
-
+!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);
jmoise.adopt_role(Role, Group).
+
+// 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).
+
// when I have an obligation or permission to a mission, commit to it
+obligation(Sch, Mission)
<- jmoise.commit_mission(Mission,Sch).
@@ -143,8 +134,10 @@
// when I am not obligated to a mission anymore, uncommit
-obligation(Sch, Mission)
+ : .my_name(Me) & commitment(Me,Mission,Sch)
<- jmoise.remove_mission(Mission,Sch).
-permission(Sch, Mission)
+ : .my_name(Me) & commitment(Me,Mission,Sch)
<- jmoise.remove_mission(Mission,Sch).
// when I am not committed to a mission anymore, remove all goals based on that mission
@@ -156,10 +149,7 @@
-scheme(_Spec,Id)
<- .drop_desire(_[scheme(Id)]).
-+error(M)[source(orgManager)]
- <- .print("Error in organisational action: ",M); -error(M)[source(orgManager)].
-
/* -- includes -- */
{ include("goto.asl") } // include plans for moving around
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-08 15:50:39 UTC (rev 1297)
@@ -12,6 +12,7 @@
<- !create_herding_gr.
+!create_herding_gr
+ : not .intend(create_herding_gr)
<- .print("ooo Creating herding group.");
.my_name(Me);
@@ -66,7 +67,7 @@
play(Me, herder, Gi) &
current_cluster(MyC)
<- // for all other groups
- .for( group_leader(Gj, L) & L \== Me & Me < L) {
+ .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));
@@ -76,7 +77,8 @@
.print("ooo Merging my herding group ",Gi," with ",Gj, " lead by ",L);
.send(L, achieve, change_role(herdboy,Gi))
}
- }.
+ };
+ .wait(2000). // give some time for them to adopt the roles before check merging again
+!check_merge.
@@ -85,15 +87,37 @@
+!define_formation[scheme(Sch),mission(Mission)]
<- .print("ooo I should define the formation of my group!");
?my_group_players(G, herder);
- jia.cluster(Cluster,CAsList);
- -+current_cluster(CAsList);
- jia.herd_position(.length(G),Cluster,L);
+ 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).
+ !alloc_all(G,L).
{ end }
-+!alloc_all([],_).
+// version "near agent of each position
++!alloc_all([],[]).
++!alloc_all([],L) <- .print("ooo there is no agent for the formation ",L).
++!alloc_all(G,[]) <- .print("ooo there is no place in the formation for ",G).
++!alloc_all(Agents,[pos(X,Y)|TLoc])
+ <- !find_closest(Agents,pos(X,Y),HA);
+ .print("ooo Allocating position ",pos(X,Y)," to agent ",HA);
+ .send(HA,tell,target(X,Y));
+ .delete(HA,Agents,TAg);
+ !alloc_all(TAg,TLoc).
+
++!find_closest(Agents, pos(FX,FY), NearAg) // find the agent near to pos(X,Y)
+ <- .my_name(Me);
+ .findall(d(D,Ag),
+ .member(Ag,Agents) & (ally_pos(Ag,AgX,AgY) | Ag == Me & pos(AgX,AgY,_)) & jia.path_length(FX,FY,AgX,AgY,D),
+ Distances);
+ //.print("Distances for ",pos(FX,FY)," are ",Distances);
+ .min(Distances,d(_,NearAg)).
+
+/*
+// version "near place of the agent"
++!alloc_all([],[]).
++!alloc_all(G,[]) <- .print("ooo there is no place in the formation for ",G).
+!alloc_all([HA|TA],LA)
<- !find_closest(HA,LA,pos(X,Y),NLA);
.print("ooo Alocating position ",pos(X,Y)," to agent ",HA);
@@ -111,10 +135,10 @@
.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))
:- jia.path_length(Fx,Fy,AgX,AgY,D) & calc_distances(TP, TD, pos(AgX,AgY)).
+*/
/*
+!closest([],S,S,_,_).
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-05-08 15:50:39 UTC (rev 1297)
@@ -172,7 +172,6 @@
if (cnl.item(j).getNodeType() == Element.ELEMENT_NODE && cellx != 0 && celly != 0) {
Element type = (Element)cnl.item(j);
-
if (type.getNodeName().equals("agent")) {
if (type.getAttribute("type").equals("ally")) {
// allies are managed by communication
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-08 15:50:39 UTC (rev 1297)
@@ -124,7 +124,7 @@
public void addCow(int x, int y) {
add(WorldModel.COW, x, y);
cows.add(new Vec( this, x, y));
- increp(cowsrep, x, y, 2, 1);
+ increp(cowsrep, x, y, 3, 1);
}
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-08 15:50:39 UTC (rev 1297)
@@ -41,13 +41,13 @@
public static final int agDistanceInFormation = 4;
public enum Formation {
- one { int[] getDistances() { return new int[] { 0 }; } },
- 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();
+ one { Vec[] getDistances() { return new Vec[] { new Vec(0,0) }; } },
+ two { Vec[] getDistances() { return new Vec[] { new Vec(sd,0), new Vec(-sd, 0) }; } },
+ three { Vec[] getDistances() { return new Vec[] { new Vec(0,0), new Vec(d, -1), new Vec(-d, -1) }; } },
+ four { Vec[] getDistances() { return new Vec[] { new Vec(sd,0), new Vec(-sd, 0), new Vec(d+sd, -2), new Vec(-(d+sd), -2) }; } },
+ five { Vec[] getDistances() { return new Vec[] { new Vec(0,0), new Vec(d, -1), new Vec(-d, -1), new Vec(d*2,-3), new Vec(-d*2,-3) }; } },
+ six { Vec[] getDistances() { return new Vec[] { new Vec(sd,0), new Vec(-sd, 0), new Vec(d+sd, -2), new Vec(-(d+sd), -2), new Vec(d*2+sd, -4), new Vec(-(d*2+sd), -4) }; } };
+ abstract Vec[] getDistances();
private static final int d = agDistanceInFormation;
private static final int sd = agDistanceInFormation/2;
};
@@ -165,66 +165,54 @@
int n = Math.min(stepsFromCenter, np.size());
Vec cowstarget = new Vec(model, s.getNodeLocation(np.get(n)));
- Vec agsTarget = mean.sub(cowstarget);
+
+ // 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>();
- int initAgTS = 1;
- for (int dist: formation.getDistances()) { // 2, -2, 6, -6, ....
- Vec agTarget = agsTarget;
- //Location l = agTarget.add(mean).getLocation(model);
-
- //System.out.println("....... "+dist+" antes angle "+agTarget);
- if (dist >= 0)
- agTarget = agTarget.turn90CW();
- else
- agTarget = agTarget.turn90ACW();
-
- Location l = findFirstFreeLocTowardsTarget(agTarget, mean.add(agsTarget), initAgTS, dist, model);
+ 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);
- if (l != null) {
- l = pathToNearCow(l, clusterLocs);
- if ( !model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l) || r.contains(l))
- l = model.nearFree(l, r);
- r.add( l );
+ if (l == null) {
+ l = model.nearFree(agsTarget.add(mean).getLocation(model), r);
+ } else {
+ //l = pathToNearCow(l, clusterLocs);
+ if ( !model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l) || r.contains(l))
+ l = model.nearFree(l, r);
}
-
- /*
- 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;
+ r.add( l );
}
//System.out.println("all places "+r);
return r;
}
- public static Location findFirstFreeLocTowardsTarget(Vec target, Vec ref, int initialSize, int maxSize, LocalWorldModel model) {
+ public static Location findFirstFreeLocTowardsTarget(Vec start, Vec direction, Vec ref, LocalWorldModel model) {
+ Vec startandref = start.add(ref);
+ Vec t = start.turn90CW();
+ t = t.newAngle(t.angle()+direction.angle());
+
+ //System.out.println(start + " to "+ direction + " = " + end);
+ Location l = start.add(ref).getLocation(model);
Location lastloc = null;
- maxSize = Math.abs(maxSize);
- 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);
- if ( (!model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l)) && lastloc != null)
+ int maxSize = (int)direction.magnitude();
+ for (int s = 1; s <= maxSize; s++) {
+ l = t.newMagnitude(s).add(startandref).getLocation(model);
+ //System.out.println(" test "+s+" = "+l+" -- ");
+ if ( (!model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l) || model.hasObject(WorldModel.CORRAL, l)) && lastloc != null)
return lastloc;
lastloc = l;
}
- return l; //ref.getLocation(model); //target.add(ref).getLocation(model);
+ return l;
}
+ /*
private Location pathToNearCow(Location t, List<Location> cluster) {
Location near = null;
for (Location c: cluster) {
@@ -243,6 +231,7 @@
}
return t;
}
+ */
/*
public Location nearFreeForAg(LocalWorldModel model, Location ag, Location t) throws Exception {
Modified: trunk/applications/jason-team/src/java/jia/scouter_pos.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/scouter_pos.java 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-team/src/java/jia/scouter_pos.java 2008-05-08 15:50:39 UTC (rev 1297)
@@ -56,8 +56,8 @@
public Location getScouterTarget(LocalWorldModel model, Location leaderPos, Location leaderTarget) throws Exception {
Vec leader = new Vec(model, leaderPos);
Vec target = new Vec(model, leaderTarget).sub(leader);
- target = target.turn90CW();
- return herd_position.findFirstFreeLocTowardsTarget(target, leader, 1, WorldModel.agPerceptionRatio*2-3, model);
+ Vec me = new Vec(WorldModel.agPerceptionRatio*2-3,0);
+ return herd_position.findFirstFreeLocTowardsTarget(target, me, leader, model);
}
}
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-05-08 15:50:39 UTC (rev 1297)
@@ -1,6 +1,7 @@
package test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import jason.environment.grid.Location;
import java.util.ArrayList;
@@ -110,10 +111,10 @@
@Test
public void testCowsRepMat() throws Exception {
scenario1();
- assertEquals(2, model.getCowsRep(5,38));
- assertEquals(1, model.getCowsRep(5,37));
- assertEquals(0, model.getCowsRep(5,36));
- assertEquals(5, model.getCowsRep(5,40));
+ assertEquals(4, model.getCowsRep(5,38));
+ assertEquals(2, model.getCowsRep(5,37));
+ assertEquals(1, model.getCowsRep(5,36));
+ assertEquals(8, model.getCowsRep(5,40));
}
@Test
@@ -149,7 +150,7 @@
scenario1();
Search s = new Search(model, cowboy.getLocation(model), new Location(8,37), null, true, true, true, false, null);
Nodo path = s.search();
- assertEquals(13, s.normalPath(path).size());
+ assertEquals(15, s.normalPath(path).size());
}
@Test
@@ -176,10 +177,15 @@
Location byIA = hp.getAgTarget(clusterLocs, Formation.one, cowboy.getLocation(model));
assertEquals(new Location(6,38), byIA);
+
+ assertEquals("[6,38, 9,41, 3,37, 11,45, 0,37]", hp.formationPlaces(clusterLocs, Formation.five).toString());
byIA = hp.getAgTarget(clusterLocs, Formation.six, cowboy.getLocation(model));
- assertEquals(new Location(6,39), byIA);
-
+ 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());
+
+ /*
// add an agent in 6,39
model.add(WorldModel.AGENT, 6,39);
byIA = hp.getAgTarget(clusterLocs, Formation.six, cowboy.getLocation(model));
@@ -203,7 +209,8 @@
// add an agent in 5,37
//model.add(WorldModel.AGENT, 5,37);
//byIA = new herd_position().getAgTarget(model, Formation.six,cowboy.getLocation(model));
- //assertEquals(new Location(5,37), byIA);
+ //assertEquals(new Location(5,37), byIA);
+ */
}
@Test
@@ -222,20 +229,20 @@
assertEquals(new Location(11,49), byIA);
List<Location> form = hp.formationPlaces(clusterLocs, Formation.four);
- assertEquals("[6,48, 11,49, 6,49, 12,48]", form.toString());
+ 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(15,48)));
}
@Test
public void scouterPos() throws Exception {
scenario1();
- Location byIA = new scouter_pos().getScouterTarget(model, new Location(2,46), new Location(6,42));
- assertEquals(new Location(5,49), byIA);
+ Location byIA = new scouter_pos().getScouterTarget(model, new Location(2,46), new Location(5,44));
+ assertEquals(new Location(6,46), byIA);
- byIA = new scouter_pos().getScouterTarget(model, new Location(2,46), new Location(3,42));
- assertEquals(new Location(6,47), byIA);
-
byIA = new scouter_pos().getScouterTarget(model, new Location(9,46), new Location(9,42));
- assertEquals(new Location(22,46), byIA);
+ 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-07 21:24:45 UTC (rev 1296)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-08 15:50:39 UTC (rev 1297)
@@ -38,7 +38,7 @@
<sub-groups>
- <group-specification id="exploration_grp" min="3" max="3" >
+ <group-specification id="exploration_grp" min="0" max="3" >
<roles>
<role id="explorer" min="1" max="1"/>
<role id="scouter" min="0" max="1"/>
@@ -48,7 +48,7 @@
<group-specification id="herding_grp" min="0" max="6" >
<roles>
<role id="herder" min="1" max="1"/>
- <role id="herdboy" min="0" max="3"/>
+ <role id="herdboy" min="0" max="5"/>
</roles>
</group-specification>
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-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 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 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-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-05 18:33:57
|
Revision: 1291
http://jason.svn.sourceforge.net/jason/?rev=1291&view=rev
Author: jomifred
Date: 2008-05-05 11:33:43 -0700 (Mon, 05 May 2008)
Log Message:
-----------
jason team: use target as "unique belief"
Modified Paths:
--------------
trunk/applications/jason-team/AC-Local-Dummies.mas2j
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/readme.txt
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/goto.asl
trunk/applications/jason-team/src/asl/herding.asl
Modified: trunk/applications/jason-team/AC-Local-Dummies.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-Dummies.mas2j 2008-05-04 21:50:33 UTC (rev 1290)
+++ trunk/applications/jason-team/AC-Local-Dummies.mas2j 2008-05-05 18:33:43 UTC (rev 1291)
@@ -15,32 +15,32 @@
host="localhost", port=12300, username=botagent1, password="1"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
dummy2 dummy.asl
[host="localhost", port=12300, username=botagent2, password="2"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
dummy3 dummy.asl
[host="localhost", port=12300, username=botagent3, password="3"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
dummy4 dummy.asl
[host="localhost", port=12300, username=botagent4, password="4"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
dummy5 dummy.asl
[host="localhost", port=12300, username=botagent5, password="5"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
dummy6 dummy.asl
[host="localhost", port=12300, username=botagent6, password="6"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
aslSourcePath: "src/asl";
}
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-04 21:50:33 UTC (rev 1290)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-05 18:33:43 UTC (rev 1291)
@@ -18,32 +18,32 @@
host="localhost", port=12300, username=participant1, password="1"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
- beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
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(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
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(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
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(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
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(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
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(_,_,_,_)");
+ beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)", "target(_,_)");
directives: maintenance_goal = agent.OrgMaintenanceGoal;
Modified: trunk/applications/jason-team/readme.txt
===================================================================
--- trunk/applications/jason-team/readme.txt 2008-05-04 21:50:33 UTC (rev 1290)
+++ trunk/applications/jason-team/readme.txt 2008-05-05 18:33:43 UTC (rev 1291)
@@ -12,18 +12,18 @@
To run this team:
-1. update sources of Jason and JMoise+
+1. update sources of Jason and JMoise+
cd Jason-svn
svn update
ant plugin
-
+
2. run massim-server
cd applications/jason-team/massim-server
- ./startServer.sh
-
- or some configuration for test
- ./startServerTest.sh conf/<some conf file>.xml
-
+ ./startServer.sh
+
+ or some configuration for test
+ ./startServerTest.sh conf/<some conf file>.xml
+
3. run dummies (written in Jason)
ant -f dummies.xml
@@ -32,12 +32,8 @@
./startAgents.sh
4. run Jason team
- a. by JasonIDE
- ../../bin/jason.sh
- open an run AC-Local-JasonTeam.mas2j
- b. by Ant
- ant -f gauchos.xml
+ ant -f gauchos.xml
5. start the simulation
go to shell running startServer.sh and press ENTER
@@ -45,13 +41,13 @@
6. you can get the agents location with the command
tail -f world-status.txt
-
- you can see the agent mind state with
-
- ant -f gauchos.xml mind-view
-
-7. to enable/disable the graphical view of some agent, add gui=yes
+ you can see the agent mind state with
+
+ ant -f gauchos.xml mind-view
+
+
+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/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-04 21:50:33 UTC (rev 1290)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-05 18:33:43 UTC (rev 1291)
@@ -64,10 +64,10 @@
// simple implementation of share_cows (see TODO above)
+cow(Id,X,Y)[source(percept)]
- : .desire(share_seen_cows) & .my_name(Me) & play(Me,_,Gr)
+ : .intend(share_seen_cows) & .my_name(Me) & play(Me,_,Gr)
<- jmoise.broadcast(Gr, tell, cow(Id,X,Y)).
-cow(Id,X,Y)[source(percept)]
- : .desire(share_seen_cows) & .my_name(Me) & play(Me,_,Gr)
+ : .intend(share_seen_cows) & .my_name(Me) & play(Me,_,Gr)
<- jmoise.broadcast(Gr, untell, cow(Id,X,Y)).
Modified: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl 2008-05-04 21:50:33 UTC (rev 1290)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-05-05 18:33:43 UTC (rev 1291)
@@ -24,8 +24,8 @@
-at_target;
!!move.
--target(_,_) // if I receive a message untell for my target, remove all target from BB
- <- .abolish(target(_,_)).
+//-target(_,_) // if I receive a message untell for my target, remove all target from BB
+// <- .abolish(target(_,_)).
// 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-04 21:50:33 UTC (rev 1290)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-05 18:33:43 UTC (rev 1291)
@@ -87,7 +87,7 @@
+!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,untell,target(_,_));
.send(HA,tell,target(X,Y));
//-+alloc_target(HA,Alloc);
!alloc_all(TA,NLA).
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-04 21:17:08
|
Revision: 1289
http://jason.svn.sourceforge.net/jason/?rev=1289&view=rev
Author: jomifred
Date: 2008-05-04 14:17:05 -0700 (Sun, 04 May 2008)
Log Message:
-----------
fix xsl for agent mind
Modified Paths:
--------------
trunk/src/xml/agInspection.xsl
Modified: trunk/src/xml/agInspection.xsl
===================================================================
--- trunk/src/xml/agInspection.xsl 2008-05-04 12:59:55 UTC (rev 1288)
+++ trunk/src/xml/agInspection.xsl 2008-05-04 21:17:05 UTC (rev 1289)
@@ -508,7 +508,7 @@
<xsl:template match="rule">
<xsl:apply-templates select="head"/>
- <xsl:text><font color="black"><b> :- </b></font></xsl:text>
+ <font color="black"><b><xsl:text> :- </xsl:text></b></font>
<table>
<tr>
<td width="20" />
@@ -519,7 +519,7 @@
<xsl:template match="literal">
<xsl:if test="@negated = 'true'">
- <xsl:text><b>~</b></xsl:text>
+ <b><xsl:text>~</xsl:text></b>
</xsl:if>
<xsl:apply-templates />
</xsl:template>
@@ -567,7 +567,7 @@
<xsl:template match="list-term">
<xsl:text>[</xsl:text>
<xsl:for-each select="*">
- <xsl:text><xsl:value-of select="@sep"/></xsl:text>
+ <xsl:value-of select="@sep"/>
<xsl:apply-templates select="." />
</xsl:for-each>
<xsl:text>]</xsl:text>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-04 12:59:57
|
Revision: 1288
http://jason.svn.sourceforge.net/jason/?rev=1288&view=rev
Author: jomifred
Date: 2008-05-04 05:59:55 -0700 (Sun, 04 May 2008)
Log Message:
-----------
update ant script for contest.xml
Modified Paths:
--------------
trunk/applications/jason-team/contest.xml
Modified: trunk/applications/jason-team/contest.xml
===================================================================
--- trunk/applications/jason-team/contest.xml 2008-05-04 08:55:03 UTC (rev 1287)
+++ trunk/applications/jason-team/contest.xml 2008-05-04 12:59:55 UTC (rev 1288)
@@ -1,67 +1,68 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-
-<!--
-
- This file was generated by Jason 1.1
- http://jason.sf.net
-
- April 10, 2008 - 23:19:55
--->
-
-<project name ="jason_team"
- basedir="."
- default="run">
-
- <property name="mas2j.project.file" value="AC-jason-official.mas2j"/>
- <property name="debug" value=""/> <!-- use "-debug" to run in debug mode -->
- <property name="build.dir" value="${basedir}/bin/classes" />
-
- <property name="jasonJar" value="../../lib/jason.jar"/>
-
- <path id="project.classpath">
- <pathelement location="${basedir}"/>
- <pathelement location="${build.dir}"/>
- <pathelement location="${jasonJar}"/>
- <fileset dir="${basedir}/lib" > <include name="*.jar" /> </fileset>
- </path>
-
- <!-- tasks the user can override in his/her c-build.xml script -->
- <target name="user-init">
- <copy file="../jason-moise/lib/jmoise.jar" todir="lib" />
- <copy file="../jason-moise/lib/moise.jar" todir="lib" />
- <ant antfile="../jason-moise/build.xml" target="jar" inheritall="false" />
- </target>
- <target name="user-end">
- </target>
-
- <target name="init">
- <mkdir dir="${build.dir}" />
- <antcall target="user-init" />
- </target>
-
- <target name="compile" depends="init">
- <condition property="srcdir" value="${basedir}/src/java" else="${basedir}" >
- <available file="${basedir}/src/java" />
- </condition>
- <javac srcdir="${srcdir}" destdir="${build.dir}" debug="true" optimize="true" >
- <classpath refid="project.classpath"/>
- </javac>
- </target>
-
- <target name="run" depends="compile" >
- <echo message="Running project ${ant.project.name}" />
- <java classname="jason.infra.centralised.RunCentralisedMAS"
- failonerror="true" fork="yes" dir="${basedir}" >
- <classpath refid="project.classpath"/>
- <arg line="${mas2j.project.file} ${debug} "/>
- <jvmarg line="-Xmx750M"/>
- </java>
- <antcall target="user-end" />
- </target>
-
- <target name="clean" >
- <delete failonerror="no" includeEmptyDirs="true" verbose="true">
- <fileset dir="${basedir}" includes="**/*.class"/>
- </delete>
- </target>
-</project>
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<!--
+
+ This file was generated by Jason 1.1
+ http://jason.sf.net
+
+ April 10, 2008 - 23:19:55
+-->
+
+<project name ="jason_team"
+ basedir="."
+ default="run">
+
+ <property name="mas2j.project.file" value="AC-jason-official.mas2j"/>
+ <property name="debug" value=""/> <!-- use "-debug" to run in debug mode -->
+ <property name="build.dir" value="${basedir}/bin/classes" />
+
+ <property name="jasonJar" value="../../lib/jason.jar"/>
+
+ <path id="project.classpath">
+ <pathelement location="${basedir}"/>
+ <pathelement location="${build.dir}"/>
+ <pathelement location="${jasonJar}"/>
+ <fileset dir="${basedir}/lib" > <include name="*.jar" /> </fileset>
+ </path>
+
+ <!-- tasks the user can override in his/her c-build.xml script -->
+ <target name="user-init">
+ <ant antfile="../jason-moise/build.xml" target="jar" inheritall="false" />
+ <copy file="../jason-moise/lib/jmoise.jar" todir="lib" />
+ <copy file="../jason-moise/lib/moise.jar" todir="lib" />
+ <mkdir dir="tmp-ag-mind" />
+ </target>
+ <target name="user-end">
+ </target>
+
+ <target name="init">
+ <mkdir dir="${build.dir}" />
+ <antcall target="user-init" />
+ </target>
+
+ <target name="compile" depends="init">
+ <condition property="srcdir" value="${basedir}/src/java" else="${basedir}" >
+ <available file="${basedir}/src/java" />
+ </condition>
+ <javac srcdir="${srcdir}" destdir="${build.dir}" debug="true" optimize="true" >
+ <classpath refid="project.classpath"/>
+ </javac>
+ </target>
+
+ <target name="run" depends="compile" >
+ <echo message="Running project ${ant.project.name}" />
+ <java classname="jason.infra.centralised.RunCentralisedMAS"
+ failonerror="true" fork="yes" dir="${basedir}" >
+ <classpath refid="project.classpath"/>
+ <arg line="${mas2j.project.file} ${debug} "/>
+ <jvmarg line="-Xmx750M"/>
+ </java>
+ <antcall target="user-end" />
+ </target>
+
+ <target name="clean" >
+ <delete failonerror="no" includeEmptyDirs="true" verbose="true">
+ <fileset dir="${basedir}" includes="**/*.class"/>
+ </delete>
+ </target>
+</project>
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-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-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/asSyntax/patterns/goal/EBDG.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -73,7 +73,7 @@
return newAg;
} catch (Exception e) {
- logger.log(Level.SEVERE,"Directive DG error.", e);
+ logger.log(Level.SEVERE,"Directive EBDG error.", e);
}
return null;
}
Modified: trunk/src/jason/stdlib/delete.java
===================================================================
--- trunk/src/jason/stdlib/delete.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/stdlib/delete.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -41,7 +41,7 @@
<p>Description: delete elements of strings or lists.
<p>Parameters:<ul>
- <li>+ arg[0] (term, string, or number): if term, this arg is the element to be removed in the list (all ocurrences of the element will be removed);
+ <li>+ arg[0] (term, string, or number): if term, this arg is the element to be removed in the list (all occurrences of the element will be removed);
if string, this arg is the substring to be removed (the second arg should be a string);
if number, this arg is the position in the list/string of the element/character to be removed.<br/>
<li>+ arg[1] (list or string): the list/string where to delete.
@@ -94,7 +94,7 @@
// first element as term
if (args[1].isList()) {
- return un.unifies(args[2], deleteFromList(args[0],(ListTerm)args[1]));
+ return un.unifies(args[2], deleteFromList(args[0],(ListTerm)args[1], un.copy()));
}
throw new JasonException("Incorrect use of the internal action '.delete' (see documentation).");
} catch (ArrayIndexOutOfBoundsException e) {
@@ -104,11 +104,15 @@
}
}
- ListTerm deleteFromList(Term element, ListTerm l) {
+ ListTerm deleteFromList(Term element, ListTerm l, Unifier un) {
+ Unifier bak = un;
ListTerm r = new ListTermImpl();
ListTerm last = r;
for (Term t: l) {
- if (!t.equals(element))
+ boolean u = un.unifies(element, t);
+ if (u)
+ un = bak.copy();
+ else
last = last.append(t);
}
return r;
Modified: trunk/src/jason/stdlib/drop_desire.java
===================================================================
--- trunk/src/jason/stdlib/drop_desire.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/stdlib/drop_desire.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -88,7 +88,7 @@
Trigger te = new Trigger(TEOperator.add, TEType.achieve, l);
Iterator<Event> ie = C.getEvents().iterator();
while (ie.hasNext()) {
- Event ei = ie.next();
+ Event ei = ie.next();
Trigger t = ei.getTrigger();
if (ei.getIntention() != Intention.EmptyInt) {
t = (Trigger) t.clone();
Modified: trunk/src/jason/stdlib/package.html
===================================================================
--- trunk/src/jason/stdlib/package.html 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/stdlib/package.html 2008-05-03 14:16:12 UTC (rev 1285)
@@ -23,6 +23,8 @@
<li>{@link jason.stdlib.succeed_goal}: abort some goal with success.</li>
<li>{@link jason.stdlib.fail_goal}: abort some goal with failure.</li>
+ <li>{@link jason.stdlib.suspend}: suspend intentions.</li>
+ <li>{@link jason.stdlib.resume}: resume suspended intentions.</li>
</ul>
<h2>Belief base</h2>
@@ -57,6 +59,7 @@
<li>{@link jason.stdlib.length}: size of lists. </li>
<li>{@link jason.stdlib.concat}: concat lists. </li>
+ <li>{@link jason.stdlib.delete}: delete members of a lists. </li>
<li>{@link jason.stdlib.difference}: difference of sets. </li>
<li>{@link jason.stdlib.intersection}: intersection of sets. </li>
@@ -75,6 +78,7 @@
<ul>
<li>{@link jason.stdlib.length}: size of strings. </li>
<li>{@link jason.stdlib.concat}: append strings. </li>
+ <li>{@link jason.stdlib.delete}: delete characters of a string. </li>
<li>{@link jason.stdlib.reverse}: reverse strings. </li>
<li>{@link jason.stdlib.substring}: test substrings of strings. </li>
<li>{@link jason.stdlib.string}: check whether an argument is a string.</li>
Modified: trunk/src/jason/stdlib/resume.java
===================================================================
--- trunk/src/jason/stdlib/resume.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/stdlib/resume.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -78,6 +78,11 @@
if (i.hasTrigger(g, un)) {
i.setSuspended(false);
ik.remove();
+
+ // remove the IA .suspend in case of self-suspend
+ if (k.equals(suspend.SELF_SUSPENDED_INT)) {
+ i.peek().removeCurrentStep();
+ }
// add it back in I if not in PA
if (! C.getPendingActions().containsKey(i.getId())) {
Modified: trunk/src/jason/stdlib/suspend.java
===================================================================
--- trunk/src/jason/stdlib/suspend.java 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/jason/stdlib/suspend.java 2008-05-03 14:16:12 UTC (rev 1285)
@@ -47,9 +47,10 @@
is a goal if there is a triggering event <code>+!G</code> in any plan within
any intention in I, E, PI, or PA.
- <p>Example:<ul>
+ <p>Examples:<ul>
<li> <code>.suspend(go(1,3))</code>: suspends intentions to go to the location 1,3.
+ <li> <code>.suspend</code>: suspends the current intention.
</ul>
@@ -69,17 +70,32 @@
public class suspend extends DefaultInternalAction {
boolean suspendIntention = false;
- public static final String SUSPENDED_INT = "suspended-";
+ public static final String SUSPENDED_INT = "suspended-";
+ public static final String SELF_SUSPENDED_INT = SUSPENDED_INT+"self";
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
+ suspendIntention = false;
+
+ Circumstance C = ts.getC();
+
+ if (args.length == 0) {
+ // suspend the current intention
+ Intention i = C.getSelectedIntention();
+ suspendIntention = true;
+ i.setSuspended(true);
+ //i.peek().removeCurrentStep();
+ C.getPendingIntentions().put(SELF_SUSPENDED_INT, i); //
+
+ return true;
+ }
+
+ // use the argument to select the intention to suspend.
+
Trigger g = new Trigger(TEOperator.add, TEType.achieve, (Literal)args[0]);
- Circumstance C = ts.getC();
String k = SUSPENDED_INT+g.getLiteral();
- suspendIntention = false;
-
// ** Must test in PA/PI first since some actions (as .suspend) put intention in PI
// suspending from Pending Actions
@@ -106,16 +122,16 @@
}
}
- // dropping the current intention?
+ // suspending the current intention?
Intention i = C.getSelectedIntention();
if (i.hasTrigger(g, un)) {
suspendIntention = true;
i.setSuspended(true);
- i.peek().removeCurrentStep();
- C.getPendingIntentions().put(k, i);
+ //i.peek().removeCurrentStep();
+ C.getPendingIntentions().put(SELF_SUSPENDED_INT, i);
}
- // dropping G in Events
+ // suspending G in Events
for (Event e: C.getEvents()) {
i = e.getIntention();
if ( i != null &&
@@ -132,7 +148,7 @@
return true;
} catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'suspend' has not received one argument.");
+ throw new JasonException("The internal action 'suspend' has not received one argument.", e);
} catch (Exception e) {
throw new JasonException("Error in internal action 'suspend': " + e, e);
}
Modified: trunk/src/xml/agInspection.xsl
===================================================================
--- trunk/src/xml/agInspection.xsl 2008-05-02 11:55:00 UTC (rev 1284)
+++ trunk/src/xml/agInspection.xsl 2008-05-03 14:16:12 UTC (rev 1285)
@@ -269,17 +269,21 @@
<xsl:template match="intended-means">
<tr>
<td valign="top" style="{$td-style}">
+ <xsl:apply-templates select="@trigger"/>
<xsl:if test="$show-int-details='true'">
+ <!-- td valign="top" style="{$td-style}" -->
+ <br/>
<xsl:apply-templates select="plan"/>
+ <!-- /td -->
</xsl:if>
- <xsl:if test="$show-int-details='false'">
- <xsl:apply-templates select="plan/trigger"/>
+ </td>
+
+ <xsl:if test="$show-int-details='true'">
+ <td valign="top" style="{$td-style}">
+ <xsl:text> </xsl:text><xsl:text> </xsl:text>
+ <xsl:apply-templates select="unifier"/>
+ </td>
</xsl:if>
- </td>
- <td valign="top" style="{$td-style}">
- <xsl:text> </xsl:text><xsl:text> </xsl:text>
- <xsl:apply-templates select="unifier"/>
- </td>
</tr>
</xsl:template>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-02 11:55:05
|
Revision: 1284
http://jason.svn.sourceforge.net/jason/?rev=1284&view=rev
Author: jomifred
Date: 2008-05-02 04:55:00 -0700 (Fri, 02 May 2008)
Log Message:
-----------
the third arg of .wait returns the elapse time
Modified Paths:
--------------
trunk/src/jason/stdlib/wait.java
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-05-02 08:43:47 UTC (rev 1283)
+++ trunk/src/jason/stdlib/wait.java 2008-05-02 11:55:00 UTC (rev 1284)
@@ -33,6 +33,7 @@
import jason.asSyntax.Atom;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.NumberTerm;
+import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.PlanBody;
import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.StringTerm;
@@ -74,11 +75,13 @@
first. In case the event does not happens in two seconds, the internal action
fails.
- <li> <code>.wait("+!g", 2000, nofail)</code>: suspend the intention until the goal
+ <li> <code>.wait("+!g", 2000, EventTime)</code>: suspend the intention until the goal
<code>g</code> is triggered or 2 seconds have passed, whatever happens
- first. In case the event does not happens in two seconds, the internal action does not
- fail.
- </ul>
+ first.
+ Hence this use of .wait has three arguments, in case the event does not happen in
+ two seconds, the internal action does not fail (as in the previous example).
+ The third argument will be unified to the
+ elapsed time (in miliseconds) from the start of .wait until the event or timeout. </ul>
@see jason.stdlib.at
@@ -98,7 +101,7 @@
long timeout = -1;
Trigger te = null;
- boolean failontimeout = true;
+ Term elapseTime = null;
try {
if (args[0].isNumeric()) {
// time in milliseconds
@@ -111,18 +114,16 @@
st.apply(un);
te = Trigger.parseTrigger(st.getString());
- if (args.length == 2) {
+ if (args.length >= 2)
timeout = (long) ((NumberTerm) args[1]).solve();
- if (args.length == 3 && args[2].toString().equals("nofail"))
- failontimeout = false;
- }
-
+ if (args.length == 3)
+ elapseTime = args[2];
}
} catch (Exception e) {
ts.getLogger().log(Level.SEVERE, "Error at .wait.", e);
return false;
}
- WaitEvent wet = new WaitEvent(te, un, ts, timeout, failontimeout);
+ WaitEvent wet = new WaitEvent(te, un, ts, timeout, elapseTime);
wet.start();
return true;
}
@@ -151,10 +152,11 @@
boolean ok = false;
boolean drop = false;
boolean stopByTimeout = false;
- boolean failontimeout;
+ Term elapseTimeTerm;
long timeout = -1;
+ long elapseTime;
- WaitEvent(Trigger te, Unifier un, TransitionSystem ts, long to, boolean failontimeout) {
+ WaitEvent(Trigger te, Unifier un, TransitionSystem ts, long to, Term elapseTimeTerm) {
super("wait "+te);
this.te = te;
this.un = un;
@@ -162,7 +164,7 @@
c = ts.getC();
si = c.getSelectedIntention();
this.timeout = to;
- this.failontimeout = failontimeout;
+ this.elapseTimeTerm = elapseTimeTerm;
// register listener
c.addEventListener(this);
@@ -188,12 +190,14 @@
// add SI again in C.I if it was not removed and this
// wait was not dropped
if (c.getPendingIntentions().remove(sTE) == si && !c.getIntentions().contains(si) && !drop) {
- if (stopByTimeout && te != null && failontimeout) {
+ if (stopByTimeout && te != null && elapseTimeTerm == null) {
// fail the .wait
PlanBody body = si.peek().getPlan().getBody();
body.add(1, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
}
si.peek().removeCurrentStep();
+ if (elapseTimeTerm != null)
+ si.peek().getUnif().unifies(elapseTimeTerm, new NumberTermImpl(elapseTime));
if (si.isSuspended()) { // if the intention was suspended by .suspend
String k = suspend.SUSPENDED_INT+si.getId();
c.getPendingIntentions().put(k, si);
@@ -211,18 +215,18 @@
synchronized public void waitEvent() {
long init = System.currentTimeMillis();
- long pass = 0;
+ elapseTime = 0;
while (!ok && !drop) {
try {
if (timeout == -1) {
wait();
} else {
- long to = timeout - pass;
+ long to = timeout - elapseTime;
if (to <= 0)
to = 100;
wait(to);
- pass = System.currentTimeMillis() - init;
- if (pass >= timeout) {
+ elapseTime = System.currentTimeMillis() - init;
+ if (elapseTime >= timeout) {
stopByTimeout = true;
break;
}
@@ -233,6 +237,7 @@
e.printStackTrace();
}
}
+ //elapseTime = System.currentTimeMillis() - init;
}
synchronized public void eventAdded(Event e) {
@@ -250,12 +255,10 @@
}
}
- public void intentionAdded(Intention i) {
- }
+ public void intentionAdded(Intention i) { }
public String toString() {
return sTE;
}
-
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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-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 != null) {
- Literal p = (Literal)m.getPropCont();
+ im.remove();
+
+ Literal p = (Literal)m.getPropCont();
int x = (int)((NumberTerm)p.getTerm(0)).solve();
int y = (int)((NumberTerm)p.getTerm(1)).solve();
if (model.inGrid(x,y)) {
model.add(WorldModel.OBSTACLE, x, y);
if (acView != null) acView.addObject(WorldModel.OBSTACLE, x, y);
}
- im.remove();
//getTS().getAg().getLogger().info("received obs="+p);
} else if (ms.startsWith("my_status") && model != null) {
- // update others location
+ im.remove();
+
+ // update others location
Literal p = Literal.parseLiteral(m.getPropCont().toString());
int x = (int)((NumberTerm)p.getTerm(0)).solve();
int y = (int)((NumberTerm)p.getTerm(1)).solve();
@@ -370,13 +356,12 @@
e.printStackTrace();
}
}
- im.remove();
}
}
- }
- } catch (Exception e) {
- logger.log(Level.SEVERE, "Error checking email!",e);
- }
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Error checking email!",e);
+ }
+ }
}
public static int getAgId(String agName) {
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -111,7 +111,7 @@
} catch (InterruptedException e) { // no problem, quit the thread
return;
} catch (Exception e) {
- e.printStackTrace();
+ System.out.println("error getting agent status "+e);
}
}
} catch (Exception e) {
Modified: trunk/applications/jason-team/src/java/jia/Search.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Search.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/jia/Search.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -62,13 +62,13 @@
this.considerCowsAsObstacles = considerCowsAsObstacles;
this.considerRepulsionForCows = considerRepulsionForCows;
this.agArch = agArch;
- if (actions != null) {
+ if (actions != null)
this.actionsOrder = actions;
- } else {
+ else
this.actionsOrder = defaultActions;
- }
this.maxDistFromCluster = 4;
+ this.nbStates = 0;
model.getCows(); // to update the cows in model.
}
@@ -76,7 +76,7 @@
maxDistFromCluster = m;
}
- /** used normally to discover the distance from 'from' to 'to' */
+ /** used normally to discover the distance from 'from' to 'to' (or if there is path to) */
Search(LocalWorldModel m, Location from, Location to, AgArch agArch) {
this(m,from,to,null,false, false, false, false, agArch);
}
@@ -203,7 +203,7 @@
public List<Estado> sucessores() {
List<Estado> s = new ArrayList<Estado>();
- if (ia.nbStates > 50000) {
+ if (ia.nbStates > 100000) {
ia.logger.info("*** It seems I am in a loop!");
return s;
} else if (ia.agArch != null && !ia.agArch.isRunning()) {
Modified: trunk/applications/jason-team/src/java/jia/direction.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/direction.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/jia/direction.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -61,13 +61,31 @@
actionsOrder[i2] = actionsOrder[i1];
actionsOrder[i1] = temp;
- Search astar = new Search(model, from, to, actionsOrder, true, true, true, false, ts.getUserAgArch());
+ Search astar = new Search(model, from, to, actionsOrder, true, false, true, false, ts.getUserAgArch());
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
+ int fixtimes = 0;
+ while (s.search() == null && ts.getUserAgArch().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);
+ to = model.nearFree(to);
+ s = new Search(model, from, to, ts.getUserAgArch());
+ }
+
+ // run A* again
+ astar = new Search(model, from, to, actionsOrder, true, false, true, false, ts.getUserAgArch());
+ solution = astar.search();
+ }
+
if (solution != null) {
- WorldModel.Move m = astar.firstAction(solution);
- if (m != null) {
+ WorldModel.Move m = astar.firstAction(solution);
+ if (m != null)
sAction = m.toString();
- }
} else {
ts.getLogger().info("No route from "+from+" to "+to+"!"+"\n"+model);
}
Modified: trunk/applications/jason-team/src/java/jia/near_least_visited.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/near_least_visited.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/jia/near_least_visited.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -11,6 +11,8 @@
import java.util.logging.Level;
+import env.WorldModel;
+
import arch.CowboyArch;
import arch.LocalWorldModel;
@@ -46,14 +48,27 @@
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;
+ if (n != null) {
+ Search s = new Search(model, ag, n, ts.getUserAgArch());
+ while (s.search() == null && ts.getUserAgArch().isRunning()) {
+ // if search is null, it is impossible in the scenario to goto n, set it as obstacle
+ ts.getLogger().info("[near least unvisited] No possible path to "+n+" setting as obstacle.");
+ model.add(WorldModel.OBSTACLE, n);
+ n = model.getNearLeastVisited(ag, tr, bl);
+ s = new Search(model, ag, n, ts.getUserAgArch());
+ }
+
+ 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/MindView.java
===================================================================
--- trunk/applications/jason-team/src/java/test/MindView.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/test/MindView.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -31,15 +31,19 @@
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.File;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.JSlider;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -67,35 +71,11 @@
// Interface components
JTextPane jTA = null;
JFrame frame;
+ JSlider jHistory = null;
void initComponents() {
frame = new JFrame();
- JButton jBtNext = new JButton("Next");
- jBtNext.setEnabled(true);
- jBtNext.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- step++;
- show();
- }
- });
- }
- });
- JButton jBtPrev = new JButton("Previous");
- jBtPrev.setEnabled(true);
- jBtPrev.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- step--;
- show();
- }
- });
- }
- });
-
jTA = new JTextPane();
jTA.setEditable(false);
jTA.setContentType("text/html");
@@ -110,11 +90,55 @@
pAg.add(BorderLayout.CENTER, spTA);
- JPanel pButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ JButton jBtNext = new JButton("Next");
+ jBtNext.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ step++;
+ show();
+ }
+ });
+ }
+ });
+ JButton jBtPrev = new JButton("Previous");
+ jBtPrev.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ step--;
+ show();
+ }
+ });
+ }
+ });
+ JPanel pButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
pButtons.add(jBtPrev);
pButtons.add(jBtNext);
- frame.getContentPane().add(BorderLayout.SOUTH, pButtons);
+
+ JPanel pHistory = new JPanel(new BorderLayout());//new FlowLayout(FlowLayout.CENTER));
+ pHistory.setBorder(BorderFactory.createTitledBorder(BorderFactory
+ .createEtchedBorder(), "Agent History", TitledBorder.LEFT, TitledBorder.TOP));
+ jHistory = new JSlider();
+ jHistory.setMaximum(1);
+ jHistory.setMinimum(0);
+ jHistory.setValue(0);
+ jHistory.setPaintTicks(true);
+ jHistory.setPaintLabels(true);
+ jHistory.setMajorTickSpacing(10);
+ jHistory.setMinorTickSpacing(1);
+ setupSlider();
+ jHistory.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ step = (int)jHistory.getValue();
+ show();
+ }
+ });
+ pHistory.add(BorderLayout.CENTER, jHistory);
+ pHistory.add(BorderLayout.EAST, pButtons);
+
+ frame.getContentPane().add(BorderLayout.SOUTH, pHistory);
frame.getContentPane().add(BorderLayout.CENTER, pAg);
frame.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
@@ -129,8 +153,36 @@
frame.setTitle(":: Jason Mind Inspector :: "+step+" ::");
Document agState = builder.parse("tmp-ag-mind/"+step+".xml");
jTA.setText(agTransformerHtml.transform(agState));
+ jHistory.setValue(step);
} catch (Exception et) {
et.printStackTrace();
}
}
+
+ @SuppressWarnings("unchecked")
+ private void setupSlider() {
+ 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 (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 );
+ jHistory.setMaximum(size);
+ jHistory.setValue(0);
+ }
}
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-01 21:29:36 UTC (rev 1282)
@@ -65,6 +65,11 @@
<functional-specification>
+ <properties>
+ <property id="check-players-in-remove-responsible-group" value="false" />
+ <property id="only-owner-can-remove-scheme" value="false" />
+ </properties>
+
<scheme id="explore_sch" >
<goal id="find_cows" >
<plan operator="parallel">
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/release-notes.txt 2008-05-01 21:29:36 UTC (rev 1282)
@@ -1,4 +1,15 @@
-------------
+version 1.1.2
+-------------
+
+New features
+. internal actions to control execution: .if, .while and .for
+
+Bugs fixed:
+. BUF add annotation "source(percept)" in the perception deletion event
+
+
+-------------
version 1.1.1
-------------
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSemantics/Agent.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -479,6 +479,7 @@
l = (Literal)l.clone();
l.clearAnnots();
l.addAnnot(BeliefBase.TPercept);
+ te.setLiteral(l);
ts.getC().addEvent(new Event(te, Intention.EmptyInt));
}
Modified: trunk/src/jason/asSemantics/Circumstance.java
===================================================================
--- trunk/src/jason/asSemantics/Circumstance.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSemantics/Circumstance.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -487,8 +487,10 @@
if (getPendingActions().values().contains(getAction())) {
e.setAttribute("pending", "true");
}
- if (getFeedbackActions().contains(getAction())) {
- e.setAttribute("feedback", "true");
+ synchronized (getFeedbackActions()) {
+ if (getFeedbackActions().contains(getAction())) {
+ e.setAttribute("feedback", "true");
+ }
}
acts.appendChild(e);
}
Modified: trunk/src/jason/asSyntax/UnnamedVar.java
===================================================================
--- trunk/src/jason/asSyntax/UnnamedVar.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSyntax/UnnamedVar.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -46,7 +46,10 @@
if (hasValue()) {
return getValue().clone();
} else {
- return new UnnamedVar(getFunctor());
+ UnnamedVar newv = new UnnamedVar(getFunctor());
+ if (hasAnnot())
+ newv.addAnnots((ListTerm)this.getAnnots().clone());
+ return newv;
}
}
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-05-01 21:29:36 UTC (rev 1282)
@@ -446,16 +446,17 @@
/* List of terms */
-List terms() : { List listTerms = new ArrayList(); Term v; }
+List terms() : { List listTerms = new ArrayList(); Term v; Object o; }
{
v=term() { listTerms.add(v); }
( "," v=term() { listTerms.add(v); }
+ | o=plan_body_term() { listTerms.add(o); }
)*
{ return listTerms; }
}
-Term term() : { Object o;}
+Term term() : { Object o; }
{
( o=list()
| o=plan_body_term()
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -623,12 +623,13 @@
/* List of terms */
final public List terms() throws ParseException {
- List listTerms = new ArrayList(); Term v;
+ List listTerms = new ArrayList(); Term v; Object o;
v = term();
listTerms.add(v);
label_9:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 27:
case 41:
;
break;
@@ -636,9 +637,21 @@
jj_la1[26] = jj_gen;
break label_9;
}
- jj_consume_token(41);
- v = term();
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 41:
+ 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");
@@ -669,7 +682,7 @@
o = log_expr();
break;
default:
- jj_la1[27] = jj_gen;
+ jj_la1[28] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -703,7 +716,7 @@
;
break;
default:
- jj_la1[28] = jj_gen;
+ jj_la1[29] = jj_gen;
break label_10;
}
jj_consume_token(41);
@@ -727,18 +740,18 @@
last = last.concat((ListTerm)f);
break;
default:
- jj_la1[29] = jj_gen;
+ jj_la1[30] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
- jj_la1[30] = jj_gen;
+ jj_la1[31] = jj_gen;
;
}
break;
default:
- jj_la1[31] = jj_gen;
+ jj_la1[32] = jj_gen;
;
}
jj_consume_token(44);
@@ -770,7 +783,7 @@
o = string();
break;
default:
- jj_la1[32] = jj_gen;
+ jj_la1[33] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -789,7 +802,7 @@
{if (true) return new LogExpr((LogicalFormula)t1,LogicalOp.or,(LogicalFormula)t2);}
break;
default:
- jj_la1[33] = jj_gen;
+ jj_la1[34] = jj_gen;
;
}
{if (true) return t1;}
@@ -806,7 +819,7 @@
{if (true) return new LogExpr((LogicalFormula)t1,LogicalOp.and,(LogicalFormula)t2);}
break;
default:
- jj_la1[34] = jj_gen;
+ jj_la1[35] = jj_gen;
;
}
{if (true) return t1;}
@@ -837,7 +850,7 @@
{if (true) return t;}
break;
default:
- jj_la1[35] = jj_gen;
+ jj_la1[36] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -873,7 +886,7 @@
op1 = string();
break;
default:
- jj_la1[36] = jj_gen;
+ jj_la1[37] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -920,7 +933,7 @@
operator = RelationalOp.literalBuilder;
break;
default:
- jj_la1[37] = jj_gen;
+ jj_la1[38] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -948,7 +961,7 @@
op2 = plan_body_term();
break;
default:
- jj_la1[38] = jj_gen;
+ jj_la1[39] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -959,7 +972,7 @@
{if (true) return new RelExpr((Term)op1, operator, (Term)op2);}
break;
default:
- jj_la1[39] = jj_gen;
+ jj_la1[40] = jj_gen;
;
}
{if (true) return op1;}
@@ -984,7 +997,7 @@
op = ArithmeticOp.minus;
break;
default:
- jj_la1[40] = jj_gen;
+ jj_la1[41] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -998,7 +1011,7 @@
{if (true) return new ArithExpr((NumberTerm)t1, op, (NumberTerm)t2);}
break;
default:
- jj_la1[41] = jj_gen;
+ jj_la1[42] = jj_gen;
;
}
{if (true) return t1;}
@@ -1032,7 +1045,7 @@
op = ArithmeticOp.mod;
break;
default:
- jj_la1[42] = jj_gen;
+ jj_la1[43] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1046,7 +1059,7 @@
{if (true) return new ArithExpr((NumberTerm)t1, op, (NumberTerm)t2);}
break;
default:
- jj_la1[43] = jj_gen;
+ jj_la1[44] = jj_gen;
;
}
{if (true) return t1;}
@@ -1071,7 +1084,7 @@
{if (true) return new ArithExpr((NumberTerm)t1, op, (NumberTerm)t2);}
break;
default:
- jj_la1[44] = jj_gen;
+ jj_la1[45] = jj_gen;
;
}
{if (true) return t1;}
@@ -1117,7 +1130,7 @@
{if (true) return t;}
break;
default:
- jj_la1[45] = jj_gen;
+ jj_la1[46] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1152,7 +1165,7 @@
v = new UnnamedVar(K.image);
break;
default:
- jj_la1[46] = jj_gen;
+ jj_la1[47] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1162,7 +1175,7 @@
v.setAnnots(lt);
break;
default:
- jj_la1[47] = jj_gen;
+ jj_la1[48] = jj_gen;
;
}
{if (true) return v;}
@@ -1235,7 +1248,7 @@
public boolean lookingAhead = false;
private boolean jj_semLA;
private int jj_gen;
- final private int[] jj_la1 = new int[48];
+ final private int[] jj_la1 = new int[49];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static {
@@ -1243,10 +1256,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,0x0,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,0x0,0x8000000,0x8000000,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,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,0x400,0x200,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;
@@ -1261,7 +1274,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1274,7 +1287,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1284,7 +1297,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1294,7 +1307,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1303,7 +1316,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1312,7 +1325,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1431,7 +1444,7 @@
la1tokens[jj_kind] = true;
jj_kind = -1;
}
- for (int i = 0; i < 48; i++) {
+ for (int i = 0; i < 49; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
Modified: trunk/src/jason/stdlib/drop_intention.java
===================================================================
--- trunk/src/jason/stdlib/drop_intention.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/stdlib/drop_intention.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -81,34 +81,39 @@
}
public void dropInt(Circumstance C, Literal l, Unifier un) {
+ Unifier bak = un.copy();
+
Trigger g = new Trigger(TEOperator.add, TEType.achieve, l);
-
for (Intention i: C.getIntentions()) {
- if (i.hasTrigger(g, un.copy())) {
+ if (i.hasTrigger(g, un)) {
C.removeIntention(i);
+ un = bak.copy();
}
}
// intention may be suspended in E
for (Event e: C.getEvents()) {
Intention i = e.getIntention();
- if (i != null && i.hasTrigger(g, un.copy())) {
+ if (i != null && i.hasTrigger(g, un)) {
C.removeEvent(e);
+ un = bak.copy();
}
}
// 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.copy())) {
+ if (i.hasTrigger(g, un)) {
C.dropPendingAction(i);
+ un = bak.copy();
}
}
// intention may be suspended in PI! (in the new semantics)
for (Intention i: C.getPendingIntentions().values()) {
- if (i != null && i.hasTrigger(g, un.copy())) {
+ if (i != null && 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.
|