|
From: <jom...@us...> - 2008-05-01 21:29:40
|
Revision: 1282
http://jason.svn.sourceforge.net/jason/?rev=1282&view=rev
Author: jomifred
Date: 2008-05-01 14:29:36 -0700 (Thu, 01 May 2008)
Log Message:
-----------
several changes in jason team
fix bug in BUF (no source was added in del bel)
fix bug in clone of unnamed vars
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/src/asl/moise-common.asl
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-team/AC-Local-Dummies.mas2j
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/java/agent/SelectEvent.java
trunk/applications/jason-team/src/java/arch/ACArchitecture.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
trunk/applications/jason-team/src/java/jia/Search.java
trunk/applications/jason-team/src/java/jia/direction.java
trunk/applications/jason-team/src/java/jia/near_least_visited.java
trunk/applications/jason-team/src/java/test/MindView.java
trunk/applications/jason-team/src/team-os.xml
trunk/release-notes.txt
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/Circumstance.java
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/stdlib/drop_intention.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestLoop.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/as-unit-test/src/jason/tests/TestLoop.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -20,9 +20,9 @@
"p(1,a). p(2,a). p(3,b). p(4,b). p(6,a). "+
"+!test1 <- .while( .count(b(_),N) & N < 4, {+b(N+1) })."+
- "+!test2 <- L=4; .while( .count(b(_)) < L, { ?b(X); +b(X+1) }); jason.asunit.print(end). "+
+ "+!test2 <- L=4; .while( .count(b(_)) < L { ?b(X); +b(X+1) }); jason.asunit.print(end). "+
- "+!test3 <- L=4; .for( p(N,a) & N < L, { jason.asunit.print(N) }); jason.asunit.print(end). "+
+ "+!test3 <- L=4; .for( p(N,a) & N < L { jason.asunit.print(N) }); jason.asunit.print(end). "+
"+!test4 <- .for( .member(N, [1,3,4]), { jason.asunit.print(N) }); jason.asunit.print(end). "
);
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/asl/moise-common.asl
===================================================================
--- trunk/applications/jason-moise/src/asl/moise-common.asl 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-moise/src/asl/moise-common.asl 2008-05-01 21:29:36 UTC (rev 1282)
@@ -45,8 +45,7 @@
// when the root goal of the scheme is achieved,
// remove my missions
-+goal_state(Sch, G[root], achieved)
- : true | .print("achieved ",G) // just to avoid G as singleton var warning
++goal_state(Sch, _[root], achieved)
<- jmoise.remove_mission(Sch).
// if some scheme is finished, drop all intentions related to it.
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -23,8 +23,10 @@
import jason.mas2j.ClassParameters;
import jason.runtime.Settings;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -98,8 +100,9 @@
i.remove();
} else if (m.getSender().equals(getOrgManagerName())) {
// the content is a normal predicate
- final String content = m.getPropCont().toString();
- final boolean isTell = m.getIlForce().equals("tell");
+ final String content = m.getPropCont().toString();
+ final boolean isTell = m.getIlForce().equals("tell");
+ final boolean isUntell = m.getIlForce().equals("untell");
if (isTell && content.startsWith("scheme(")) {
i.remove();
addAsBel(content);
@@ -113,12 +116,18 @@
i.remove();
updateGoalBels(Pred.parsePred(content));
updateGoalEvt = true;
- } else if (isTell && content.startsWith("scheme_group")) {
+ } else if (content.startsWith("scheme_group")) {
i.remove();
- // this message is generated when my group becomes
- // responsible for a scheme
- Literal l = addAsBel(content);
- generateObligationPermissionEvents(l);
+ if (isTell) {
+ // this message is generated when my group becomes
+ // responsible for a scheme
+ Literal l = addAsBel(content);
+ generateObligationPermissionEvents(l);
+ } else if (isUntell) {
+ Literal l = delAsBel(content);
+ removeObligationPermissionBeliefs(l, "obligation");
+ removeObligationPermissionBeliefs(l, "permission");
+ }
} else if (isTell && content.startsWith("commitment")) {
i.remove();
addAsBel(content);
@@ -127,7 +136,7 @@
} else if (m.getIlForce().equals("untell") && content.startsWith("scheme")) {
String schId = Pred.parsePred(content).getTerm(1).toString();
- removeAchieveEvents(schId);
+ removeAchieveGoalsOfSch(schId);
removeBeliefs(schId);
}
}
@@ -152,8 +161,14 @@
getTS().getAg().addBel(l);
return l;
}
+ private Literal delAsBel(String b) throws RevisionFailedException {
+ Literal l = Literal.parseLiteral(b);
+ l.addAnnot(managerSource);
+ getTS().getAg().delBel(l);
+ return l;
+ }
- void generateObligationPermissionEvents(Pred m) throws RevisionFailedException {
+ private void generateObligationPermissionEvents(Pred m) throws RevisionFailedException {
// computes this agent obligations in the scheme
String schId = m.getTerm(0).toString();
String grId = m.getTerm(1).toString();
@@ -166,7 +181,7 @@
obligations.add(p);
Literal l = Literal.parseLiteral("obligation(" + p.getScheme().getId() + ","
+ p.getMission().getId() + ")[" + "role(" + p.getRolePlayer().getRole().getId()
- + "),group(" + p.getRolePlayer().getGroup().getGrSpec().getId() + ")]");
+ + "),group(" + p.getRolePlayer().getGroup().getId() + ")]");
l.addAnnot(managerSource);
getTS().getAg().addBel(l);
if (logger.isLoggable(Level.FINE)) logger.fine("New obligation: " + l);
@@ -178,15 +193,45 @@
if (p.getRolePlayer().getGroup().getId().equals(grId) && p.getScheme().getId().equals(schId) && !obligations.contains(p)) {
Literal l = Literal.parseLiteral("permission(" + p.getScheme().getId() + ","
+ p.getMission().getId() + ")[" + "role(" + p.getRolePlayer().getRole().getId()
- + "),group(" + p.getRolePlayer().getGroup().getGrSpec().getId() + ")]");
+ + "),group(" + p.getRolePlayer().getGroup().getId() + ")]");
l.addAnnot(managerSource);
getTS().getAg().addBel(l);
if (logger.isLoggable(Level.FINE)) logger.fine("New permission: " + l);
}
}
}
+
+
+ private void removeObligationPermissionBeliefs(Pred m, String type) throws RevisionFailedException {
+ // computes this agent obligations in the scheme
+ Term sch = m.getTerm(0);
+ Term grId = m.getTerm(1);
+
+ Structure giAnnot = new Structure("group");
+ giAnnot.addTerm(grId);
+
+ Literal obl = new Literal(type);
+ obl.addTerms(sch,new UnnamedVar());
+ obl.addAnnot(giAnnot);
+
+ // find obligation(sch,_)[group(id)]
+ Unifier un = new Unifier();
+ Iterator<Literal> i = getTS().getAg().getBB().getCandidateBeliefs(obl, un);
+ if (i != null) {
+ List<Literal> todel = new ArrayList<Literal>();
+ while (i.hasNext()) {
+ Literal inbb = i.next();
+ un.clear();
+ if (un.unifies(obl, inbb))
+ todel.add(inbb);
+ }
+ for (Literal l: todel) {
+ getTS().getAg().delBel(l);
+ }
+ }
+ }
- private void generateOrgGoalEvents() {
+ private void generateOrgGoalEvents() {
OEAgent me = getMyOEAgent();
for (GoalInstance gi : getMyOEAgent().getPossibleGoals()) {
if (!alreadyGeneratedEvents.contains(gi)) {
@@ -198,6 +243,15 @@
giID.addTerm(new Atom(gi.getScheme().getId()));
l.addAnnot(giID);
+ // add annot with mission id
+ Structure mission = new Structure("mission", 1);
+ for (MissionPlayer mp: getMyOEAgent().getMissions()) {
+ if (mp.getMission().getGoals().contains(gi.getSpec())) {
+ mission.addTerm(new Atom(mp.getMission().getId()));
+ }
+ }
+ l.addAnnot(mission);
+
// add annot with type of goal
Structure type = new Structure("type", 1);
type.addTerm(getGoalTypeAtom(gi.getSpec()));
@@ -238,7 +292,7 @@
return null;
}
- void removeAchieveEvents(String schId) {
+ void removeAchieveGoalsOfSch(String schId) {
Iterator<GoalInstance> i = alreadyGeneratedEvents.iterator();
while (i.hasNext()) {
GoalInstance gi = i.next();
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -160,6 +160,9 @@
logger.info("Received an unknown message: " + m + "!");
}
updateGUI();
+ } catch (MoiseException e) {
+ logger.log(Level.SEVERE, "Error processing '" + m + "' for " + agSender + ". "+e);
+ sendReply(agSender, m.getMsgId(), "error(\"" + e + "\")");
} catch (Exception e) {
logger.log(Level.SEVERE, "Error processing '" + m + "' for " + agSender, e);
sendReply(agSender, m.getMsgId(), "error(\"" + e + "\")");
@@ -337,15 +340,44 @@
sendReply(sender, mId, "error(\"you are not the owner of the group " + grId + ", so you can not remove it\")");
}
- currentOE.removeGroup(grId);
+ gr.checkRemove();
- String annot = "";
+ /*String annot = "";
if (gr.getGrSpec().isRoot()) {
annot = "root";
} else {
annot = "super_gr(" + gr.getSuperGroup().getId() + ")";
}
- updateMembersOE(currentOE.getAgents(), "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")[owner(" + gr.getOwner() + ")," + annot + "]", false, false);
+ */
+ //updateMembersOE(currentOE.getAgents(), "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")[owner(" + gr.getOwner() + ")," + annot + "]", false, false);
+
+ // also send untell scheme_group (if it is the case)
+ for (SchemeInstance sch: gr.getRespSchemes()) {
+ updateMembersOE(gr.getPlayers(), "scheme_group(" + sch.getId() + "," + grId + ")", false, false);
+ }
+ // untell players
+ for (RolePlayer rp: gr.getPlayers()) {
+ updateMembersOE(gr.getAgents(true), "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + gr.getId() + ")", false, false);
+ }
+
+ // send changes for subgroups of gr
+ for (GroupInstance sg: gr.getAllSubGroupsTree()) {
+ updateMembersOE(currentOE.getAgents(), "group(" + sg.getGrSpec().getId() + "," + sg.getId() + ")", false, false);
+ // also send untell scheme_group (if it is the case)
+ for (SchemeInstance sch: sg.getRespSchemes()) {
+ updateMembersOE(sg.getPlayers(), "scheme_group(" + sch.getId() + "," + sg.getId() + ")", false, false);
+ }
+ // untell players
+ for (RolePlayer rp: sg.getPlayers()) {
+ updateMembersOE(sg.getAgents(true), "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + sg.getId() + ")", false, false);
+ }
+ }
+
+ // have to remove after sending the untells
+ currentOE.removeGroup(grId);
+
+ // sent a new copy of OE
+ updateMembersOE(currentOE.getAgents(), "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")", true, false);
}
}
@@ -428,7 +460,8 @@
sendReply(sender, mId, "error(\"the scheme " + schId + " does not exist\")");
return;
}
- if (!sender.equals(sch.getOwner())) {
+
+ if (sch.getSpec().getFS().getBoolProperty("only-owner-can-remove-scheme") && !sender.equals(sch.getOwner())) {
sendReply(sender, mId, "error(\"you are not the owner of the scheme " + schId + ", so you can not change it\")");
}
Modified: trunk/applications/jason-team/AC-Local-Dummies.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-Dummies.mas2j 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/AC-Local-Dummies.mas2j 2008-05-01 21:29:36 UTC (rev 1282)
@@ -17,27 +17,27 @@
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy2 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent2, password="2"]
+ [host="localhost", port=12300, username=botagent2, password="2"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy3 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent3, password="3"]
+ [host="localhost", port=12300, username=botagent3, password="3"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy4 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent4, password="4"]
+ [host="localhost", port=12300, username=botagent4, password="4"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy5 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent5, password="5"]
+ [host="localhost", port=12300, username=botagent5, password="5"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
dummy6 dummy.asl
- [verbose=1,host="localhost", port=12300, username=botagent6, password="6"]
+ [host="localhost", port=12300, username=botagent6, password="6"]
agentArchClass arch.ACArchitecture
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","ally_pos(key,_,_)","corral(_,_,_,_)");
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-05-01 21:29:36 UTC (rev 1282)
@@ -1,4 +1,3 @@
-
/* Jason Team for the
* Multi-Agent Programming Contest 2008
* (http://cig.in.tu-clausthal.de/AgentContest)
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-05-01 21:29:36 UTC (rev 1282)
@@ -46,7 +46,7 @@
: goal(search) & cell(_,_,cow(_)) // I see cows and was searching
<- !decide_target.
-// revise target each 4 steps
+// revise target each 6 steps
+pos(Step,_,_) // new cycle
: Step mod 6 == 0
<- !decide_target.
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-05-01 21:29:36 UTC (rev 1282)
@@ -5,9 +5,6 @@
/* -- initial goals -- */
-//!test.
-//+!test <- +gsize(16,8).
-
/*
-- plans for new match
-- create the initial exploration groups and areas
@@ -17,10 +14,8 @@
/* plans for the team's groups creation */
+!create_team_group
- <- .print("oooo creating team group");
- .if( group(team,Old), {
- jmoise.remove_group(Old)
- });
+ <- .print("oooo creating new team group -- ************************************************ ");
+ !remove_org;
jmoise.create_group(team).
+group(team,GId) // agent 1 is responsible for the creation of exploration groups
@@ -28,9 +23,10 @@
<- jmoise.create_group(exploration_grp,GId);
jmoise.create_group(exploration_grp,GId);
jmoise.create_group(exploration_grp,GId).
-+group(exploration_grp,_) // compute the area of the groups
++group(exploration_grp,_) // compute the area of the groups
: .my_name(gaucho1) &
- .findall(GId, group(exploration_grp,GId), LG) &
+ group(team,TeamId) &
+ .findall(GId, group(exploration_grp,GId)[super_gr(TeamId)], LG) &
LG = [G1,G2,G3] // there are three groups
<- ?gsize(W,H);
X = math.round(((W*H)/3)/H);
@@ -49,7 +45,7 @@
: .my_name(Me) &
agent_id(Me,AgId) &
AgId mod 2 == 1 // I have an odd Id
- <- .if( .my_name(gaucho1), {
+ <- .if( .my_name(gaucho1) {
!create_team_group
});
@@ -59,7 +55,7 @@
?pos(MyX,MyY,_);
// wait others pos
- .while( .count(ally_pos(_,_,_), N) & N < 5, {
+ .while( .count(ally_pos(_,_,_), N) & N < 5 {
.print("ooo waiting others pos ");
.wait("+ally_pos(_,_,_)", 500, nofail)
});
@@ -99,7 +95,7 @@
// TODO: make a pattern for organisational maintainance goal
-+!goto_near_unvisited[scheme(Sch)]
++!goto_near_unvisited[scheme(Sch),mission(Mission)]
<- .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
@@ -108,13 +104,13 @@
jia.near_least_visited(MeX, MeY, Area, TargetX, TargetY);
-+target(TargetX, TargetY);
.wait("+pos(_,_,_)"); // wait next cycle
- !!goto_near_unvisited[scheme(Sch)].
+ !!goto_near_unvisited[scheme(Sch),mission(Mission)].
--!goto_near_unvisited[scheme(Sch)]
+-!goto_near_unvisited[scheme(Sch),mission(Mission)]
<- .current_intention(I);
.print("ooo Failure to goto_near_unvisited ",I);
.wait("+pos(_,_,_)"); // wait next cycle
- !!goto_near_unvisited[scheme(Sch)].
+ !!goto_near_unvisited[scheme(Sch),mission(Mission)].
/* -- plans for the goals of role scouter -- */
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-05-01 21:29:36 UTC (rev 1282)
@@ -43,7 +43,8 @@
+?group_area(Id,G,A) <- .wait("+group_area(Id,G,A)").
+end_of_simulation(_Result)
- <- .abolish(group_area(_,_,_)).
+ <- .abolish(group_area(_,_,_));
+ !remove_org.
+!restart.
@@ -56,19 +57,6 @@
/* -- plans for the goals of all roles -- */
-// get the list G of participants of the group where I play R
-+?my_group_players(G,R)
- <- .my_name(Me);
- play(Me,R,Gid);
- .findall(P, play(P,_,Gid), G).
-
-+!play_role(Role,Group)[source(Ag)]
- : .my_name(Me) & not play(Me,_,_) // I can not play more than one role
- <- .print("ooo Adopting role ",Role,", asked by ",Ag);
- jmoise.adopt_role(Role, Group).
-+!play_role(Role,Group)[source(Ag)]
- <- .print("ooo Can NOT adopt role ",Role,", asked by ",Ag).
-
/*
TODO: use a list given by BUF
@@ -104,12 +92,51 @@
/* -- general organisational plans -- */
+// remove all groups and schemes (only agent1 does that)
++!remove_org
+ : .my_name(gaucho1)
+ <- .if( group(team,Old) {
+ jmoise.remove_group(Old)
+ });
+
+ .for( scheme(_,SchId) {
+ jmoise.remove_scheme(SchId)
+ }).
++!remove_org.
+
+// finish the scheme if it has no more players
+// and it was created by me
++sch_players(Sch,0)
+ : .my_name(Me) & scheme(_, Sch)[owner(Me)]
+ <- jmoise.remove_scheme(Sch).
+
+
+// get the list G of participants of the group where I play R
++?my_group_players(G,R)
+ <- .my_name(Me);
+ play(Me,R,Gid);
+ .findall(P, play(P,_,Gid), G).
+
++!play_role(Role,Group)[source(Ag)]
+ <- .print("ooo Adopting role ",Role," in group ",Group,", asked by ",Ag);
+ jmoise.adopt_role(Role, Group).
+
// when I have an obligation or permission to a mission, commit to it
+obligation(Sch, Mission)
<- jmoise.commit_mission(Mission,Sch).
+permission(Sch, Mission)
<- jmoise.commit_mission(Mission,Sch).
+// when I am not obligated to a mission anymore, uncommit
+-obligation(Sch, Mission)
+ <- jmoise.remove_mission(Mission,Sch).
+-permission(Sch, Mission)
+ <- jmoise.remove_mission(Mission,Sch).
+
+// when I am not committed to a mission anymore, remove all goals based on that mission
+-commitment(Ag,Mission,Sch)
+ <- .drop_desire(_[scheme(Id),mission(Mission)]).
+
// if some scheme is finished, drop all intentions related to it.
-scheme(_Spec,Id)
<- .drop_desire(_[scheme(Id)]).
Modified: trunk/applications/jason-team/src/java/agent/SelectEvent.java
===================================================================
--- trunk/applications/jason-team/src/java/agent/SelectEvent.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/agent/SelectEvent.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -10,13 +10,13 @@
import java.util.Queue;
/**
- * change the default select event function to prefer cell(_,_,cow(_)) events.
+ * change the default select event function to prefer +cow(_,_,_) events.
*
* @author Jomi
*/
public class SelectEvent extends Agent {
- private Trigger cow = Trigger.parseTrigger("+cell(_,_,cow(_))");
+ private Trigger cow = Trigger.parseTrigger("+cow(_,_,_)");
private Unifier un = new Unifier();
public Event selectEvent(Queue<Event> events) {
Modified: trunk/applications/jason-team/src/java/arch/ACArchitecture.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/arch/ACArchitecture.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -168,12 +168,14 @@
}
// set all actions as successfully executed
List<ActionExec> feedback = getTS().getC().getFeedbackActions();
- while (!toExecute.isEmpty()) {
- ActionExec action = toExecute.poll();
- action.setResult(true);
- feedback.add(action);
- if (!toExecute.isEmpty())
- notsent.append(action.getActionTerm()+" ");
+ synchronized (feedback) {
+ while (!toExecute.isEmpty()) {
+ ActionExec action = toExecute.poll();
+ action.setResult(true);
+ feedback.add(action);
+ if (!toExecute.isEmpty())
+ notsent.append(action.getActionTerm()+" ");
+ }
}
go(); // reset the wait
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -55,7 +55,6 @@
@Override
public void initAg(String agClass, ClassParameters bbPars, String asSrc, Settings stts) throws JasonException {
super.initAg(agClass, bbPars, asSrc, stts);
-
model = new LocalWorldModel(10,10, WorldModel.agsByTeam, getTS().getAg().getBB()); // just to have a default model
gui = "yes".equals(stts.getUserParameter("gui"));
if ("yes".equals(stts.getUserParameter("write_status"))) {
@@ -116,16 +115,14 @@
// manage GUIs
if (view != null) view.dispose();
if (acView != null) acView.finish();
- if (gui) {
- view = new WorldView("Herding (view of cowboy "+(getMyId()+1)+") -- against "+opponent,model);
- }
+ if (gui) view = new WorldView("Herding (view of cowboy "+(getMyId()+1)+") -- against "+opponent,model);
+ if (writeStatusThread != null) writeStatusThread.reset();
+
if (massimBackDir != null && massimBackDir.length() > 0) {
acView = new ACViewer(massimBackDir, w, h);
acView.setPriority(Thread.MIN_PRIORITY);
acView.start();
}
- if (writeStatusThread != null)
- writeStatusThread.reset();
}
/** The perception of the corral location is removed from the percepts list
@@ -225,7 +222,7 @@
protected void addRestart() {
try {
logger.info("** Arch adding restart for "+getAgName());
- //getTS().getC().create();
+ //getTS().getC().create(); // it is terrible for pending intentions of cowboys!
getTS().getC().addAchvGoal(new Literal("restart"), Intention.EmptyInt);
lo2 = new Location(-1,-1); // to not restart again in the next cycle
} catch (Exception e) {
@@ -241,25 +238,8 @@
return l;
}
- //private static final Literal cowstoclean = Literal.parseLiteral("cell(_,_,cow(_))");
- //private boolean cleanCows = false;
-
- /*
- @Override
- public synchronized void agDidPerceive() {
- super.agDidPerceive();
- if (cleanCows) {
- try {
- getTS().getAg().abolish(cowstoclean, null);
- } catch (RevisionFailedException e) {}
- cleanCows = false;
- }
- }
- */
-
void initKnownCows() {
model.clearCows();
- //cleanCows = true;
}
//void cowPerceived(int x, int y) {
@@ -283,11 +263,14 @@
void simulationEndPerceived(String result) throws RevisionFailedException {
getTS().getAg().addBel(Literal.parseLiteral("end_of_simulation("+result+")"));
+ model = null;
playing = false;
+ if (view != null) view.dispose();
}
void setCycle(int s) {
cycle = s;
+ super.setCycleNumber(cycle);
if (view != null) view.setCycle(cycle);
if (writeStatusThread != null) writeStatusThread.go();
}
@@ -321,14 +304,14 @@
@SuppressWarnings("unchecked")
@Override
public void checkMail() {
- try {
- super.checkMail();
-
- // remove messages related to obstacles and agent_position
- // and update the model
- Iterator<Message> im = getTS().getC().getMailBox().iterator();
- while (im.hasNext()) {
- Message m = im.next();
+ super.checkMail();
+
+ // remove messages related to obstacles and agent_position
+ // and update the model
+ Iterator<Message> im = getTS().getC().getMailBox().iterator();
+ while (im.hasNext()) {
+ Message m = im.next();
+ try {
if (m.getIlForce().equals("tell-cows")) {
im.remove();
/* not used anymore
@@ -341,18 +324,21 @@
} else {
String ms = m.getPropCont().toString();
if (ms.startsWith("cell") && ms.endsWith("obstacle)") && model != null) {
- Literal p = (Literal)m.getPropCont();
+ im.remove();
+
+ Literal p = (Literal)m.getPropCont();
int x = (int)((NumberTerm)p.getTerm(0)).solve();
int y = (int)((NumberTerm)p.getTerm(1)).solve();
if (model.inGrid(x,y)) {
model.add(WorldModel.OBSTACLE, x, y);
if (acView != null) acView.addObject(WorldModel.OBSTACLE, x, y);
}
- im.remove();
//getTS().getAg().getLogger().info("received obs="+p);
} else if (ms.startsWith("my_status") && model != null) {
- // update others location
+ im.remove();
+
+ // update others location
Literal p = Literal.parseLiteral(m.getPropCont().toString());
int x = (int)((NumberTerm)p.getTerm(0)).solve();
int y = (int)((NumberTerm)p.getTerm(1)).solve();
@@ -370,13 +356,12 @@
e.printStackTrace();
}
}
- im.remove();
}
}
- }
- } catch (Exception e) {
- logger.log(Level.SEVERE, "Error checking email!",e);
- }
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Error checking email!",e);
+ }
+ }
}
public static int getAgId(String agName) {
Modified: trunk/applications/jason-team/src/java/arch/WriteStatusThread.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/arch/WriteStatusThread.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -111,7 +111,7 @@
} catch (InterruptedException e) { // no problem, quit the thread
return;
} catch (Exception e) {
- e.printStackTrace();
+ System.out.println("error getting agent status "+e);
}
}
} catch (Exception e) {
Modified: trunk/applications/jason-team/src/java/jia/Search.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Search.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/jia/Search.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -62,13 +62,13 @@
this.considerCowsAsObstacles = considerCowsAsObstacles;
this.considerRepulsionForCows = considerRepulsionForCows;
this.agArch = agArch;
- if (actions != null) {
+ if (actions != null)
this.actionsOrder = actions;
- } else {
+ else
this.actionsOrder = defaultActions;
- }
this.maxDistFromCluster = 4;
+ this.nbStates = 0;
model.getCows(); // to update the cows in model.
}
@@ -76,7 +76,7 @@
maxDistFromCluster = m;
}
- /** used normally to discover the distance from 'from' to 'to' */
+ /** used normally to discover the distance from 'from' to 'to' (or if there is path to) */
Search(LocalWorldModel m, Location from, Location to, AgArch agArch) {
this(m,from,to,null,false, false, false, false, agArch);
}
@@ -203,7 +203,7 @@
public List<Estado> sucessores() {
List<Estado> s = new ArrayList<Estado>();
- if (ia.nbStates > 50000) {
+ if (ia.nbStates > 100000) {
ia.logger.info("*** It seems I am in a loop!");
return s;
} else if (ia.agArch != null && !ia.agArch.isRunning()) {
Modified: trunk/applications/jason-team/src/java/jia/direction.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/direction.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/jia/direction.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -61,13 +61,31 @@
actionsOrder[i2] = actionsOrder[i1];
actionsOrder[i1] = temp;
- Search astar = new Search(model, from, to, actionsOrder, true, true, true, false, ts.getUserAgArch());
+ Search astar = new Search(model, from, to, actionsOrder, true, false, true, false, ts.getUserAgArch());
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
+ int fixtimes = 0;
+ while (s.search() == null && ts.getUserAgArch().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);
+ to = model.nearFree(to);
+ s = new Search(model, from, to, ts.getUserAgArch());
+ }
+
+ // run A* again
+ astar = new Search(model, from, to, actionsOrder, true, false, true, false, ts.getUserAgArch());
+ solution = astar.search();
+ }
+
if (solution != null) {
- WorldModel.Move m = astar.firstAction(solution);
- if (m != null) {
+ WorldModel.Move m = astar.firstAction(solution);
+ if (m != null)
sAction = m.toString();
- }
} else {
ts.getLogger().info("No route from "+from+" to "+to+"!"+"\n"+model);
}
Modified: trunk/applications/jason-team/src/java/jia/near_least_visited.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/near_least_visited.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/jia/near_least_visited.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -11,6 +11,8 @@
import java.util.logging.Level;
+import env.WorldModel;
+
import arch.CowboyArch;
import arch.LocalWorldModel;
@@ -46,14 +48,27 @@
Location bl = new Location(ax2, ay2);
Location n = model.getNearLeastVisited(ag, tr, bl);
- un.unifies(args[3], new NumberTermImpl(n.x));
- un.unifies(args[4], new NumberTermImpl(n.y));
- //ts.getLogger().info("at "+agx+","+agy+" to "+n.x+","+n.y);
- return true;
+ if (n != null) {
+ Search s = new Search(model, ag, n, ts.getUserAgArch());
+ while (s.search() == null && ts.getUserAgArch().isRunning()) {
+ // 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);
+ n = model.getNearLeastVisited(ag, tr, bl);
+ s = new Search(model, ag, n, ts.getUserAgArch());
+ }
+
+ un.unifies(args[3], new NumberTermImpl(n.x));
+ un.unifies(args[4], new NumberTermImpl(n.y));
+ //ts.getLogger().info("at "+agx+","+agy+" to "+n.x+","+n.y);
+ return true;
+ }
}
} catch (Throwable e) {
ts.getLogger().log(Level.SEVERE, "near_least_visited error: "+e, e);
}
return false;
}
+
+
}
Modified: trunk/applications/jason-team/src/java/test/MindView.java
===================================================================
--- trunk/applications/jason-team/src/java/test/MindView.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/java/test/MindView.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -31,15 +31,19 @@
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.File;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.JSlider;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -67,35 +71,11 @@
// Interface components
JTextPane jTA = null;
JFrame frame;
+ JSlider jHistory = null;
void initComponents() {
frame = new JFrame();
- JButton jBtNext = new JButton("Next");
- jBtNext.setEnabled(true);
- jBtNext.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- step++;
- show();
- }
- });
- }
- });
- JButton jBtPrev = new JButton("Previous");
- jBtPrev.setEnabled(true);
- jBtPrev.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- step--;
- show();
- }
- });
- }
- });
-
jTA = new JTextPane();
jTA.setEditable(false);
jTA.setContentType("text/html");
@@ -110,11 +90,55 @@
pAg.add(BorderLayout.CENTER, spTA);
- JPanel pButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
+ JButton jBtNext = new JButton("Next");
+ jBtNext.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ step++;
+ show();
+ }
+ });
+ }
+ });
+ JButton jBtPrev = new JButton("Previous");
+ jBtPrev.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ step--;
+ show();
+ }
+ });
+ }
+ });
+ JPanel pButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
pButtons.add(jBtPrev);
pButtons.add(jBtNext);
- frame.getContentPane().add(BorderLayout.SOUTH, pButtons);
+
+ JPanel pHistory = new JPanel(new BorderLayout());//new FlowLayout(FlowLayout.CENTER));
+ pHistory.setBorder(BorderFactory.createTitledBorder(BorderFactory
+ .createEtchedBorder(), "Agent History", TitledBorder.LEFT, TitledBorder.TOP));
+ jHistory = new JSlider();
+ jHistory.setMaximum(1);
+ jHistory.setMinimum(0);
+ jHistory.setValue(0);
+ jHistory.setPaintTicks(true);
+ jHistory.setPaintLabels(true);
+ jHistory.setMajorTickSpacing(10);
+ jHistory.setMinorTickSpacing(1);
+ setupSlider();
+ jHistory.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ step = (int)jHistory.getValue();
+ show();
+ }
+ });
+ pHistory.add(BorderLayout.CENTER, jHistory);
+ pHistory.add(BorderLayout.EAST, pButtons);
+
+ frame.getContentPane().add(BorderLayout.SOUTH, pHistory);
frame.getContentPane().add(BorderLayout.CENTER, pAg);
frame.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
@@ -129,8 +153,36 @@
frame.setTitle(":: Jason Mind Inspector :: "+step+" ::");
Document agState = builder.parse("tmp-ag-mind/"+step+".xml");
jTA.setText(agTransformerHtml.transform(agState));
+ jHistory.setValue(step);
} catch (Exception et) {
et.printStackTrace();
}
}
+
+ @SuppressWarnings("unchecked")
+ private void setupSlider() {
+ int size = 0;
+ for (String f: new File("tmp-ag-mind").list()) {
+ if (f.endsWith(".xml")) {
+ f = f.substring(0, f.length()-4);
+ try {
+ int n = Integer.parseInt(f);
+ if (n > size)
+ size = n;
+ } catch (Exception e) { }
+ }
+ }
+ /*File f = new File("tmp-ag-mind/"+size+".xml");
+ while (f.exists()) {
+ size++;
+ f = new File("tmp-ag-mind/"+size+".xml");
+ }
+ */
+ //Hashtable<Integer,Component> labelTable = new Hashtable<Integer,Component>();
+ //labelTable.put( 0, new JLabel("Cycle 0") );
+ //labelTable.put( size, new JLabel("Cycle "+size) );
+ //jHistory.setLabelTable( labelTable );
+ jHistory.setMaximum(size);
+ jHistory.setValue(0);
+ }
}
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/applications/jason-team/src/team-os.xml 2008-05-01 21:29:36 UTC (rev 1282)
@@ -65,6 +65,11 @@
<functional-specification>
+ <properties>
+ <property id="check-players-in-remove-responsible-group" value="false" />
+ <property id="only-owner-can-remove-scheme" value="false" />
+ </properties>
+
<scheme id="explore_sch" >
<goal id="find_cows" >
<plan operator="parallel">
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/release-notes.txt 2008-05-01 21:29:36 UTC (rev 1282)
@@ -1,4 +1,15 @@
-------------
+version 1.1.2
+-------------
+
+New features
+. internal actions to control execution: .if, .while and .for
+
+Bugs fixed:
+. BUF add annotation "source(percept)" in the perception deletion event
+
+
+-------------
version 1.1.1
-------------
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSemantics/Agent.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -479,6 +479,7 @@
l = (Literal)l.clone();
l.clearAnnots();
l.addAnnot(BeliefBase.TPercept);
+ te.setLiteral(l);
ts.getC().addEvent(new Event(te, Intention.EmptyInt));
}
Modified: trunk/src/jason/asSemantics/Circumstance.java
===================================================================
--- trunk/src/jason/asSemantics/Circumstance.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSemantics/Circumstance.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -487,8 +487,10 @@
if (getPendingActions().values().contains(getAction())) {
e.setAttribute("pending", "true");
}
- if (getFeedbackActions().contains(getAction())) {
- e.setAttribute("feedback", "true");
+ synchronized (getFeedbackActions()) {
+ if (getFeedbackActions().contains(getAction())) {
+ e.setAttribute("feedback", "true");
+ }
}
acts.appendChild(e);
}
Modified: trunk/src/jason/asSyntax/UnnamedVar.java
===================================================================
--- trunk/src/jason/asSyntax/UnnamedVar.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSyntax/UnnamedVar.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -46,7 +46,10 @@
if (hasValue()) {
return getValue().clone();
} else {
- return new UnnamedVar(getFunctor());
+ UnnamedVar newv = new UnnamedVar(getFunctor());
+ if (hasAnnot())
+ newv.addAnnots((ListTerm)this.getAnnots().clone());
+ return newv;
}
}
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-05-01 21:29:36 UTC (rev 1282)
@@ -446,16 +446,17 @@
/* List of terms */
-List terms() : { List listTerms = new ArrayList(); Term v; }
+List terms() : { List listTerms = new ArrayList(); Term v; Object o; }
{
v=term() { listTerms.add(v); }
( "," v=term() { listTerms.add(v); }
+ | o=plan_body_term() { listTerms.add(o); }
)*
{ return listTerms; }
}
-Term term() : { Object o;}
+Term term() : { Object o; }
{
( o=list()
| o=plan_body_term()
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -623,12 +623,13 @@
/* List of terms */
final public List terms() throws ParseException {
- List listTerms = new ArrayList(); Term v;
+ List listTerms = new ArrayList(); Term v; Object o;
v = term();
listTerms.add(v);
label_9:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 27:
case 41:
;
break;
@@ -636,9 +637,21 @@
jj_la1[26] = jj_gen;
break label_9;
}
- jj_consume_token(41);
- v = term();
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case 41:
+ jj_consume_token(41);
+ v = term();
listTerms.add(v);
+ break;
+ case 27:
+ o = plan_body_term();
+ listTerms.add(o);
+ break;
+ default:
+ jj_la1[27] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
}
{if (true) return listTerms;}
throw new Error("Missing return statement in function");
@@ -669,7 +682,7 @@
o = log_expr();
break;
default:
- jj_la1[27] = jj_gen;
+ jj_la1[28] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -703,7 +716,7 @@
;
break;
default:
- jj_la1[28] = jj_gen;
+ jj_la1[29] = jj_gen;
break label_10;
}
jj_consume_token(41);
@@ -727,18 +740,18 @@
last = last.concat((ListTerm)f);
break;
default:
- jj_la1[29] = jj_gen;
+ jj_la1[30] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
- jj_la1[30] = jj_gen;
+ jj_la1[31] = jj_gen;
;
}
break;
default:
- jj_la1[31] = jj_gen;
+ jj_la1[32] = jj_gen;
;
}
jj_consume_token(44);
@@ -770,7 +783,7 @@
o = string();
break;
default:
- jj_la1[32] = jj_gen;
+ jj_la1[33] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -789,7 +802,7 @@
{if (true) return new LogExpr((LogicalFormula)t1,LogicalOp.or,(LogicalFormula)t2);}
break;
default:
- jj_la1[33] = jj_gen;
+ jj_la1[34] = jj_gen;
;
}
{if (true) return t1;}
@@ -806,7 +819,7 @@
{if (true) return new LogExpr((LogicalFormula)t1,LogicalOp.and,(LogicalFormula)t2);}
break;
default:
- jj_la1[34] = jj_gen;
+ jj_la1[35] = jj_gen;
;
}
{if (true) return t1;}
@@ -837,7 +850,7 @@
{if (true) return t;}
break;
default:
- jj_la1[35] = jj_gen;
+ jj_la1[36] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -873,7 +886,7 @@
op1 = string();
break;
default:
- jj_la1[36] = jj_gen;
+ jj_la1[37] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -920,7 +933,7 @@
operator = RelationalOp.literalBuilder;
break;
default:
- jj_la1[37] = jj_gen;
+ jj_la1[38] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -948,7 +961,7 @@
op2 = plan_body_term();
break;
default:
- jj_la1[38] = jj_gen;
+ jj_la1[39] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -959,7 +972,7 @@
{if (true) return new RelExpr((Term)op1, operator, (Term)op2);}
break;
default:
- jj_la1[39] = jj_gen;
+ jj_la1[40] = jj_gen;
;
}
{if (true) return op1;}
@@ -984,7 +997,7 @@
op = ArithmeticOp.minus;
break;
default:
- jj_la1[40] = jj_gen;
+ jj_la1[41] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -998,7 +1011,7 @@
{if (true) return new ArithExpr((NumberTerm)t1, op, (NumberTerm)t2);}
break;
default:
- jj_la1[41] = jj_gen;
+ jj_la1[42] = jj_gen;
;
}
{if (true) return t1;}
@@ -1032,7 +1045,7 @@
op = ArithmeticOp.mod;
break;
default:
- jj_la1[42] = jj_gen;
+ jj_la1[43] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1046,7 +1059,7 @@
{if (true) return new ArithExpr((NumberTerm)t1, op, (NumberTerm)t2);}
break;
default:
- jj_la1[43] = jj_gen;
+ jj_la1[44] = jj_gen;
;
}
{if (true) return t1;}
@@ -1071,7 +1084,7 @@
{if (true) return new ArithExpr((NumberTerm)t1, op, (NumberTerm)t2);}
break;
default:
- jj_la1[44] = jj_gen;
+ jj_la1[45] = jj_gen;
;
}
{if (true) return t1;}
@@ -1117,7 +1130,7 @@
{if (true) return t;}
break;
default:
- jj_la1[45] = jj_gen;
+ jj_la1[46] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1152,7 +1165,7 @@
v = new UnnamedVar(K.image);
break;
default:
- jj_la1[46] = jj_gen;
+ jj_la1[47] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
@@ -1162,7 +1175,7 @@
v.setAnnots(lt);
break;
default:
- jj_la1[47] = jj_gen;
+ jj_la1[48] = jj_gen;
;
}
{if (true) return v;}
@@ -1235,7 +1248,7 @@
public boolean lookingAhead = false;
private boolean jj_semLA;
private int jj_gen;
- final private int[] jj_la1 = new int[48];
+ final private int[] jj_la1 = new int[49];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static {
@@ -1243,10 +1256,10 @@
jj_la1_1();
}
private static void jj_la1_0() {
- jj_la1_0 = new int[] {0x8000000,0x10cb00,0x8000000,0x80000000,0x8000000,0x10000,0x10cb00,0x8000000,0x8000000,0x20000000,0x10000,0x0,0x0,0x0,0x80000000,0x80000000,0x30cb80,0x0,0x0,0x80000000,0x80000000,0x800,0x10cb00,0x10c000,0x0,0x0,0x0,0x83acf80,0x0,0x200080,0x0,0x3acb80,0x3acb80,0x0,0x0,0x3acf80,0x3acb80,0x0,0x83acb80,0x0,0x0,0x0,0x3000,0x3000,0x0,0x32cb80,0x200080,0x0,};
+ jj_la1_0 = new int[] {0x8000000,0x10cb00,0x8000000,0x80000000,0x8000000,0x10000,0x10cb00,0x8000000,0x8000000,0x20000000,0x10000,0x0,0x0,0x0,0x80000000,0x80000000,0x30cb80,0x0,0x0,0x80000000,0x80000000,0x800,0x10cb00,0x10c000,0x0,0x0,0x8000000,0x8000000,0x83acf80,0x0,0x200080,0x0,0x3acb80,0x3acb80,0x0,0x0,0x3acf80,0x3acb80,0x0,0x83acb80,0x0,0x0,0x0,0x3000,0x3000,0x0,0x32cb80,0x200080,0x0,};
}
private static void jj_la1_1() {
- jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x1,0x2,0xc,0x10,0x10,0x0,0x20,0x4,0x5c,0x5c,0x0,0x0,0x0,0x80,0x400,0x200,0x488,0x200,0x400,0x800,0x488,0x488,0x800,0x2000,0x88,0x88,0x3fc000,0x488,0x3fc000,0xc,0xc,0xc00000,0xc00000,0x1000000,0x88,0x0,0x400,};
+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x1,0x2,0xc,0x10,0x10,0x0,0x20,0x4,0x5c,0x5c,0x0,0x0,0x0,0x80,0x400,0x200,0x200,0x488,0x200,0x400,0x800,0x488,0x488,0x800,0x2000,0x88,0x88,0x3fc000,0x488,0x3fc000,0xc,0xc,0xc00000,0xc00000,0x1000000,0x88,0x0,0x400,};
}
final private JJCalls[] jj_2_rtns = new JJCalls[1];
private boolean jj_rescan = false;
@@ -1261,7 +1274,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1274,7 +1287,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1284,7 +1297,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1294,7 +1307,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1303,7 +1316,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1312,7 +1325,7 @@
token = new Token();
jj_ntk = -1;
jj_gen = 0;
- for (int i = 0; i < 48; i++) jj_la1[i] = -1;
+ for (int i = 0; i < 49; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
@@ -1431,7 +1444,7 @@
la1tokens[jj_kind] = true;
jj_kind = -1;
}
- for (int i = 0; i < 48; i++) {
+ for (int i = 0; i < 49; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
Modified: trunk/src/jason/stdlib/drop_intention.java
===================================================================
--- trunk/src/jason/stdlib/drop_intention.java 2008-04-30 17:21:29 UTC (rev 1281)
+++ trunk/src/jason/stdlib/drop_intention.java 2008-05-01 21:29:36 UTC (rev 1282)
@@ -81,34 +81,39 @@
}
public void dropInt(Circumstance C, Literal l, Unifier un) {
+ Unifier bak = un.copy();
+
Trigger g = new Trigger(TEOperator.add, TEType.achieve, l);
-
for (Intention i: C.getIntentions()) {
- if (i.hasTrigger(g, un.copy())) {
+ if (i.hasTrigger(g, un)) {
C.removeIntention(i);
+ un = bak.copy();
}
}
// intention may be suspended in E
for (Event e: C.getEvents()) {
Intention i = e.getIntention();
- if (i != null && i.hasTrigger(g, un.copy())) {
+ if (i != null && i.hasTrigger(g, un)) {
C.removeEvent(e);
+ un = bak.copy();
}
}
// intention may be suspended in PA! (in the new semantics)
for (ActionExec a: C.getPendingActions().values()) {
Intention i = a.getIntention();
- if (i.hasTrigger(g, un.copy())) {
+ if (i.hasTrigger(g, un)) {
C.dropPendingAction(i);
+ un = bak.copy();
}
}
// intention may be suspended in PI! (in the new semantics)
for (Intention i: C.getPendingIntentions().values()) {
- if (i != null && i.hasTrigger(g, un.copy())) {
+ if (i != null && 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.
|