|
From: <bo...@us...> - 2008-04-26 21:45:32
|
Revision: 1266
http://jason.svn.sourceforge.net/jason/?rev=1266&view=rev
Author: bordini
Date: 2008-04-26 14:45:22 -0700 (Sat, 26 Apr 2008)
Log Message:
-----------
target allocation for herding formation and sharing of information about cow locations
Modified Paths:
--------------
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/team-os.xml
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-04-26 20:32:39 UTC (rev 1265)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-04-26 21:45:22 UTC (rev 1266)
@@ -3,9 +3,9 @@
/* -- initial beliefs -- */
-// missions I can commit to
-desired_mission(exploring, mexplorer).
-desired_mission(exploring, mscouter).
+// missions I can commit to depend on the roles I adopt
+desired_mission(explore_sch, explore) :- desired_role(exploration_grp, explorer).
+desired_mission(explore_sch, scout) :- desired_role(exploration_grp, scouter).
/* -- initial goals -- */
@@ -21,7 +21,7 @@
/* plans for agent 1 */
-+gsize(_Weight,_Height) // new match've started
++gsize(_Weight,_Height) // new match has started
: .my_name(gaucho1) // agent 1 is responsible for the team creation
<- //.print("oooo creating team group");
.if( group(team,Old), {
@@ -78,13 +78,15 @@
// adopt role explorer in the group
jmoise.adopt_role(explorer,G);
+ +desired_role(exploration_grp, explorer); // needed for moise-common plans
+ +desired_role(herding_grp, herder); // explorers will also be herders
!find_scouter(LSOdd, G).
+!find_scouter([],_)
- <- .print("ooo I do not find a scouter to work with me!").
+ <- .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));
+ .send(AgName, achieve, play_role(scouter,GId,exploration_grp));
.wait("+play(Ag,scouter,GId)",2000).
-!find_scouter([_|LSOdd],GId) // in case the wait fails, try next agent
<- .print("ooo find_scouter failure, try another agent.");
@@ -99,17 +101,24 @@
/* plans for the others */
-+!play_role(Role,Group)[source(Ag)]
++!play_role(Role,Group,Group_Spec)[source(Ag)]
<- .print("ooo Adopting role ",Role,", asked by ",Ag);
- jmoise.adopt_role(Role,Group).
-
-
+ jmoise.adopt_role(Role, Group);
+ +desired_role(Group_Spec, Role).
+
+// to keep plan above generic...
+// scouters will be herdboys
+// and need to tell t
++desired_role(exploration_grp, scouter)
+ <- +desired_role(herding_grp, herdboy).
+
+
/* -- plans for the goals of role explorer -- */
// TODO: make a pattern for organisational maintainance goal
+!goto_near_unvisited[scheme(Sch)]
- <- .print("ooo I should find the near unvisited location and go there!");
+ <- .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
@@ -136,9 +145,15 @@
/* -- plans for the goals of all roles -- */
-+!share_cows[scheme(Sch)]
++!share_seen_cows[scheme(Sch)]
<- .print("ooo I should share cows!");
- // TODO:
+ ?cows_to_inform(C);
+ jmoise.broadcast(Sch, tell, C);
.wait("+pos(_,_,_)"); // wait next cycle
- !!share_cows[scheme(Sch)].
+ !!share_seen_cows[scheme(Sch)].
++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]).
+
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-26 20:32:39 UTC (rev 1265)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-26 21:45:22 UTC (rev 1266)
@@ -18,18 +18,26 @@
/* -- 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).
+agent_id(gaucho1,1).
+agent_id(gaucho2,2).
+agent_id(gaucho3,3).
+agent_id(gaucho4,4).
+agent_id(gaucho5,5).
+agent_id(gaucho6,6).
ag_perception_ratio(8). // ratio of perception of the agent
cow_perception_ratio(4).
/* -- 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)").
@@ -47,7 +55,7 @@
/* -- includes -- */
-{ include("goto.asl") } // include plans for movimentation
+{ include("goto.asl") } // include plans for moving around
{ include("exploration.asl") } // include plans for exploration
{ include("herding.asl") } // include plans for herding
{ include("moise-common.asl") } // include common plans for MOISE+ agents
Modified: trunk/applications/jason-team/src/asl/goto.asl
===================================================================
--- trunk/applications/jason-team/src/asl/goto.asl 2008-04-26 20:32:39 UTC (rev 1265)
+++ trunk/applications/jason-team/src/asl/goto.asl 2008-04-26 21:45:22 UTC (rev 1266)
@@ -53,5 +53,6 @@
// in case of failure, move
-!move
- <- .current_intention(I); .println("failure in move, intention: ",I);
+ <- .current_intention(I); .println("failure in moving; intention was: ",I);
!move.
+
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-04-26 20:32:39 UTC (rev 1265)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-04-26 21:45:22 UTC (rev 1266)
@@ -3,8 +3,8 @@
/* -- initial beliefs -- */
// missions I can commit to
-desired_mission(exploring, mherder).
-desired_mission(exploring, mherdboy).
+desired_mission(herd_sch, herd) :- desired_role(herding_grp, herder).
+desired_mission(herd_sch, help_herder) :- desired_role(herding_grp, herdboy).
/* -- plans for the goals of role herder -- */
@@ -18,13 +18,46 @@
+!define_formation[scheme(Sch)]
<- .print("ooo I should define the formation of my group!");
- jia.herd_position(2,L); // formation in two (TODO: get the number of players in the group or scheme)
+ ?my_group(G, herder);
+ .length(G,NumP);
+ jia.herd_position(NumP,L);
.print("ooo formation is ",L);
- // TODO: allocate and share the formation
+ !alloc_all(G,L);
.wait("+pos(_,_,_)"); // wait next cycle
!!define_formation[scheme(Sch)].
+// get the list G of participants of the group where I play R
++?my_group(G,R)
+ <- .my_name(Me);
+ play(Me,R,Gid);
+ .findall(P, play(P,_,Gid), G);
+ +my_group(G,R).
+// TODO, IMPORTANT: Quando tiver mudanca no grupo, apagar essa crenca
+// pra deixar esse plano rodar de novo.
++!alloc_all([],LA).
++!alloc_all([HA|TA],LA)
+ <- !find_closest(HA,LA,pos(X,Y),NLA);
+ .send(HA,tell,target(X,Y));
+ -+alloc_target(HA,Alloc);
+ !alloc_all(TA,NLA).
+
++!find_closest(Ag, List, Alloc, Rest)
+ <- ?alloc_target(Ag,pos(X,Y));
+ !closest(List,[],Sorted,pos(X,Y),9999);
+ Sorted = [Alloc|Rest];
+ .print("FIND CLOSEST: ",Sorted).
+
++!closest([],S,S,P,D).
++!closest([pos(XH,YH)|T],Aux,S,pos(XP,YP),LD)
+ : jia.dist(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).
+
++?alloc_target(Ag,X,Y) <- .send(Ag, askOne, pos(X,Y,_), pos(X,Y,_)).
+
/* -- plans for the goals of all roles (herder and herdboy) -- */
+!be_in_formation[scheme(Sch)]
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-04-26 20:32:39 UTC (rev 1265)
+++ trunk/applications/jason-team/src/team-os.xml 2008-04-26 21:45:22 UTC (rev 1266)
@@ -38,19 +38,20 @@
<sub-groups>
- <group-specification id="exploration" min="3" max="3" >
+ <group-specification id="exploration_grp" min="3" max="3" >
<roles>
<role id="explorer" min="1" max="1"/>
<role id="scouter" min="0" max="1"/>
</roles>
</group-specification>
- <group-specification id="herding" min="0" max="6" >
+ <group-specification id="herding_grp" min="0" max="6" >
<roles>
<role id="herder" min="1" max="1"/>
<role id="herdboy" min="0" max="3"/>
</roles>
</group-specification>
+
</sub-groups>
<formation-constraints>
@@ -64,53 +65,53 @@
<functional-specification>
- <scheme id="exploring" >
+ <scheme id="explore_sch" >
<goal id="find_cows" >
<plan operator="parallel">
<goal id="goto_near_unvisited" ds="go to the near unvisited location inside the area of the group" type="maintenance"/>
- <goal id="share_cows" ds="share seen cows with other agents in the scheme" 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"/>
</plan>
</goal>
- <mission id="mexplorer" min="1">
+ <mission id="explore" min="1">
<goal id="goto_near_unvisited" />
- <goal id="share_cows" />
+ <goal id="share_seen_cows" />
</mission>
- <mission id="mscouter" >
+ <mission id="scout" >
<goal id="follow_leader" />
- <goal id="share_cows" />
+ <goal id="share_seen_cows" />
</mission>
</scheme>
- <scheme id="herding" >
+ <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_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/>
+ <goal id="share_seen_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/>
</plan>
</goal>
- <mission id="mherder" min="1">
+ <mission id="herd" min="1">
<goal id="recruit" />
<goal id="define_formation" />
<goal id="be_in_formation" />
- <goal id="share_cows" />
+ <goal id="share_seen_cows" />
</mission>
- <mission id="mherdboy" >
+ <mission id="help_herder" >
<goal id="be_in_formation" />
- <goal id="share_cows" />
+ <goal id="share_seen_cows" />
</mission>
</scheme>
</functional-specification>
<deontic-specification>
- <deontic-relation type="obligation" role="explorer" mission="mexplorer" />
- <deontic-relation type="obligation" role="scouter" mission="mscouter" />
- <deontic-relation type="obligation" role="herder" mission="mherder" />
- <deontic-relation type="obligation" role="herdboy" mission="mherdboy" />
+ <deontic-relation type="obligation" role="explorer" mission="mexplore" />
+ <deontic-relation type="obligation" role="scouter" mission="mscout" />
+ <deontic-relation type="obligation" role="herder" mission="mherd" />
+ <deontic-relation type="obligation" role="herdboy" mission="mhelp_herder" />
</deontic-specification>
</organisational-specification>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-27 17:57:31
|
Revision: 1272
http://jason.svn.sourceforge.net/jason/?rev=1272&view=rev
Author: jomifred
Date: 2008-04-27 10:57:30 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
add internal action scouter_pos
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/java/env/WorldModel.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
Added Paths:
-----------
trunk/applications/jason-team/src/java/jia/scouter_pos.java
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-04-27 14:10:17 UTC (rev 1271)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-04-27 17:57:30 UTC (rev 1272)
@@ -133,9 +133,17 @@
-+target(LX,LY)
}, {
.print("ooo being in formation with leader.");
- do(skip)
+ .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
Modified: trunk/applications/jason-team/src/java/env/WorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/env/WorldModel.java 2008-04-27 14:10:17 UTC (rev 1271)
+++ trunk/applications/jason-team/src/java/env/WorldModel.java 2008-04-27 17:57:30 UTC (rev 1272)
@@ -23,7 +23,7 @@
public static final int agsByTeam = 6;
- public static final int agPerceptionRatio = 8;
+ public static final int agPerceptionRatio = 8;
public static final int cowPerceptionRatio = 4;
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-27 14:10:17 UTC (rev 1271)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-27 17:57:30 UTC (rev 1272)
@@ -186,11 +186,11 @@
if (dist < 0)
initAgTS = Math.abs(dist)+1;
}
- System.out.println("all places "+r);
+ //System.out.println("all places "+r);
return r;
}
- private Location findFirstFreeLocTowardsTarget(Vec target, Vec ref, int initialSize, int maxSize, LocalWorldModel model) {
+ 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);;
Added: trunk/applications/jason-team/src/java/jia/scouter_pos.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/scouter_pos.java (rev 0)
+++ trunk/applications/jason-team/src/java/jia/scouter_pos.java 2008-04-27 17:57:30 UTC (rev 1272)
@@ -0,0 +1,63 @@
+package jia;
+
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.NumberTerm;
+import jason.asSyntax.NumberTermImpl;
+import jason.asSyntax.Term;
+import jason.environment.grid.Location;
+
+import java.util.logging.Level;
+
+import arch.CowboyArch;
+import arch.LocalWorldModel;
+import env.WorldModel;
+
+/**
+ * Gives a good location for the scouter
+ *
+ * jia.scouter_pos( LeaderPos, LeaderTarget, Return).
+ *
+ * Example: jia.scouter_pos( 2,2, 5,6, X, Y)
+ *
+ * @author jomi
+ */
+public class scouter_pos 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;
+
+ int lx = (int)((NumberTerm)args[0]).solve();
+ int ly = (int)((NumberTerm)args[1]).solve();
+ int tx = (int)((NumberTerm)args[2]).solve();
+ int ty = (int)((NumberTerm)args[3]).solve();
+ Location leaderPos = new Location(lx, ly);
+ Location leaderTarget = new Location(tx, ty);
+
+ Location agTarget = getScouterTarget(model, leaderPos, leaderTarget);
+ if (agTarget != null) {
+ return un.unifies(args[4], new NumberTermImpl(agTarget.x)) &&
+ un.unifies(args[5], new NumberTermImpl(agTarget.y));
+ } else {
+ ts.getLogger().info("No target for scouter!");
+ }
+ } catch (Throwable e) {
+ ts.getLogger().log(Level.SEVERE, "scouter_pos error: "+e, e);
+ }
+ return false;
+ }
+
+ 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);
+ }
+}
+
Modified: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-27 14:10:17 UTC (rev 1271)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-27 17:57:30 UTC (rev 1272)
@@ -10,6 +10,7 @@
import jia.Search;
import jia.Vec;
import jia.herd_position;
+import jia.scouter_pos;
import jia.herd_position.Formation;
import org.junit.Before;
@@ -188,6 +189,19 @@
assertEquals(new Location(11,49), byIA);
}
+ @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);
+
+ 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);
+ }
+
/*
@Test
public void oneCow() throws Exception {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-27 18:05:27
|
Revision: 1273
http://jason.svn.sourceforge.net/jason/?rev=1273&view=rev
Author: jomifred
Date: 2008-04-27 11:05:25 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
jason team: add path_length.java
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/herding.asl
Added Paths:
-----------
trunk/applications/jason-team/src/java/jia/path_length.java
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-04-27 17:57:30 UTC (rev 1272)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-04-27 18:05:25 UTC (rev 1273)
@@ -66,7 +66,7 @@
// find distance to even agents
.findall(ag_d(D,AgName),
- ally_pos(AgName,X,Y) & agent_id(AgName,Id) & Id mod 2 == 0 & jia.dist(MyX, MyY, X, Y, D),
+ 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);
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-04-27 17:57:30 UTC (rev 1272)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-04-27 18:05:25 UTC (rev 1273)
@@ -36,7 +36,7 @@
// TODO: use min
+!closest([],S,S,P,D).
+!closest([pos(XH,YH)|T],Aux,S,pos(XP,YP),LD)
- : jia.dist(XH,YH,XP,YP,D) & D < LD // usar A*
+ : jia.path_length(XH,YH,XP,YP,D) & D < LD // usar A*
<- !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);
Added: trunk/applications/jason-team/src/java/jia/path_length.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/path_length.java (rev 0)
+++ trunk/applications/jason-team/src/java/jia/path_length.java 2008-04-27 18:05:25 UTC (rev 1273)
@@ -0,0 +1,51 @@
+package jia;
+
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.NumberTerm;
+import jason.asSyntax.NumberTermImpl;
+import jason.asSyntax.Term;
+import jason.environment.grid.Location;
+
+import java.util.logging.Level;
+
+import arch.CowboyArch;
+import arch.LocalWorldModel;
+import busca.Nodo;
+
+public class path_length extends DefaultInternalAction {
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
+ try {
+ LocalWorldModel model = ((CowboyArch)ts.getUserAgArch()).getModel();
+
+ int iagx = (int)((NumberTerm)terms[0]).solve();
+ int iagy = (int)((NumberTerm)terms[1]).solve();
+ int itox = (int)((NumberTerm)terms[2]).solve();
+ int itoy = (int)((NumberTerm)terms[3]).solve();
+
+ if (model.inGrid(itox,itoy)) {
+
+ // destination should be a free place
+ while (!model.isFreeOfObstacle(itox,itoy) && itox > 0) itox--;
+ while (!model.isFreeOfObstacle(itox,itoy) && itox < model.getWidth()) itox++;
+
+ Location from = new Location(iagx, iagy);
+ Location to = new Location(itox, itoy);
+
+ Nodo solution = new Search(model, from, to, ts.getUserAgArch()).search();
+ if (solution != null) {
+ int length = solution.getProfundidade();
+ return un.unifies(terms[4], new NumberTermImpl(length));
+ } else {
+ ts.getLogger().info("No route from "+from+" to "+to+"!"+"\n"+model);
+ }
+ }
+ } catch (Throwable e) {
+ ts.getLogger().log(Level.SEVERE, "jia.path_length error: "+e, e);
+ }
+ return false;
+ }
+}
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-26 14:34:07
|
Revision: 1310
http://jason.svn.sourceforge.net/jason/?rev=1310&view=rev
Author: jomifred
Date: 2008-05-26 07:34:03 -0700 (Mon, 26 May 2008)
Log Message:
-----------
jason team: fixes
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/gaucho.asl
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
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-26 13:54:15 UTC (rev 1309)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-26 14:34:03 UTC (rev 1310)
@@ -59,17 +59,17 @@
!try_adopt(scouter,LGE);
// if I still have no role, try herdboy
- if ( not play(Me,_,_) ) {
+ if ( not play(Me,_,_) ) {
.findall(GH, group(herding_grp,GH), LGH);
- !try_adopt(herdboy,LGH)
- }.
+ !try_adopt(herdboy,LGH)
+ }.
+!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).
+ <- .wait(500); !try_adopt(Role,RG).
/* -- plans for the goals of all roles -- */
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-26 13:54:15 UTC (rev 1309)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-26 14:34:03 UTC (rev 1310)
@@ -3,7 +3,6 @@
import jason.JasonException;
import jason.ReceiverNotFoundException;
import jason.RevisionFailedException;
-import jason.architecture.AgArch;
import jason.asSemantics.Intention;
import jason.asSemantics.Message;
import jason.asSyntax.Atom;
@@ -19,6 +18,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import jmoise.OrgAgent;
import agent.SelectEvent;
import env.ACViewer;
import env.WorldModel;
@@ -29,7 +29,7 @@
*
* @author Jomi
*/
-public class CowboyArch extends AgArch { //IdentifyCrashed {
+public class CowboyArch extends OrgAgent { //IdentifyCrashed {
LocalWorldModel model = null;
WorldView view = null;
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-26 13:54:15 UTC (rev 1309)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-05-26 14:34:03 UTC (rev 1310)
@@ -145,16 +145,12 @@
}
private void increp(int[][] m, int x, int y, int maxr, int value) {
- System.out.println("in for "+x+" "+y+" "+value);
- for (int r = 1; r <= maxr; r++) {
- System.out.println(" "+r);
+ for (int r = 1; r <= maxr; r++)
for (int c = x-r; c <= x+r; c++)
for (int l = y-r; l <= y+r; l++)
if (inGrid(c,l)) {
- System.out.println(" "+c+" "+l+" +"+value);
m[c][l] += value;
}
- }
}
// occupied means the places that can not be considered as nearFree
Modified: trunk/applications/jason-team/src/java/jia/Search.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Search.java 2008-05-26 13:54:15 UTC (rev 1309)
+++ trunk/applications/jason-team/src/java/jia/Search.java 2008-05-26 14:34:03 UTC (rev 1310)
@@ -192,10 +192,8 @@
c += ia.model.getAgsRep(pos.x, pos.y);
}
- if (ia.considerEnemyCorralRepulsion) {
- System.out.println("using "+ia.model.getEnemyCorralRep(pos.x, pos.y)+" for "+pos);
+ if (ia.considerEnemyCorralRepulsion)
c += ia.model.getEnemyCorralRep(pos.x, pos.y);
- }
return c;
}
Modified: trunk/applications/jason-team/src/java/jia/cluster.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-26 13:54:15 UTC (rev 1309)
+++ trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-26 14:34:03 UTC (rev 1310)
@@ -29,6 +29,8 @@
*/
public class cluster extends DefaultInternalAction {
+ private static final int MAXCLUSTERSIZE = 15;
+
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
@@ -103,6 +105,10 @@
}
}
}
+
+ // do not get too big clusters
+ if (cs.size() > MAXCLUSTERSIZE)
+ break;
}
List<Location> clusterLocs = new ArrayList<Location>();
for (Vec v: cs) {
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-26 13:54:15 UTC (rev 1309)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-05-26 14:34:03 UTC (rev 1310)
@@ -44,9 +44,9 @@
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) }; } };
+ four { Vec[] getDistances() { return new Vec[] { new Vec(sd,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) }; } };
abstract Vec[] getDistances();
private static final int d = agDistanceInFormation;
private static final int sd = agDistanceInFormation/2;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-28 20:06:03
|
Revision: 1314
http://jason.svn.sourceforge.net/jason/?rev=1314&view=rev
Author: jomifred
Date: 2008-05-28 13:05:55 -0700 (Wed, 28 May 2008)
Log Message:
-----------
jason team: minor fixes
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/java/arch/ACArchitecture.java
trunk/applications/jason-team/src/java/jia/cluster.java
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-27 19:28:36 UTC (rev 1313)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-28 20:05:55 UTC (rev 1314)
@@ -147,9 +147,8 @@
!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);
+ //.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)
@@ -162,7 +161,7 @@
+!ask_all_cows([],[]).
+!ask_all_cows([L|Leaders],Cows)
<- .send(L,askAll,cow(_,_,_),LC);
- .print("xxx cows from ",L," are ",LC);
+ //.print("xxx cows from ",L," are ",LC);
!ask_all_cows(Leaders,RC);
.concat(LC,RC,Cows).
@@ -171,9 +170,8 @@
+!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));
+ //.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)
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-05-27 19:28:36 UTC (rev 1313)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-05-28 20:05:55 UTC (rev 1314)
@@ -221,6 +221,7 @@
try {
lastAction = null;
waitSleep();
+
if (lastAction != null) {
lastActionInCurrentCycle = lastAction.getActionTerm().getTerm(0).toString();
proxy.sendAction(lastActionInCurrentCycle);
Modified: trunk/applications/jason-team/src/java/jia/cluster.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-27 19:28:36 UTC (rev 1313)
+++ trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-28 20:05:55 UTC (rev 1314)
@@ -29,7 +29,7 @@
*/
public class cluster extends DefaultInternalAction {
- private static final int MAXCLUSTERSIZE = 25;
+ private static final int MAXCLUSTERSIZE = 15;
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
@@ -81,7 +81,8 @@
for (Vec v: cows)
vs.add(v.sub(mean));
- Collections.sort(vs);
+ if (vs.size() > 4)
+ Collections.sort(vs); // sort only big clusters (for small clusters, to sort causes a kind of oscillation)
List<Vec> cs = new ArrayList<Vec>();
if (!vs.isEmpty())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-05-29 11:49:20
|
Revision: 1316
http://jason.svn.sourceforge.net/jason/?rev=1316&view=rev
Author: jomifred
Date: 2008-05-29 04:49:16 -0700 (Thu, 29 May 2008)
Log Message:
-----------
jason team: fix restart
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/jia/cluster.java
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-05-29 07:05:19 UTC (rev 1315)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-29 11:49:16 UTC (rev 1316)
@@ -171,7 +171,7 @@
<- .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) {
+ if (.length(LBoys) < 2 & .length(LCluster) > (.length(LBoys)+1)*5) {
!!create_herding_gr
}{
!check_small_herd_grp(Leaders)
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-05-29 07:05:19 UTC (rev 1315)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-05-29 11:49:16 UTC (rev 1316)
@@ -65,7 +65,7 @@
+!check_merge
: .my_name(Me) &
play(Me, herder, Gi) &
- .count(play(_,_,Gi), N) & N < 3 & // only merge small group
+ //.count(play(_,_,Gi), N) & N < 3 & // only merge small group
current_cluster(MyC)
<- // for all other groups
for( group_leader(Gj, L) & Me < L & L \== Me & not play(L,herdboy,Gi)) { //
Modified: trunk/applications/jason-team/src/java/jia/cluster.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-29 07:05:19 UTC (rev 1315)
+++ trunk/applications/jason-team/src/java/jia/cluster.java 2008-05-29 11:49:16 UTC (rev 1316)
@@ -13,6 +13,7 @@
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;
@@ -20,7 +21,6 @@
import arch.CowboyArch;
import arch.LocalWorldModel;
import busca.Nodo;
-import env.WorldModel;
/**
* Computes a cluster of cows for the agent
@@ -39,7 +39,7 @@
if (model == null)
return false;
- List<Location> locs = getCluster(model, WorldModel.cowPerceptionRatio, arch);
+ List<Location> locs = getCluster(model, 3, arch); //WorldModel.cowPerceptionRatio
if (args.length == 1) {
return un.unifies(args[0], new ObjectTermImpl(locs));
@@ -60,7 +60,7 @@
return false;
}
- public static List<Location> getCluster(LocalWorldModel model, int maxDist, CowboyArch arch) throws Exception {
+ public static List<Location> getClusterTest1(LocalWorldModel model, int maxDist, CowboyArch arch) throws Exception {
/*
Vs = set of all seen cows
Cs = { the cow near to the corral }
@@ -96,8 +96,53 @@
cows.remove(near);
}
- /* OLD strategy
- Vec mean = Vec.mean( cows );
+ boolean add = true;
+ while (add) {
+ add = false;
+ Iterator<Vec> i = cows.iterator();
+ while (i.hasNext()) {
+ Vec v = i.next();
+
+ Iterator<Vec> j = cs.iterator();
+ while (j.hasNext() && cs.size() < MAXCLUSTERSIZE) {
+ Vec c = j.next();
+ if (c.sub(v).magnitude() < maxDist) {
+ cs.add(v);
+ i.remove();
+ add = true;
+ break;
+ }
+ }
+ }
+
+ // do not get too big clusters
+ if (cs.size() > MAXCLUSTERSIZE)
+ break;
+ }
+ List<Location> clusterLocs = new ArrayList<Location>();
+ for (Vec v: cs) {
+ // place all cows in ref to 0,0
+ clusterLocs.add(v.getLocation(model));
+ }
+ return clusterLocs;
+ }
+
+ public static List<Location> getCluster(LocalWorldModel model, int maxDist, CowboyArch arch) throws Exception {
+ /*
+ 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();
+ List<Vec> cs = new ArrayList<Vec>();
+ Vec mean = Vec.mean( cows );
List<Vec> vs = new ArrayList<Vec>();
// place all cows in ref to mean
for (Vec v: cows)
@@ -108,13 +153,12 @@
if (!vs.isEmpty())
cs.add(vs.remove(0));
- */
boolean add = true;
while (add) {
add = false;
- Iterator<Vec> i = cows.iterator(); //vs.iterator();
+ Iterator<Vec> i = vs.iterator();
while (i.hasNext()) {
Vec v = i.next();
@@ -137,12 +181,11 @@
List<Location> clusterLocs = new ArrayList<Location>();
for (Vec v: cs) {
// place all cows in ref to 0,0
- clusterLocs.add(v.getLocation(model));
- //clusterLocs.add(v.add(mean).getLocation(model));
+ 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)
@@ -150,4 +193,3 @@
return cows;
}
}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|