|
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.
|