|
From: <jom...@us...> - 2008-04-27 14:10:21
|
Revision: 1271
http://jason.svn.sourceforge.net/jason/?rev=1271&view=rev
Author: jomifred
Date: 2008-04-27 07:10:17 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
the creation of groups/schemes for exploration are ok
start coding the scouter (not finished)
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
trunk/applications/jason-team/src/java/jia/herd_position.java
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-04-27 13:25:39 UTC (rev 1270)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-04-27 14:10:17 UTC (rev 1271)
@@ -30,10 +30,12 @@
import java.util.logging.Logger;
import moise.oe.GoalInstance;
+import moise.oe.GroupInstance;
import moise.oe.MissionPlayer;
import moise.oe.OE;
import moise.oe.OEAgent;
import moise.oe.Permission;
+import moise.oe.RolePlayer;
import moise.oe.SchemeInstance;
import moise.os.fs.Goal;
import moise.os.fs.Goal.GoalType;
@@ -185,8 +187,9 @@
}
private void generateOrgGoalEvents() {
- for (GoalInstance gi : getMyOEAgent().getPossibleGoals()) {
- if (!alreadyGeneratedEvents.contains(gi)) {
+ OEAgent me = getMyOEAgent();
+ for (GoalInstance gi : getMyOEAgent().getPossibleGoals()) {
+ if (!alreadyGeneratedEvents.contains(gi)) {
alreadyGeneratedEvents.add(gi);
Literal l = Literal.parseLiteral(gi.getAsProlog());
@@ -203,13 +206,25 @@
// add source annot
l.addAnnot(managerSource);
- // "role(notimplemented),group(notimplemented)"+
- // TODO: add annots: role, group (percorrer as missoes do ag que
- // em GI, procurar os papel com obrigacao para essa missao)
+ // try to find the role/group of this goal
+ // (the first all resp group of the scheme where I am)
+ for (GroupInstance g: gi.getScheme().getResponsibleGroups()) {
+ for (RolePlayer rp: g.getPlayers()) {
+ if (rp.getPlayer().equals(me)) {
+ Structure role = new Structure("role");
+ role.addTerm(new Atom(rp.getRole().getId()));
+ l.addAnnot(role);
+
+ Structure group = new Structure("group");
+ group.addTerm(new Atom(rp.getGroup().getId()));
+ l.addAnnot(group);
+ }
+ }
+ }
getTS().updateEvents(new Event(new Trigger(TEOperator.add, TEType.achieve, l), Intention.EmptyInt));
if (logger.isLoggable(Level.FINE)) logger.fine("New goal: " + l);
- }
- }
+ }
+ }
}
private static final Atom aAchievementGoal = new Atom(GoalType.achievement.toString());
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-04-27 13:25:39 UTC (rev 1270)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-04-27 14:10:17 UTC (rev 1271)
@@ -119,9 +119,23 @@
/* -- plans for the goals of role scouter -- */
-+!follow_leader[scheme(Sch)]
- <- .print("ooo I should follow the leader!");
- // TODO:
++!follow_leader[scheme(Sch),group(Gr)]
+ : play(Leader, explorer, Gr)
+ <- .print("ooo I should follow the leader ",Leader);
+ ?pos(MyX,MyY,_);
+ ?ally_pos(Leader,LX,LY);
+ ?ag_perception_ratio(AGPR);
+ jia.dist(MyX, MyY, LX, LY, DistanceToLeader);
+
+ // If I am far from him, go to him
+ .if( DistanceToLeader > (AGPR * 2) -3, {
+ .print("ooo Approaching leader.");
+ -+target(LX,LY)
+ }, {
+ .print("ooo being in formation with leader.");
+ do(skip)
+ });
+
.wait("+pos(_,_,_)"); // wait next cycle
- !!follow_leader[scheme(Sch)].
+ !!follow_leader[scheme(Sch),group(Gr)].
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-27 13:25:39 UTC (rev 1270)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-27 14:10:17 UTC (rev 1271)
@@ -46,14 +46,15 @@
+end_of_simulation(_Result)
<- .abolish(group_area(_,_,_)).
-+!restart
- <- .print("*** restart ***");
++!restart.
+
+/* <- .print("*** restart ***").
//.drop_all_desires;
- .abolish(target(_,_)).
+ //.abolish(target(_,_)).
// TODO: what to do?
//!decide_target.
+*/
-
/* -- plans for the goals of all roles -- */
// get the list G of participants of the group where I play R
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-04-27 13:25:39 UTC (rev 1270)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-04-27 14:10:17 UTC (rev 1271)
@@ -14,9 +14,8 @@
+!define_formation[scheme(Sch)]
<- .print("ooo I should define the formation of my group!");
- ?my_group(G, herder);
- .length(G,NumP);
- jia.herd_position(NumP,L);
+ ?my_group_players(G, herder);
+ jia.herd_position(.length(G),L);
.print("ooo formation is ",L);
!alloc_all(G,L);
.wait("+pos(_,_,_)"); // wait next cycle
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-04-27 13:25:39 UTC (rev 1270)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-04-27 14:10:17 UTC (rev 1271)
@@ -102,7 +102,7 @@
}
public String shortActionFormat(String act) {
- if (act == null) return "";
+ if (act == null) return " ";
if (act.equals(WorldModel.Move.east.toString())) return "e ";
if (act.equals(WorldModel.Move.northeast.toString())) return "ne";
if (act.equals(WorldModel.Move.southeast.toString())) return "se";
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-27 13:25:39 UTC (rev 1270)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-27 14:10:17 UTC (rev 1271)
@@ -155,14 +155,14 @@
Vec agTarget = agsTarget;
//Location l = agTarget.add(mean).getLocation(model);
- System.out.println("....... "+dist+" antes angle "+agTarget);
+ //System.out.println("....... "+dist+" antes angle "+agTarget);
if (dist >= 0)
agTarget = agTarget.turn90CW();
else
agTarget = agTarget.turn90ACW();
Location l = findFirstFreeLocTowardsTarget(agTarget, mean.add(agsTarget), initAgTS, dist, model);
- System.out.println(" = "+dist+" result "+l);
+ //System.out.println(" = "+dist+" result "+l);
if (l != null)
r.add(pathToNearCow(model, l));
@@ -196,7 +196,7 @@
Location l = ref.getLocation(model);;
for (int s = initialSize; s <= maxSize; s++) {
l = target.newMagnitude(s).add(ref).getLocation(model);
- System.out.println("pos angle "+s+" = "+l);
+ //System.out.println("pos angle "+s+" = "+l);
if ( (!model.inGrid(l) || model.hasObject(WorldModel.OBSTACLE, l)) && lastloc != null)
return lastloc;
lastloc = l;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|