|
From: <jom...@us...> - 2008-05-27 19:28:41
|
Revision: 1313
http://jason.svn.sourceforge.net/jason/?rev=1313&view=rev
Author: jomifred
Date: 2008-05-27 12:28:36 -0700 (Tue, 27 May 2008)
Log Message:
-----------
jason team: fix the bug in near unvisited that stop the agents sometimes
Modified Paths:
--------------
trunk/applications/jason-team/AC-jason-official.mas2j
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/ACArchitecture.java
trunk/applications/jason-team/src/java/arch/ACProxy.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
trunk/applications/jason-team/src/java/jia/Search.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/near_least_visited.java
trunk/applications/jason-team/src/team-os.xml
Modified: trunk/applications/jason-team/AC-jason-official.mas2j
===================================================================
--- trunk/applications/jason-team/AC-jason-official.mas2j 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/AC-jason-official.mas2j 2008-05-27 19:28:36 UTC (rev 1313)
@@ -15,42 +15,42 @@
gaucho1 gaucho.asl
[verbose=1, gui=yes, write_status=yes, //ac_sim_back_dir="./massim-server/backup",
- host="agentmaster.in.tu-clausthal.de", port=12300, username="Jason0", password="Pq600pXo"]
+ host="agentcontest1.in.tu-clausthal.de", port=12300, username="Jason0", password="Pq600pXo"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
"target(_,_)", "group_leader(key,_)", //"cow(key,_,_)",
"group_area(key, _)");
gaucho2 gaucho.asl
- [verbose=1,host="agentmaster.in.tu-clausthal.de", port=12300, username="Jason1", password="EjFlDB7U"]
+ [verbose=1,host="agentcontest1.in.tu-clausthal.de", port=12300, username="Jason1", password="EjFlDB7U"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
"target(_,_)", "group_leader(key,_)", //"cow(key,_,_)",
"group_area(key, _)");
gaucho3 gaucho.asl
- [verbose=1,gui=no,host="agentmaster.in.tu-clausthal.de", port=12300, username="Jason2", password="Jt9VNkUN"]
+ [verbose=1,gui=no,host="agentcontest1.in.tu-clausthal.de", port=12300, username="Jason2", password="Jt9VNkUN"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
"target(_,_)", "group_leader(key,_)", //"cow(key,_,_)",
"group_area(key, _)");
gaucho4 gaucho.asl
- [verbose=1,host="agentmaster.in.tu-clausthal.de", port=12300, username="Jason3", password="IzToicMA"]
+ [verbose=1,host="agentcontest1.in.tu-clausthal.de", port=12300, username="Jason3", password="IzToicMA"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
"target(_,_)", "group_leader(key,_)", //"cow(key,_,_)",
"group_area(key, _)");
gaucho5 gaucho.asl
- [verbose=1,gui=no,host="agentmaster.in.tu-clausthal.de", port=12300, username="Jason4", password="7dIx5Ioh"]
+ [verbose=1,gui=no,host="agentcontest1.in.tu-clausthal.de", port=12300, username="Jason4", password="7dIx5Ioh"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
"target(_,_)", "group_leader(key,_)", //"cow(key,_,_)",
"group_area(key, _)");
gaucho6 gaucho.asl
- [verbose=1,host="agentmaster.in.tu-clausthal.de", port=12300, username="Jason5", password="kd1u9HLi"]
+ [verbose=1,host="agentcontest1.in.tu-clausthal.de", port=12300, username="Jason5", password="kd1u9HLi"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)",
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-27 19:28:36 UTC (rev 1313)
@@ -78,7 +78,9 @@
!find_scouter([], G);
jmoise.set_goal_state(Sch, find_scouter, satisfied).
-
+-!find_scouter[scheme(Sch),group(G)]
+ <- .wait(1000); !find_scouter[scheme(Sch),group(G)].
+
+!find_scouter(_,G) // if someone plays scouter in my group, it is ok.
: play(_,scouter,G).
+!find_scouter([],G)
@@ -140,13 +142,43 @@
+!change_to_herding[scheme(Sch),mission(Mission)]
: cow(_,_,_)
<- .print("ooo I see some cows, create the herding group");
- !!create_herding_gr.
+ // check these cows are being herded by other group
+ .findall(L, group_leader(_,L),Leaders);
+ !ask_all_cows(Leaders,LCows);
+ .findall(cow(ID,X,Y), cow(ID,X,Y), MyCows);
+ .intersection(MyCows, LCows, Common);
+ .print("xxx all cows in herding groups are ",LCows," my are ",MyCows," intersection is ",Common);
+ if ( Common == [] ) {
+ .print("xxx start herding");
+ !!create_herding_gr
+ }{
+ !check_small_herd_grp(Leaders)
+ }.
+!change_to_herding[scheme(Sch),mission(Mission)].
{ end }
++!ask_all_cows([],[]).
++!ask_all_cows([L|Leaders],Cows)
+ <- .send(L,askAll,cow(_,_,_),LC);
+ .print("xxx cows from ",L," are ",LC);
+ !ask_all_cows(Leaders,RC);
+ .concat(LC,RC,Cows).
+
++!check_small_herd_grp([]).
++!check_small_herd_grp([L|Leaders])
+ <- .send(L,askAll,play(_, herdboy, _), LBoys);
+ .send(L,askOne,current_cluster(_),current_cluster(LCluster));
+ .print("xxx boys of ",L," are ",LBoys," his cluster size is ", .length(LCluster));
+ if (.length(LBoys) < 2 & .length(LCluster) > 10) {
+ .print("xxx start herding");
+ !!create_herding_gr
+ }{
+ !check_small_herd_grp(Leaders)
+ }.
+
/* -- plans for the goals of role scouter -- */
{ begin maintenance_goal("+pos(_,_,_)") }
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-27 19:28:36 UTC (rev 1313)
@@ -38,8 +38,7 @@
+?ally_pos(Name,X,Y) : .my_name(Name) <- ?pos(X,Y,_).
+corral(UpperLeftX,UpperLeftY,DownRightX,DownRightY)
- <- .print(UpperLeftX,UpperLeftY,DownRightX,DownRightY);
- -+corral_center( (UpperLeftX + DownRightX)/2, (UpperLeftY + DownRightY)/2).
+ <- -+corral_center( (UpperLeftX + DownRightX)/2, (UpperLeftY + DownRightY)/2).
+end_of_simulation(_Result)
@@ -52,7 +51,10 @@
: .my_name(Me) &
agent_id(Me,AgId) &
AgId mod 2 == 1 // I have an odd Id
- <- .print("*** restart -- odd ***");
+ <- .print("*** restart -- odd ***");
+ ?random_pos(X,Y);
+ +target(X,Y);
+ .wait("+at_target",10000,_);
!create_exploration_gr.
+!restart
<- .print("*** restart -- even ***");
@@ -68,7 +70,7 @@
.findall(GH, group(herding_grp,GH), LGH);
!try_adopt(herdboy,LGH)
}.
-
+
+!try_adopt(_Role,[]).
+!try_adopt(Role,[G|_])
<- .print("ooo try role ",Role, " in ",G);
@@ -136,8 +138,9 @@
!quite_all_missions_roles;
jmoise.adopt_role(NewRole,GT).
--!change_role(R,G)
- <- !change_role(R,G).
+// causes a loop:
+// -!change_role(R,G)
+// <- .wait(500); !change_role(R,G).
+!play_role(R,G)
: .my_name(Me) & play(Me,R,G).
Modified: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-05-27 19:28:36 UTC (rev 1313)
@@ -5,15 +5,14 @@
/* -- 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)
*/
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-27 19:28:36 UTC (rev 1313)
@@ -90,7 +90,17 @@
.wait(2000). // give some time for them to adopt the roles before check merging again
+!check_merge.
+{ begin maintenance_goal("+pos(_,_,_)") }
++!release_boys[scheme(Sch),mission(Mission),group(Gr)]
+ : .count(play(_,herdboy,Gr),N) & N > 4
+ <- .print("xxx release gaucho5 from my herding group");
+ .send(gaucho5,achieve,create_exploration_gr);
+ .send(gaucho6,achieve,restart).
++!release_boys[scheme(Sch),mission(Mission),group(Gr)].
+
+{ end }
+
{ begin maintenance_goal("+pos(_,_,_)") }
+!define_formation[scheme(Sch),mission(Mission)]
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-05-27 19:28:36 UTC (rev 1313)
@@ -67,7 +67,7 @@
@Override
public List<Literal> perceive() {
- /* agDidPerceive(); // for crash control */
+ agDidPerceive(); // for crash control
return new ArrayList<Literal>(percepts); // it must be a copy!
}
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-05-27 19:28:36 UTC (rev 1313)
@@ -185,14 +185,17 @@
}
} else if (type.getNodeName().equals("cow")) {
- int cowId = Integer.parseInt(type.getAttribute("ID"));
- Literal lc = new Literal("cow");
- lc.addTerms(new NumberTermImpl( cowId ), new NumberTermImpl( absx), new NumberTermImpl(absy));
- Structure stepannot = new Structure("step",1);
- stepannot.addTerm(new NumberTermImpl(step));
- lc.addAnnot(stepannot);
- percepts.add(lc);
- //arq.cowPerceived(absx, absy);
+ // ignore cows in the border, they complicate all :-)
+ if (absx < arq.getModel().getWidth()-1 && absx != 0 && absy != 00 && absy < arq.getModel().getHeight()-1) {
+ int cowId = Integer.parseInt(type.getAttribute("ID"));
+ Literal lc = new Literal("cow");
+ lc.addTerms(new NumberTermImpl( cowId ), new NumberTermImpl( absx), new NumberTermImpl(absy));
+ 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")) {
arq.obstaclePerceived(absx, absy, CowboyArch.createCellPerception(absx, absy, CowboyArch.aOBSTACLE));
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-27 19:28:36 UTC (rev 1313)
@@ -29,7 +29,7 @@
*
* @author Jomi
*/
-public class CowboyArch extends OrgAgent { //IdentifyCrashed {
+public class CowboyArch extends IdentifyCrashed { //IdentifyCrashed OrgAgent{
LocalWorldModel model = null;
WorldView view = null;
@@ -80,12 +80,10 @@
super.stopAg();
}
- /*
@Override
public boolean isCrashed() {
return playing && super.isCrashed();
}
- */
void setSimId(String id) {
simId = id;
@@ -380,3 +378,4 @@
}
}
+
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-27 19:28:36 UTC (rev 1313)
@@ -236,9 +236,12 @@
logger.info(line);
}
*/
+ Location better = null;
//int visitedTarget = 0;
- while (true) {
+ int loopcount = 0;
+ while (loopcount < 100) {
+ loopcount++;
int x = agloc.x;
int y = agloc.y;
@@ -246,9 +249,9 @@
int dx = 0;
int dy = 0;
int stage = 1;//(x % 2 == 0 ? 1 : 2);
- Location better = null;
-
+ better = null;
while (w < getWidth()) { //( (w/2+distanceToBorder) < getWidth()) {
+
switch (stage) {
case 1: if (dx < w) {
dx++;
@@ -300,6 +303,7 @@
}
minVisited++;
}
+ return better;
}
Modified: trunk/applications/jason-team/src/java/jia/Search.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Search.java 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/java/jia/Search.java 2008-05-27 19:28:36 UTC (rev 1313)
@@ -188,8 +188,8 @@
if (ia.considerRepulsionForCows) {
// consider the cost of agents only if they are near
c += ia.model.getObsRep(pos.x, pos.y);
- if (ia.from.maxBorder(pos) <= ia.maxDistFromCluster)
- c += ia.model.getAgsRep(pos.x, pos.y);
+ //if (ia.from.maxBorder(pos) <= ia.maxDistFromCluster)
+ // c += ia.model.getAgsRep(pos.x, pos.y);
}
if (ia.considerEnemyCorralRepulsion)
Modified: trunk/applications/jason-team/src/java/jia/cluster.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-27 19:28:36 UTC (rev 1313)
@@ -29,7 +29,7 @@
*/
public class cluster extends DefaultInternalAction {
- private static final int MAXCLUSTERSIZE = 15;
+ private static final int MAXCLUSTERSIZE = 25;
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
@@ -40,7 +40,7 @@
return false;
//Location agLoc = model.getAgPos(arch.getMyId());
- List<Location> locs = getCluster(model, WorldModel.cowPerceptionRatio);
+ List<Location> locs = getCluster(model, 3); //WorldModel.cowPerceptionRatio);
if (args.length == 1) {
return un.unifies(args[0], new ObjectTermImpl(locs));
@@ -95,7 +95,7 @@
Vec v = i.next();
Iterator<Vec> j = cs.iterator();
- while (j.hasNext()) {
+ while (j.hasNext() && cs.size() < MAXCLUSTERSIZE) {
Vec c = j.next();
if (c.sub(v).magnitude() < maxDist) {
cs.add(v);
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-27 19:28:36 UTC (rev 1313)
@@ -38,15 +38,15 @@
*/
public class herd_position extends DefaultInternalAction {
- public static final int agDistanceInFormation = 4;
+ public static final int agDistanceInFormation = 3;
public enum Formation {
one { Vec[] getDistances() { return new Vec[] { new Vec(0,0) }; } },
- two { Vec[] getDistances() { return new Vec[] { new Vec(sd,0), new Vec(-sd, 0) }; } },
+ two { Vec[] getDistances() { return new Vec[] { new Vec(sd+1,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, -3), new Vec(-(d+sd), -3) }; } },
+ four { Vec[] getDistances() { return new Vec[] { new Vec(sd+1,0), new Vec(-sd, 0), new Vec(d+sd, -3), new Vec(-(d+sd), -3) }; } },
five { Vec[] getDistances() { return new Vec[] { new Vec(0,0), new Vec(d, -1), new Vec(-d, -1), new Vec(d*2-1,-4), new Vec(-d*2,-4) }; } },
- six { Vec[] getDistances() { return new Vec[] { new Vec(sd,0), new Vec(-sd, 0), new Vec(d+sd, -3), new Vec(-(d+sd), -3), new Vec(d*2+sd-2, -6), new Vec(-(d*2+sd-2), -6) }; } };
+ six { Vec[] getDistances() { return new Vec[] { new Vec(sd+1,0), new Vec(-sd, 0), new Vec(d+sd, -3), new Vec(-(d+sd), -3), new Vec(d*2+sd-2, -6), new Vec(-(d*2+sd-2), -6) }; } };
abstract Vec[] getDistances();
private static final int d = agDistanceInFormation;
private static final int sd = agDistanceInFormation/2;
@@ -171,6 +171,7 @@
if (farcow == null || farcow.getLocation(model).maxBorder(model.getCorralCenter()) < c.getLocation(model).maxBorder(model.getCorralCenter()))
farcow = c;
+ //Collection<Vec> allcows = model.getCows();
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>();
@@ -181,7 +182,8 @@
if (l == null) {
l = model.nearFree(agsTarget.add(mean).getLocation(model), r);
} else {
- //l = pathToNearCow(l, clusterLocs);
+ if (clusterLocs.size() > 10)
+ l = pathToNearCow(l, clusterLocs);
if ( !model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l) || r.contains(l))
l = model.nearFree(l, r);
}
@@ -212,10 +214,9 @@
return l;
}
- /*
- private Location pathToNearCow(Location t, List<Location> cluster) {
+ private Location pathToNearCow(Location t, List<Location> cows) {
Location near = null;
- for (Location c: cluster) {
+ for (Location c: cows) {
if (near == null || t.maxBorder(c) < t.maxBorder(near))
near = c;
}
@@ -231,7 +232,6 @@
}
return t;
}
- */
/*
public Location nearFreeForAg(LocalWorldModel model, Location ag, Location t) throws Exception {
Modified: trunk/applications/jason-team/src/java/jia/near_least_visited.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/near_least_visited.java 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/java/jia/near_least_visited.java 2008-05-27 19:28:36 UTC (rev 1313)
@@ -50,7 +50,9 @@
Location n = model.getNearLeastVisited(ag, tr, bl);
if (n != null) {
Search s = new Search(model, ag, n, ts.getUserAgArch());
- while (s.search() == null && ts.getUserAgArch().isRunning()) {
+ int loopcount = 0;
+ while (s.search() == null && ts.getUserAgArch().isRunning() && loopcount < 5) {
+ loopcount++;
// 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);
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-05-26 16:45:59 UTC (rev 1312)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-27 19:28:36 UTC (rev 1313)
@@ -105,6 +105,7 @@
<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="release_boys" ds="if the number of agents too much, release some boyd" 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"/>
@@ -114,6 +115,7 @@
<mission id="herd" min="1">
<goal id="recruit" />
+ <goal id="release_boys" />
<goal id="define_formation" />
<goal id="be_in_formation" />
<!--goal id="share_seen_cows" /-->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|