|
From: <jom...@us...> - 2008-04-24 22:26:42
|
Revision: 1252
http://jason.svn.sourceforge.net/jason/?rev=1252&view=rev
Author: jomifred
Date: 2008-04-24 15:26:31 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
create exploration groups for the team
explorer finds a scouter
gauchos code splited in many sources
Modified Paths:
--------------
trunk/applications/jason-eclipse-plugin/.project
trunk/applications/jason-eclipse-plugin/build.xml
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/java/arch/ACArchitecture.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
Added Paths:
-----------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/goto.asl
trunk/applications/jason-team/src/asl/herding.asl
Modified: trunk/applications/jason-eclipse-plugin/.project
===================================================================
--- trunk/applications/jason-eclipse-plugin/.project 2008-04-24 16:03:14 UTC (rev 1251)
+++ trunk/applications/jason-eclipse-plugin/.project 2008-04-24 22:26:31 UTC (rev 1252)
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>JasonIDE</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jason eclipse plugin</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Modified: trunk/applications/jason-eclipse-plugin/build.xml
===================================================================
--- trunk/applications/jason-eclipse-plugin/build.xml 2008-04-24 16:03:14 UTC (rev 1251)
+++ trunk/applications/jason-eclipse-plugin/build.xml 2008-04-24 22:26:31 UTC (rev 1252)
@@ -25,14 +25,6 @@
<pathelement location="${jasonJar}" />
</path>
- <condition property="parsers-ok" value="ok">
- <and>
- <uptodate property="parsers-ok" targetfile="${basedir}/src/jason/mas2j/parser/mas2j.java" srcfile="${basedir}/src/jason/mas2j/parser/MAS2JavaParser.jcc" />
- <uptodate property="parsers-ok" targetfile="${basedir}/src/jason/asSyntax/parser/as2j.java" srcfile="${basedir}/src/jason/asSyntax/parser/AS2JavaParser.jcc" />
- <uptodate property="parsers-ok" targetfile="${basedir}/doc/AS2JavaParser.html" srcfile="${basedir}/src/jason/asSyntax/parser/AS2JavaParser.jcc" />
- </and>
- </condition>
-
<target name="init">
<mkdir dir="${build.dir}" />
</target>
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-24 16:03:14 UTC (rev 1251)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-24 22:26:31 UTC (rev 1252)
@@ -10,7 +10,7 @@
infrastructure: Centralised
agents:
- orgManager [osfile="src/team-os.xml",gui=no]
+ orgManager [osfile="src/team-os.xml",gui=yes]
agentArchClass jmoise.OrgManager;
gaucho1 gaucho.asl
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-04-24 16:03:14 UTC (rev 1251)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-04-24 22:26:31 UTC (rev 1252)
@@ -115,7 +115,7 @@
<- .current_intention(I); .println("failure in move, intention: ",I);
!move.
-+restart
++!restart
<- .print("*** restart ***");
.drop_all_desires;
.abolish(target(_,_));
Added: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl (rev 0)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-04-24 22:26:31 UTC (rev 1252)
@@ -0,0 +1,82 @@
+/* -- plans for exploration phase -- */
+
+/* -- initial goals -- */
+
+//!test.
+//+!test <- +gsize(16,8).
+
+/*
+ -- plans for new match
+ -- create the initial exploration groups and areas
+*/
+
+
+/* plans for agent 1 */
+
++gsize(_Weight,_Height) // new match've started
+ : .my_name(gaucho1) // agent 1 is responsible for the team creation
+ <- .print("oooo creating team group");
+ .if( group(team,Old), {
+ jmoise.remove_group(Old)
+ });
+ jmoise.create_group(team).
+
++group(team,GId) // agent 1 is responsible for the creation of exploration groups
+ : .my_name(gaucho1)
+ <- jmoise.create_group(exploration,GId);
+ jmoise.create_group(exploration,GId);
+ jmoise.create_group(exploration,GId).
++group(exploration,_) // compute the area of the groups
+ : .my_name(gaucho1) &
+ .findall(GId, group(exploration,GId), 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 agents with even id */
+
++gsize(_,_)
+ : .my_name(Me) &
+ agent_id(Me,AgId) &
+ AgId mod 2 == 0 // I have an even Id
+ <- // wait my pos
+ .if(not pos(MyX, MyY,_), { MyX = 333; MyY = 444 }); //.wait("+pos(MyX,MyY,_)")
+ .print("oooo ",MyX, MyY); //?pos(MyX, MyY,_);
+
+ // wait others pos
+ .if(not cell(_,_,ally(_)), { .wait("+cell(_,_,ally(_))") });
+ .wait(200);
+
+ // find distance to odd agents
+ .findall(ag_d(D,AgName),
+ cell(X,Y,ally(AgName)) & .print(AgName) & agent_id(AgName,Id) & .print(AgName," ooo ",Id) & Id mod 2 == 1 & jia.dist(MyX, MyY, X, Y, D),
+ LOdd);
+ .sort(LOdd, LSOdd);
+ // test if I received the area of my group
+ .if( not group_area(AgId div 2,G,A), { .wait("+group_area(AgId div 2,G,A)") });
+ .print("oooo Ags=", LSOdd," in area ",group_area(AgId div 2,G,A));
+
+ // adopt role explorer in the group
+ jmoise.adopt_role(explorer,G);
+ !find_scouter(LSOdd, G).
+
++!find_scouter([],_)
+ <- .print("oooo I do not find a scouter to work with me!").
++!find_scouter([ag_d(_,AgName)|_],GId)
+ <- .send(AgName, achieve, play_role(scouter,GId));
+ .wait("+play(Ag,scouter,GId)",1000).
+-!find_scouter([_|LSOdd],GId) // in case the wait fails, try next agent
+ <- !find_scouter(LSOdd,GId).
+
+
+/* plans for agents the others */
+
++!play_role(Role,Group)
+ <- jmoise.adopt_role(Role,Group).
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-24 16:03:14 UTC (rev 1251)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-24 22:26:31 UTC (rev 1252)
@@ -18,40 +18,34 @@
/* -- initial beliefs -- */
+agent_id(gaucho1,0).
+agent_id(gaucho2,1).
+agent_id(gaucho3,2).
+agent_id(gaucho4,3).
+agent_id(gaucho5,4).
+agent_id(gaucho6,5).
+
+ag_perception_ratio(8). // ratio of perception of the agent
+cow_perception_ratio(4).
+
/* -- initial goals -- */
-!test.
-+!test <- +gsize(16,8).
+/* -- plans -- */
-/* -- create the initial exploration groups and areas -- */
++end_of_simulation(_Result)
+ <- .abolish(area(_,_,_,_,_,_)).
-+gsize(_Weight,_Height) // new match've started
- : .my_name(gaucho1)
- <- .if( group(team,Old), {
- jmoise.remove_group(Old)
- });
- .abolish(area(_,_,_,_,_));
- jmoise.create_group(team).
-+gsize(_Weight,_Height)
- <- .abolish(area(_,_,_,_,_)).
-
-+group(team,GId)
- : .my_name(gaucho1)
- <- jmoise.create_group(exploration,GId);
- jmoise.create_group(exploration,GId);
- jmoise.create_group(exploration,GId).
-+group(exploration,_) // compute the area of the groups
- : .my_name(gaucho1) &
- .findall(GId, group(exploration,GId), LG) &
- LG = [G1,G2,G3] // there are three groups
- <- ?gsize(W,H);
- X = math.round(((W*H)/3)/H);
- +area(G1, 0, 0, X, H-1);
- +area(G2, X+1, 0, W-1, H/2);
- +area(G3, X+1, (H/2)+1, W-1, H-1).
-+area(G,A,B,C,D)[source(self)]
- <- .broadcast(tell, area(G,A,B,C,D)).
++!restart
+ <- //.print("*** restart ***");
+ .drop_all_desires;
+ .abolish(target(_,_)).
+ // TODO: what to do?
+ //!decide_target.
-// include common plans for MOISE+ agents
-{ include("moise-common.asl") }
+/* -- includes -- */
+{ include("goto.asl") } // include plans for movimentation
+{ include("exploration.asl") } // include plans for exploration
+{ include("herding.asl") } // include plans for herding
+{ include("moise-common.asl") } // include common plans for MOISE+ agents
+
Added: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl (rev 0)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-04-24 22:26:31 UTC (rev 1252)
@@ -0,0 +1,56 @@
+
+/* -- plans for movimentation -- */
+
+
+/* -- useful rules */
+
+// 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)
+*/
+
+// if the target is changed, "restart" move
++target(NX,NY)
+ <- .drop_desire(move);
+ jia.set_target(NX,NY);
+ !!move.
+
+// I still do not know my location
++!move
+ : not pos(_,_,_)
+ <- .print("waiting my location....");
+ .wait("+pos(_,_,_)");
+ !move.
+
++!move
+ : not target(_,_)
+ <- .print("waiting my target....");
+ .wait("+target(_,_)");
+ !move.
+
++!move
+ : pos(X,Y,_) & target(X,Y) // I am at target
+ <- -+at_target;
+ do(skip);
+ !!move.
+
+// does one step towards target
++!move
+ : pos(X,Y,_) &
+ target(BX,BY) &
+ jia.direction(X, Y, BX, BY, D) // jia.direction finds one action D (using A*) towards the target
+ <- do(D); // this action will "block" the intention until it is sent to the simulator (in the end of the cycle)
+ !!move. // continue moving
+
+// in case of failure, move
+-!move
+ <- .current_intention(I); .println("failure in move, intention: ",I);
+ !move.
Added: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl (rev 0)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-04-24 22:26:31 UTC (rev 1252)
@@ -0,0 +1 @@
+/* -- plans for herding phase -- */
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-24 16:03:14 UTC (rev 1251)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-24 22:26:31 UTC (rev 1252)
@@ -139,6 +139,7 @@
Lock lock = new ReentrantLock();
Condition cycle = lock.newCondition();
long timestartcycle = 0;
+ int cycleCounter = 0;
WaitSleep() {
super("WaitSpeepToSendAction");
@@ -156,6 +157,9 @@
}
void newCycle() {
+ cycleCounter++;
+ if (getCycle() == 1) cycleCounter = 1;
+
StringBuilder notsent = new StringBuilder();
if (toExecute.size() > 1) {
notsent.append(" The following was not sent: ");
@@ -173,7 +177,7 @@
// prepare msg to print out
String w = "";
- if (lastActionInCurrentCycle == null) {
+ if (lastActionInCurrentCycle == null && cycleCounter > 3) { // ignore problem in the first cycles (the agent is still in setup!)
addRestart();
w = "*** ";
}
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-24 16:03:14 UTC (rev 1251)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-24 22:26:31 UTC (rev 1252)
@@ -2,6 +2,7 @@
import jason.JasonException;
import jason.RevisionFailedException;
+import jason.asSemantics.Intention;
import jason.asSemantics.Message;
import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
@@ -224,9 +225,7 @@
try {
logger.info("** Arch adding restart for "+getAgName());
getTS().getC().create();
-
- getTS().getAg().getBB().abolish(new Literal("restart").getPredicateIndicator());
- getTS().getAg().addBel(new Literal("restart"));
+ getTS().getC().addAchvGoal(new Literal("restart"), Intention.EmptyInt);
lo2 = new Location(-1,-1); // to not restart again in the next cycle
} catch (Exception e) {
logger.info("Error in restart!"+ e);
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-04-24 16:03:14 UTC (rev 1251)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-04-24 22:26:31 UTC (rev 1252)
@@ -67,21 +67,23 @@
//out.println(model.toString());
StringBuilder s = new StringBuilder(String.format("Step %5d : ", owner.getCycle()-1));
for (int agId=0; agId<WorldModel.agsByTeam; agId++) {
- Location agp = agents[agId].getLastLocation();
- if (agp != null) {
- // count how long the agent is in the same location
- int c = 0;
- Iterator<Location> il = locations.get(agId).iterator();
- while (il.hasNext() && il.next().equals(agp) && c <= 11) {
- c++;
- }
- String sc = "*";
- if (c < 10) sc = ""+c;
-
- locations.get(agId).add(0,agp);
- String lastAct = shortActionFormat(agents[agId].getLastAction());
- s.append(String.format("%5d,%2d/%s %s", agp.x, agp.y, sc, lastAct));
- }
+ if (agents[agId] != null) {
+ Location agp = agents[agId].getLastLocation();
+ if (agp != null) {
+ // count how long the agent is in the same location
+ int c = 0;
+ Iterator<Location> il = locations.get(agId).iterator();
+ while (il.hasNext() && il.next().equals(agp) && c <= 11) {
+ c++;
+ }
+ String sc = "*";
+ if (c < 10) sc = ""+c;
+
+ locations.get(agId).add(0,agp);
+ String lastAct = shortActionFormat(agents[agId].getLastAction());
+ s.append(String.format("%5d,%2d/%s %s", agp.x, agp.y, sc, lastAct));
+ }
+ }
}
logger.info(s.toString());
out.println(s.toString());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|