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