|
From: <jom...@us...> - 2008-10-21 14:27:02
|
Revision: 1400
http://jason.svn.sourceforge.net/jason/?rev=1400&view=rev
Author: jomifred
Date: 2008-10-21 14:26:54 +0000 (Tue, 21 Oct 2008)
Log Message:
-----------
jmoise: update jmoise OrgArch
jmoise: allow the creation of groups/schemes with specific names
jason: fix problem in tell with content as atom
Modified Paths:
--------------
trunk/applications/jason-moise/example/moise-tutorial/lucio.asl
trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java
trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j
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-moise/src/jmoise/create_group.java
trunk/applications/jason-moise/src/jmoise/create_scheme.java
trunk/src/asl/kqmlPlans.asl
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/VarTerm.java
Removed Paths:
-------------
trunk/applications/jason-moise/example/moise-tutorial/jojOS.xml
Deleted: trunk/applications/jason-moise/example/moise-tutorial/jojOS.xml
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/jojOS.xml 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/example/moise-tutorial/jojOS.xml 2008-10-21 14:26:54 UTC (rev 1400)
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<?xml-stylesheet href="os.xsl" type="text/xsl" ?>
-
-<organisational-specification
-
- id="joj"
- os-version="0.6"
-
- xmlns='http://moise.sourceforge.net/os'
- xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
- xsi:schemaLocation='http://moise.sourceforge.net/os
- http://moise.sourceforge.net/xml/os.xsd'>
-
- <structural-specification>
- <role-definitions>
- <role id="player" />
- <role id="coach" />
- <role id="middle"> <extends role="player"/> </role>
- <role id="leader"> <extends role="player"/> </role>
- <role id="back"> <extends role="player"/> </role>
- <role id="goalkeeper"> <extends role="back"/> </role>
- <role id="attacker"> <extends role="player"/> </role>
- </role-definitions>
-
- <group-specification id="team">
- <roles>
- <role id="coach" min="1" max="2"/>
- </roles>
- <links>
- <link from="leader" to="player" type="authority"
- scope="inter-group" extends-sub-groups="true" bi-dir="false"/>
- <link from="coach" to="player" type="authority"
- scope="inter-group" extends-sub-groups="true" bi-dir="false"/>
- <link from="player" to="player" type="communication"
- scope="inter-group" extends-sub-groups="true" bi-dir="false"/>
- <link from="player" to="coach" type="communication"
- scope="inter-group" extends-sub-groups="true" bi-dir="false"/>
- </links>
- <sub-groups>
-
- <group-specification id="attack" min="1" max="1">
- <roles>
- <role id="middle" min="5" max="5" />
- <role id="leader" min="0" max="1"/>
- <role id="attacker" min="2" max="2" />
- </roles>
- <formation-constraints>
- <compatibility from="middle" to="leader" type="compatibility"
- scope="intra-group" extends-sub-groups="false"
- bi-dir="true"/>
- </formation-constraints>
- </group-specification>
-
- <group-specification id="defense" min="1" max="1">
- <roles>
- <role id="leader" min="0" max="1" />
- <role id="goalkeeper" min="1" max="1" />
- <role id="back" min="3" max="3" />
- </roles>
- <links>
- <link from="goalkeeper" to="back" type="authority"
- scope="intra-group" extends-sub-groups="false"
- bi-dir="false"/>
- </links>
- <formation-constraints>
- <compatibility from="back" to="leader" type="compatibility"
- scope="intra-group" extends-sub-groups="false"
- bi-dir="true"/>
- </formation-constraints>
- </group-specification>
- </sub-groups>
-
- <formation-constraints>
- <!-- sub-groups scope cardinality -->
- <cardinality min="1" max="1" object="role" id="leader"/>
- </formation-constraints>
- </group-specification>
- </structural-specification>
-
-
- <functional-specification>
- <scheme id="sideAttack" >
- <goal id="scoreGoal" min="1">
- <plan operator="sequence">
- <goal id="g1" min="1" ds="get the ball" />
- <goal id="g2" ds="to be well placed">
- <plan operator="parallel">
- <goal id="g7" min="1" ds="go toward the opponent's field" />
- <goal id="g8" min="1" ds="be placed in the middle field" />
- <goal id="g9" min="1" ds="be placed in the opponent's goal area" />
- </plan>
- </goal>
- <goal id="g3" min="1" ds="kick the ball to the m2Ag" >
- <argument id="M2Ag" />
- </goal>
- <goal id="g4" min="1" ds="go to the opponent's back line" />
- <goal id="g5" min="1" ds="kick the ball to the goal area" />
- <goal id="g6" min="1" ds="shot at the opponent's goal" />
- </plan>
- </goal>
-
- <mission id="m1" min="1" max="1">
- <goal id="g1" />
- <goal id="g3" />
- <goal id="g7" />
- </mission>
- <mission id="m2" min="1" max="1">
- <goal id="g8" />
- <goal id="g4" />
- <goal id="g5" />
- </mission>
- <mission id="m3" min="1" max="1">
- <goal id="g9" />
- <goal id="g6" />
- </mission>
- </scheme>
- </functional-specification>
-
- <deontic-specification>
- <deontic-relation type="permission" role="back" mission="m1" />
- <deontic-relation type="obligation" role="middle" mission="m2" />
- <deontic-relation type="obligation" role="attacker" mission="m3" />
- </deontic-specification>
-</organisational-specification>
-
Modified: trunk/applications/jason-moise/example/moise-tutorial/lucio.asl
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/lucio.asl 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/example/moise-tutorial/lucio.asl 2008-10-21 14:26:54 UTC (rev 1400)
@@ -2,3 +2,6 @@
+!do(X) <- .print("doing ",X); X; gui.list_bels.
++!wtitle[scheme(S)] <- jmoise.set_goal_state(S,wtitle,satisfied).
++!wabs[scheme(S)] <- jmoise.set_goal_state(S,wabs,satisfied).
++!wsectitles[scheme(S)] <- jmoise.set_goal_state(S,wsectitles,satisfied).
Modified: trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java 2008-10-21 14:26:54 UTC (rev 1400)
@@ -27,6 +27,8 @@
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
+import moise.oe.GoalInstance;
+
import jmoise.OrgAgent;
public class OrgAgentGUI extends OrgAgent {
@@ -43,24 +45,21 @@
frame.setVisible(false);
}
- JTextArea bels = new JTextArea(20,50);
+ JTextArea bels = new JTextArea(20,50);
JTextField args = new JTextField(30);
JFrame frame;
- String[][] actions = { { "create_group", "g1,wpgroup" },
+ String[][] actions = { { "create_group", "gr_name(g1),wpgroup" },
{ "remove_group", "g1" },
{ "adopt_role", "editor,g1" },
- { "adopt_role", "writer,g1" },
- { "remove_role", "role,groupId" },
- { "create_scheme", "p1, writePaperSch, [g1]" },
+ { "remove_role", "editor,g1" },
+ { "create_scheme", "sch_name(p1), writePaperSch, [g1]" },
{ "abort_scheme", "schemeId" },
- { "remove_scheme", "schemeId" },
+ { "remove_scheme", "p1" },
{ "add_responsible_group", "schemeId, groupId" },
{ "commit_mission", "mManager, p1" },
- { "commit_mission", "mColaborator, p1" },
- { "commit_mission", "mBib, p1" },
- { "remove_mission", "[missionId,] SchemeId" },
- { "set_goal_state", "p1, goalId, state" }
+ { "remove_mission", "p1" },
+ { "set_goal_state", "p1, goalId, satisfied" }
};
protected void startGUI() {
@@ -156,10 +155,16 @@
}
public void listBels() {
- bels.setText("");
+ bels.setText("--- beliefs ---\n");
for (Literal b: getTS().getAg().getBB()) {
bels.append(b+"\n");
}
+ if (getOE() != null) {
+ bels.append("\n--- goals --- \n");
+ for (GoalInstance gi : getMyOEAgent().getPossibleGoals()) {
+ bels.append(gi+"\n");
+ }
+ }
}
Modified: trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j 2008-10-21 14:26:54 UTC (rev 1400)
@@ -1,7 +1,7 @@
MAS write_paper {
infrastructure: Centralised
agents:
- orgManager [osfile="../writePaper/wp-os.xml",gui=yes] // jojOS
+ orgManager [osfile="../writePaper/wp-os.xml",gui=yes]
agentArchClass jmoise.OrgManager;
marcos agentArchClass gui.OrgAgentGUI;
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-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/src/asl/moise-common.asl 2008-10-21 14:26:54 UTC (rev 1400)
@@ -21,10 +21,11 @@
// 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).
-
+*/
/* Deontic events */
@@ -40,7 +41,14 @@
// when the root goal of the scheme is achieved,
// remove my missions
+goal_state(Sch, _[root], achieved)
- <- jmoise.remove_mission(Sch).
+ <- jmoise.remove_mission(Sch);
+ .my_name(Me);
+ if (scheme(_,Sch)[owner(Me)]) {
+ if (not sch_players(Sch,0)) {
+ .wait("+sch_players(Sch,0)", 1000, _)
+ };
+ jmoise.remove_scheme(Sch)
+ }.
// if some scheme is finished, drop all intentions related to it.
-scheme(_Spec,Id)
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-21 14:26:54 UTC (rev 1400)
@@ -1,6 +1,7 @@
package jmoise;
-import static jason.asSyntax.ASSyntax.*;
+import static jason.asSyntax.ASSyntax.createLiteral;
+import static jason.asSyntax.ASSyntax.createStructure;
import jason.JasonException;
import jason.RevisionFailedException;
import jason.architecture.AgArch;
@@ -98,97 +99,65 @@
super.checkMail(); // get the messages from arch to circumstance
Circumstance C = getTS().getC();
- Iterator<Message> i = C.getMailBox().iterator();
- boolean updateGoalBels = false;
- boolean updateGoalEvt = false;
- while (i.hasNext()) {
- try {
+ Iterator<Message> i = C.getMailBox().iterator();
+
+ boolean shouldUpdate = false;
+ try {
+ while (i.hasNext()) {
Message m = i.next();
- // check if content is and OE
- if (m.getPropCont() instanceof OE) {
- currentOE = (OE) m.getPropCont();
- updateBB();
+
+ // check if content comes from orgManager
+ if (m.getSender().equals(getOrgManagerName())) {
i.remove();
- } else if (m.getSender().equals(getOrgManagerName())) {
- // the content is a normal predicate
- final String content = m.getPropCont().toString();
-
- // test if it is the result of some org action
- if (m.getInReplyTo() != null) {
- // find the intention
- Intention pi = C.getPendingIntentions().remove("om/"+m.getInReplyTo());
- if (pi != null) {
- i.remove();
- resumeIntention(pi, content, C);
+ if (m.getPropCont() instanceof OE) {
+ currentOE = (OE) m.getPropCont();
+ shouldUpdate = true;
+ } else {
+ // the content is a normal predicate
+ final String content = m.getPropCont().toString();
+
+ // test if it is the result of some org action
+ if (m.getInReplyTo() != null) {
+ // find the intention
+ Intention pi = C.getPendingIntentions().remove("om/"+m.getInReplyTo());
+ if (pi != null) {
+ resumeIntention(pi, content, C);
+ }
}
- } else {
- // add all tells directly in the memory
- if (m.getIlForce().equals("tell")) {
- i.remove();
- if (content.startsWith("goal_state")) {
- // the state of a scheme i belong to has changed
- // add all goals of the scheme in BB
- updateGoalBels = true;
- updateGoalEvt = true;
- // Note: must change all goals, because the state of others may also change (waiting->possible)
- } else {
- Literal cl = addAsBel(content);
-
- if (content.startsWith("scheme_group")) {
- // this message is generated when my group becomes
- // responsible for a scheme
- generateObligationPermissionEvents(cl);
- } else if (content.startsWith("commitment")) {
- // add all goals of the scheme in BB
- updateGoalBels = true;
- // I need to generate AS Triggers like !<orggoal> since some scheme becomes well formed
- updateGoalEvt = true;
- }
- }
-
- } else if ( m.getIlForce().equals("untell") ) {
- i.remove();
- Literal cl = delAsBel(content);
-
- if (content.startsWith("scheme_group")) {
- Term sch = cl.getTerm(0);
- Term gr = cl.getTerm(1);
- removeObligationPermissionBeliefs(sch, gr, "obligation");
- removeObligationPermissionBeliefs(sch, gr, "permission");
- } else if (content.startsWith("scheme")) {
- String schId = cl.getTerm(1).toString();
- cleanGoalsOfSch(schId);
- removeBeliefs(schId);
- } else if (content.startsWith("commitment")) {
- // if I remove my commit, remove the goals from BB
- String schId = cl.getTerm(2).toString();
- SchemeInstance sch = currentOE.findScheme(schId);
- if (sch != null && !sch.isPlayer(getMyOEAgent())) {
- cleanGoalsOfSch(schId);
- removeBeliefs(schId);
- }
- }
- }
}
}
- } catch (Exception e) {
- logger.log(Level.SEVERE, "Error!", e);
- }
- } // while
- try {
- if (updateGoalBels)
- updateGoalBels();
- if (updateGoalEvt)
- generateOrgGoalEvents();
+ } // while
+
+ if (shouldUpdate)
+ updateBB(3);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error!", e);
}
+
}
- /** update the bel base according to the current OE */
- void updateBB() throws RevisionFailedException {
-
+ /** update the bel base according to the current OE */
+ void updateBB(int n) throws RevisionFailedException, ParseException {
+ if (n == 0) {
+ logger.log(Level.SEVERE, "**** too much concurrent modification", new Exception());
+ return;
+ }
+ try {
+ updateGroup();
+ updateRolePlayer();
+ updateScheme();
+ updateSchemeGroup();
+ updatePermissionsObligations();
+ updateCommitments();
+ updateGoalBels(); // add all goals of the scheme in BB
+ generateOrgGoalEvents(); // I need to generate AS Triggers like !<orggoal> since some scheme becomes well formed
+ } catch (ConcurrentModificationException e) {
+ updateBB(n-1); // try again
+ }
+ }
+
+ private void updateGroup() throws RevisionFailedException {
// update "play"
List<Literal> toAdd = new ArrayList<Literal>();
@@ -204,9 +173,11 @@
toAdd.add(l);
}
orgBUF(toAdd, groupLiteral);
-
+ }
+
+ private void updateRolePlayer() throws RevisionFailedException {
// create list of players
- toAdd.clear();
+ List<Literal> toAdd = new ArrayList<Literal>();
for (RolePlayer myrole: getMyOEAgent().getRoles()) { // for all my groups
for (RolePlayer rp: myrole.getGroup().getPlayers()) { // for player of the group I play some role
Literal l = createLiteral("play", new Atom(rp.getPlayer().getId()), new Atom(rp.getRole().getId()), new Atom(rp.getGroup().getId()));
@@ -215,13 +186,79 @@
}
}
orgBUF(toAdd, playLiteral);
+ }
+
+ private void updateScheme() throws RevisionFailedException, ParseException {
+ // create list of scheme
+ List<Literal> toAdd = new ArrayList<Literal>();
+ for (SchemeInstance sch: currentOE.getSchemes()) {
+ Literal l = createLiteral("scheme", new Atom(sch.getSpec().getId()), new Atom(sch.getId()));
+ l.addAnnots(createStructure("owner", new Atom(sch.getOwner().getId())), managerSource);
+ toAdd.add(l);
+
+ if (sch.getOwner().equals(getMyOEAgent())) {
+ // update the number of players
+ getTS().getAg().delBel(createLiteral( "sch_players", new Atom(sch.getId()), new UnnamedVar()));
+ getTS().getAg().addBel(createLiteral( "sch_players", new Atom(sch.getId()), ASSyntax.createNumber(sch.getPlayersQty())));
+ }
+ }
+ List<Literal> deleted = orgBUF(toAdd, schemeLiteral);
+ for (Literal l: deleted) {
+ cleanGoalsOfSch(l.getTerm(1).toString());
+ removeBeliefs((Atom)l.getTerm(1));
+ }
}
+
+ private void updateSchemeGroup() throws RevisionFailedException {
+ // create list of scheme_group
+ List<Literal> toAdd = new ArrayList<Literal>();
+ for (RolePlayer myrole: getMyOEAgent().getRoles()) { // for all my groups
+ for (SchemeInstance sch : myrole.getGroup().getRespSchemes()) { // for all scheme they are responsible for
+ Literal l = createLiteral("scheme_group", new Atom(sch.getId()), new Atom(myrole.getGroup().getId()));
+ l.addAnnot(managerSource);
+ toAdd.add(l);
+ }
+ }
+ orgBUF(toAdd, schemeGroupLiteral);
+ }
- private void orgBUF(List<Literal> toAdd, PredicateIndicator bel) throws RevisionFailedException {
+ private void updatePermissionsObligations() throws RevisionFailedException {
+ // create list of obligations/permissions
+ Set<Permission> obligations = new HashSet<Permission>();
+ List<Literal> toAdd = new ArrayList<Literal>();
+ toAdd = createObligation(obligations);
+ orgBUF(toAdd, obligationLiteral);
+ toAdd.clear();
+ toAdd = createPermission(obligations);
+ orgBUF(toAdd, permissionLiteral);
+ }
+
+ private void updateCommitments() throws RevisionFailedException {
+ List<Literal> toAdd = new ArrayList<Literal>();
+ for (MissionPlayer mymission: getMyOEAgent().getMissions()) {
+ for (MissionPlayer mp: mymission.getScheme().getPlayers()) {
+ Literal l = createLiteral("commitment", new Atom(mp.getPlayer().getId()), new Atom(mp.getMission().getId()), new Atom(mp.getScheme().getId()));
+ l.addAnnot(managerSource);
+ toAdd.add(l);
+ }
+ }
+ List<Literal> deleted = orgBUF(toAdd, commitmentLiteral);
+
+ for (Literal l: deleted) {
+ String schId = l.getTerm(2).toString();
+ SchemeInstance sch = currentOE.findScheme(schId);
+ if (sch != null && !sch.isPlayer(getMyOEAgent())) {
+ cleanGoalsOfSch(schId);
+ removeBeliefs((Atom)l.getTerm(2));
+ }
+ }
+ }
+
+ private List<Literal> orgBUF(List<Literal> toAdd, PredicateIndicator bel) throws RevisionFailedException {
+ List<Literal> toDel = new ArrayList<Literal>();
try {
Agent ag = getTS().getAg();
- List<Literal> toDel = new ArrayList<Literal>();
// remove old bels
Iterator<Literal> i = ag.getBB().getCandidateBeliefs(bel);
@@ -229,11 +266,13 @@
while (i.hasNext()) {
Literal l = i.next();
- // if this play in not in the add list, it should be removed
boolean isInOE = false;
- for (Literal p: toAdd) {
+ Iterator<Literal> ip = toAdd.iterator();
+ while (ip.hasNext()) {
+ Literal p = ip.next();
if (p.equalsAsStructure(l)) {
isInOE = true;
+ ip.remove();
break;
}
}
@@ -245,26 +284,12 @@
for (Literal l: toDel)
ag.delBel(l);
- // add new players
for (Literal l: toAdd)
ag.addBel(l);
} catch (ConcurrentModificationException e) {}
+ return toDel;
}
-
- private Literal addAsBel(String b) throws RevisionFailedException {
- Literal l = Literal.parseLiteral(b);
- l.addAnnot(managerSource);
- 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;
- }
-
private void resumeIntention(Intention pi, String content, Circumstance C) {
pi.setSuspended(false);
C.addIntention(pi); // add it back in I
@@ -292,63 +317,46 @@
}
- private void generateObligationPermissionEvents(Literal m) throws RevisionFailedException {
- // computes this agent obligations in the scheme
- String schId = m.getTerm(0).toString();
- String grId = m.getTerm(1).toString();
- Set<Permission> obligations = new HashSet<Permission>();
- if (logger.isLoggable(Level.FINE)) logger.fine("Computing obl/per for " + m + " in obl=" + getMyOEAgent().getObligations() + " and per=" + getMyOEAgent().getPermissions());
+ private List<Literal> createObligation(Set<Permission> obligations) {
+ List<Literal> r = new ArrayList<Literal>();
+
+ if (logger.isLoggable(Level.FINE)) logger.fine("Computing obl with " + getMyOEAgent().getObligations());
// obligations
for (Permission p : getMyOEAgent().getObligations()) {
- if (p.getRolePlayer().getGroup().getId().equals(grId) && p.getScheme().getId().equals(schId)) {
- obligations.add(p);
- Literal l = Literal.parseLiteral("obligation(" + p.getScheme().getId() + ","
- + p.getMission().getId() + ")[" + "role(" + p.getRolePlayer().getRole().getId()
- + "),group(" + p.getRolePlayer().getGroup().getId() + ")]");
- l.addAnnot(managerSource);
- getTS().getAg().addBel(l);
- if (logger.isLoggable(Level.FINE)) logger.fine("New obligation: " + l);
- }
+ obligations.add(p);
+ Literal l = createLiteral("obligation",
+ new Atom(p.getScheme().getId()),
+ new Atom(p.getMission().getId()));
+ l.addAnnots(createStructure("role", new Atom(p.getRolePlayer().getRole().getId())),
+ createStructure("group", new Atom(p.getRolePlayer().getGroup().getId())),
+ managerSource);
+ r.add(l);
+ if (logger.isLoggable(Level.FINE)) logger.fine("New obligation: " + l);
}
+ return r;
+ }
+
+ private List<Literal> createPermission(Set<Permission> obligations) {
+ List<Literal> r = new ArrayList<Literal>();
+
+ if (logger.isLoggable(Level.FINE)) logger.fine("Computing per with "+ getMyOEAgent().getPermissions());
// permissions
for (Permission p : getMyOEAgent().getPermissions()) {
- 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().getId() + ")]");
- l.addAnnot(managerSource);
- getTS().getAg().addBel(l);
+ if (!obligations.contains(p)) {
+ Literal l = createLiteral("permission",
+ new Atom(p.getScheme().getId()),
+ new Atom(p.getMission().getId()));
+ l.addAnnots(createStructure("role", new Atom(p.getRolePlayer().getRole().getId())),
+ createStructure("group", new Atom(p.getRolePlayer().getGroup().getId())),
+ managerSource);
+ r.add(l);
if (logger.isLoggable(Level.FINE)) logger.fine("New permission: " + l);
}
}
+ return r;
}
-
-
- private void removeObligationPermissionBeliefs(Term sch, Term gr, String type) throws RevisionFailedException {
- // computes this agent obligations in the scheme
- Structure giAnnot = new Structure("group");
- giAnnot.addTerm(gr);
-
- Literal obl = ASSyntax.createLiteral(type, sch, new UnnamedVar()).addAnnots(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() {
OEAgent me = getMyOEAgent();
@@ -423,7 +431,7 @@
private static final PredicateIndicator groupLiteral = new PredicateIndicator("group", 2);
private static final PredicateIndicator playLiteral = new PredicateIndicator("play", 3);
-
+ private static final PredicateIndicator schemeLiteral = new PredicateIndicator("scheme", 2);
private static final PredicateIndicator obligationLiteral = new PredicateIndicator("obligation", 2);
private static final PredicateIndicator permissionLiteral = new PredicateIndicator("permission", 2);
private static final PredicateIndicator schemeGroupLiteral = new PredicateIndicator("scheme_group", 2);
@@ -432,15 +440,14 @@
private static final PredicateIndicator commitmentLiteral = new PredicateIndicator("commitment", 3);
/** removes all bels related to a Scheme */
- void removeBeliefs(String schId) throws RevisionFailedException {
+ private void removeBeliefs(Atom schId) throws RevisionFailedException {
Agent ag = getTS().getAg();
- Atom aSchId = new Atom(schId);
- ag.abolish(buildLiteralToCleanBB(aSchId, obligationLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(aSchId, permissionLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(aSchId, schemeGroupLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(aSchId, goalStateLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(aSchId, schPlayersLiteral, false), null);
- ag.abolish(buildLiteralToCleanBB(aSchId, commitmentLiteral, true), null);
+ //ag.abolish(buildLiteralToCleanBB(aSchId, obligationLiteral, false), null);
+ //ag.abolish(buildLiteralToCleanBB(aSchId, permissionLiteral, false), null);
+ //ag.abolish(buildLiteralToCleanBB(aSchId, schemeGroupLiteral, false), null);
+ ag.abolish(buildLiteralToCleanBB(schId, goalStateLiteral, false), null);
+ ag.abolish(buildLiteralToCleanBB(schId, schPlayersLiteral, false), null);
+ //ag.abolish(buildLiteralToCleanBB(aSchId, commitmentLiteral, true), null);
}
private Literal buildLiteralToCleanBB(Atom aSchId, PredicateIndicator pred, boolean schInEnd) {
@@ -457,7 +464,7 @@
return l;
}
- OEAgent getMyOEAgent() {
+ protected OEAgent getMyOEAgent() {
return currentOE.getAgent(getAgName());
}
@@ -511,8 +518,7 @@
// create the literal to be added
VarTerm S = new VarTerm("S");
- Literal gil = new LiteralImpl("goal_state");
- gil.addTerms(new Atom(gi.getScheme().getId()), gap, S);
+ Literal gil = createLiteral("goal_state", new Atom(gi.getScheme().getId()), gap, S);
gil.addAnnot(managerSource);
Unifier u = new Unifier();
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-10-21 14:26:54 UTC (rev 1400)
@@ -6,6 +6,7 @@
import jason.asSyntax.ListTerm;
import jason.asSyntax.Pred;
import jason.asSyntax.StringTerm;
+import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.mas2j.ClassParameters;
import jason.runtime.Settings;
@@ -140,7 +141,7 @@
try {
if (agSender == null) {
agSender = currentOE.addAgent(m.getSender());
- updateMembersOE(currentOE.getAgent(m.getSender()), (String) null, true, true);
+ updateMembersOE(currentOE.getAgent(m.getSender()));
}
// get content
@@ -191,25 +192,7 @@
GroupInstance gr = currentOE.findGroup(grId);
// send new OE to the members of the group
- updateMembersOE(gr.getAgents(true), null, true, true);
-
- /*
- // notify others in the group about this new player
- updateMembersOE(gr.getAgents(true), rolePlayer2str(nrp), true, true);
-
- // send players of the group to the sender
- for (RolePlayer rp : gr.getPlayers(null, true)) {
- if (!rp.getPlayer().equals(sender)) {
- updateMembersOE(sender, rolePlayer2str(rp), false, true);
- }
- }
- */
-
- // send schemes of this group to sender
- for (SchemeInstance sch : gr.getRespSchemes()) {
- updateMembersOE(sender, "scheme_group(" + sch.getId() + "," + grId + ")", false, true);
- }
-
+ updateMembersOE(gr.getAgents(true));
sendReply(sender, mId, "ok");
}
}
@@ -226,27 +209,10 @@
GroupInstance gr = currentOE.findGroup(grId);
// notify other players
- updateMembersOE(gr.getAgents(true), null, true, false);
+ updateMembersOE(gr.getAgents(true));
// and the sender (that is not in the group anymore)
- updateMembersOE(sender, null, true, false);
+ updateMembersOE(sender);
- /*
- // notify other players
- updateMembersOE(gr.getAgents(true), rolePlayer2str(orp), false, false);
-
- // and the sender
- updateMembersOE(sender, "play(" + sender + "," + roleId + "," + grId + ")", true, false);
- */
-
- // if the agent is not member of the group anymore, remove other informations of the group
- if (!gr.getAgents(false).contains(sender)) {
- /*for (RolePlayer rp : gr.getPlayers()) {
- updateMembersOE(sender, rolePlayer2str(rp), false, false);
- }*/
- for (SchemeInstance sch : gr.getRespSchemes()) {
- updateMembersOE(sender, "scheme_group(" + sch.getId() + "," + grId + ")", false, false);
- }
- }
sendReply(sender, mId, "ok");
}
}
@@ -258,24 +224,12 @@
public void process(OE currentOE, Pred command, OEAgent sender, String mId) throws MoiseException {
String misId = command.getTerm(0).toString();
String schId = command.getTerm(1).toString();
- MissionPlayer nmp = sender.commitToMission(misId, schId);
+ sender.commitToMission(misId, schId);
SchemeInstance sch = currentOE.findScheme(schId);
// notify to the scheme players the new player
- updateMembersOE(sch.getPlayers(), missionPlayer2str(nmp), true, true);
-
- // notify to the sender the other commitments of the scheme
- for (MissionPlayer mp : sch.getPlayers()) {
- if (!mp.getPlayer().equals(sender)) {
- updateMembersOE(sender, missionPlayer2str(mp), false, true);
- }
- }
-
- if (sch.getPlayersQty() > 1) {
- updateMembersOE(sch.getOwner(), "sch_players(" + sch.getId() + ",NP)", false, false);
- }
- updateMembersOE(sch.getOwner(), "sch_players(" + sch.getId() + "," + sch.getPlayersQty() + ")", false, true);
+ updateMembersOE(sch.getPlayers());
sendReply(sender, mId, "ok");
}
}
@@ -302,27 +256,16 @@
MissionPlayer mp = mpi.next();
sender.removeMission(mp.getMission().getId(), schId);
mpi = sender.getMissions().iterator();
- String evUnCom = missionPlayer2str(mp);
- updateMembersOE(sch.getPlayers(), evUnCom, false, false);
- //if (!sch.isPlayer(sender)) {
- updateMembersOE(sender, evUnCom, false, false);
- //}
}
} else {
- sch = currentOE.findScheme(schId);
MissionPlayer omp = sender.removeMission(misId, schId);
- String evUnCom = missionPlayer2str(omp);
- updateMembersOE(sender, evUnCom, false, false);
- //if (!sch.isPlayer(sender)) {
- updateMembersOE(sch.getPlayers(), evUnCom, false, false);
- //}
+ sch = omp.getScheme();
}
- updateMembersOE(sender, (String) null, true, true);
+ updateMembersOE(sch.getPlayers());
+ updateMembersOE(sender);
+ updateMembersOE(sch.getOwner()); // the owner my be removed its mission already
- // notify owner that it can finish the scheme
- updateMembersOE(sch.getOwner(), "sch_players(" + sch.getId() + ",NP)", false, false);
- updateMembersOE(sch.getOwner(), "sch_players(" + sch.getId() + "," + sch.getPlayersQty() + ")", false, true);
sendReply(sender, mId, "ok");
}
}
@@ -333,24 +276,39 @@
return "create_group";
}
public void process(OE currentOE, Pred command, OEAgent sender, String mId) throws MoiseException {
- boolean isNewRoot = command.getArity() == 1;
+ boolean isNewRoot;
+ String grName = null;
+ String specId = null;
+ if (command.getTerm(0).toString().startsWith("gr_name")) {
+ grName = ((Structure)command.getTerm(0)).getTerm(0).toString();
+ specId = command.getTerm(1).toString();
+ isNewRoot = command.getArity() == 2;
+ } else {
+ specId = command.getTerm(0).toString();
+ isNewRoot = command.getArity() == 1;
+ }
+
GroupInstance newGr;
- String specId = command.getTerm(0).toString();
if (isNewRoot) {
- newGr = currentOE.addGroup(specId);
+ if (grName == null)
+ newGr = currentOE.addGroup(specId);
+ else
+ newGr = currentOE.addGroup(grName,specId);
} else {
String superGrId = command.getTerm(1).toString();
GroupInstance superGr = currentOE.findGroup(superGrId);
if (superGr == null) {
- sendReply(sender, mId, "error(\"the group " + superGrId + " does not exist\")");
+ sendReply(sender, mId, "error(\"the super-group " + superGrId + " does not exist\")");
return;
}
- newGr = superGr.addSubGroup(specId);
+ if (grName == null)
+ newGr = superGr.addSubGroup(specId);
+ else
+ newGr = superGr.addSubGroup(grName,specId);
}
newGr.setOwner(sender);
- //updateMembersOE(currentOE.getAgents(), group2str(newGr), false, true);
- updateMembersOE(currentOE.getAgents(), null, true, true);
+ updateMembersOE(currentOE.getAgents());
sendReply(sender, mId, newGr.getId());
}
}
@@ -371,41 +329,12 @@
sendReply(sender, mId, "error(\"you are not the owner of the group " + grId + ", so you can not remove it\")");
}
- gr.checkRemove(); // TODO: does not work!
+ //gr.checkRemove();
- // 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), rolePlayer2str(rp), false, false);
- }
- */
-
- // send changes for subgroups of gr
- for (GroupInstance sg: gr.getAllSubGroupsTree()) {
- //updateMembersOE(currentOE.getAgents(), group2str(sg), 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), rolePlayer2str(rp), false, false);
- }
- */
- }
-
- // have to remove after sending the untells
currentOE.removeGroup(grId);
// sent a new copy of OE
- //updateMembersOE(currentOE.getAgents(), group2str(gr), true, false);
- updateMembersOE(currentOE.getAgents(), null, true, true);
+ updateMembersOE(currentOE.getAgents());
sendReply(sender, mId, "ok");
}
}
@@ -416,21 +345,8 @@
}
public void process(OE currentOE, Pred command, OEAgent sender, String mId) throws MoiseException {
// send new OE to all
- updateMembersOE(currentOE.getAgents(), null, true, true);
- /*
- // send created groups
- for (GroupInstance gr: currentOE.getGroups()) {
- sendGr(sender, gr);
- }
- */
+ updateMembersOE(currentOE.getAgents());
}
- /*
- private void sendGr(OEAgent to, GroupInstance gr) {
- updateMembersOE(to, group2str(gr), false, true);
- for (GroupInstance sg: gr.getSubGroups())
- sendGr(to, sg);
- }
- */
}
class CreateScheme implements OrgManagerCommand {
@@ -438,23 +354,41 @@
return "create_scheme";
}
public void process(OE currentOE, Pred command, OEAgent sender, String mId) throws MoiseException {
- String schSpecId = command.getTerm(0).toString();
- SchemeInstance sch = currentOE.startScheme(schSpecId.toString());
+ String schId = null;
+ String schSpecId;
+ ListTerm groups = null;
+ if (command.getTerm(0).toString().startsWith("sch_name")) {
+ schId = ((Structure)command.getTerm(0)).getTerm(0).toString();
+ schSpecId = command.getTerm(1).toString();
+ if (command.getArity() == 3)
+ groups = (ListTerm)command.getTerm(2);
+ } else {
+ schSpecId = command.getTerm(0).toString();
+ if (command.getArity() == 2)
+ groups = (ListTerm)command.getTerm(1);
+ }
+
+ SchemeInstance sch;
+ if (schId == null)
+ sch = currentOE.startScheme(schSpecId);
+ else
+ sch = currentOE.startScheme(schId, schSpecId);
+
sch.setOwner(sender);
- updateMembersOE(currentOE.getAgents(), scheme2str(sch), true, true);
- if (command.getArity() > 1) {
+ if (groups != null) {
// set the initial groups
- for (Term gr: (ListTerm)command.getTerm(1)) {
+ for (Term gr: groups) {
GroupInstance gi = currentOE.findGroup(gr.toString());
if (gi == null) {
sendReply(sender, mId, "error(\"the group " + gr + " does not exist\")");
return;
}
sch.addResponsibleGroup(gi);
- updateMembersOE(gi.getPlayers(), "scheme_group(" + sch.getId() + "," + gi.getId() + ")", true, true);
}
}
+
+ updateMembersOE(currentOE.getAgents());
sendReply(sender, mId, sch.getId());
}
}
@@ -483,7 +417,7 @@
sch.addResponsibleGroup(gr);
- updateMembersOE(gr.getPlayers(), "scheme_group(" + schId + "," + grId + ")", true, true);
+ updateMembersOE(gr.getPlayers());
sendReply(sender, mId, "ok");
}
}
@@ -502,11 +436,12 @@
if (sch.getSpec().getFS().getBoolProperty("only-owner-can-remove-scheme", true) && !sender.equals(sch.getOwner())) {
sendReply(sender, mId, "error(\"you are not the owner of the scheme " + schId + ", so you can not change it\")");
+ return;
}
act(currentOE, sch);
// send untell to agents
- updateMembersOE(currentOE.getAgents(), scheme2str(sch), false, false);
+ updateMembersOE(currentOE.getAgents());
sendReply(sender, mId, "ok");
}
protected void act(OE currentOE, SchemeInstance sch) throws MoiseException {
@@ -554,7 +489,8 @@
} else if (state.equals("impossible")) {
gi.setImpossible(sender);
}
- updateMembersOE(sch.getPlayers(), "goal_state(" + gi.getScheme().getId() + "," + gi.getSpec().getId() + ")", true, true);
+
+ updateMembersOE(sch.getPlayers());
sendReply(sender, mId, "ok");
}
}
@@ -594,34 +530,11 @@
gi.setArgumentValue(arg, value);
- updateMembersOE(sch.getPlayers(), "goal_state(" + gi.getScheme().getId() + "," + gi.getSpec().getId() + ")", true, true);
+ updateMembersOE(sch.getPlayers());
sendReply(sender, mId, "ok");
}
}
- /*
- String group2str(GroupInstance gr) {
- String sga = "root";
- if (gr.getSuperGroup() != null)
- sga = "super_gr("+gr.getSuperGroup().getId()+")";
- return "group(" + gr.getGrSpec().getId() + "," + gr.getId() + ")[owner(" + gr.getOwner().getId() +"),"+sga+"]";
- }
-
-
- String rolePlayer2str(RolePlayer rp) {
- return "play(" + rp.getPlayer().getId() + "," + rp.getRole().getId() + "," + rp.getGroup().getId() + ")";
- }
- */
-
- String scheme2str(SchemeInstance sch) {
- return "scheme(" + sch.getSpec().getId() + "," + sch.getId() + ")[owner(" + sch.getOwner().getId() + ")]";
- }
-
- String missionPlayer2str(MissionPlayer mp) {
- return "commitment(" + mp.getPlayer().getId() + "," + mp.getMission().getId() + "," + mp.getScheme().getId() + ")";
- }
-
-
void sendReply(OEAgent to, String mId, String content) {
try {
Message r = new Message("tell", null, to.getId(), content);
@@ -643,8 +556,9 @@
}
}
+ /* send OE to a set of agents */
@SuppressWarnings("unchecked")
- private void updateMembersOE(Collection ags, Object pEnv, boolean sendOE, boolean tell) {
+ private void updateMembersOE(Collection ags) {
Set<OEAgent> all = new HashSet<OEAgent>(); // to remove duplicates
Iterator iAgs = ags.iterator();
while (iAgs.hasNext()) {
@@ -657,26 +571,19 @@
}
for (OEAgent ag : all) {
- updateMembersOE(ag, pEnv, sendOE, tell);
+ updateMembersOE(ag);
}
}
- private void updateMembersOE(OEAgent ag, Object pEnv, boolean sendOE, boolean tell) {
+ /** send OE to one agent */
+ private void updateMembersOE(OEAgent ag) {
if (!ag.getId().equals("orgManager")) {
try {
- if (sendOE) {
- Message moe = new Message("tell", null, ag.getId(), null);
- moe.setPropCont(currentOE); //partialOE(ag)); // TODO: the clone of OE is not working!
- sendMsg(moe);
- }
- if (pEnv != null) {
- String perf = "tell";
- if (!tell)
- perf = "untell";
- sendMsg(new Message(perf, null, ag.getId(), pEnv));
- }
+ Message moe = new Message("tell", null, ag.getId(), null);
+ moe.setPropCont(currentOE.clone()); //partialOE(ag)); // TODO: the clone of OE is not working!
+ sendMsg(moe);
} catch (Exception e) {
- logger.log(Level.SEVERE, "Error sending update to " + ag + " (" + pEnv + ").", e);
+ logger.log(Level.SEVERE, "Error sending update to " + ag, e);
}
}
}
Modified: trunk/applications/jason-moise/src/jmoise/create_group.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/create_group.java 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/src/jmoise/create_group.java 2008-10-21 14:26:54 UTC (rev 1400)
@@ -6,11 +6,13 @@
/**
-<p>Organisational action: <b><code>jmoise.create_group( GrSpecId [,
+<p>Organisational action: <b><code>jmoise.create_group( [gr_name(GrName),] GrSpecId [,
SuperGrId] [, newGroupId] )</code></b>: used by an agent to create
- a new group based on GrSpecId specification. GrSpecId is the name
+ a new group based on GrSpecId specification. If the first parameter
+ is a structure with functor gr_name, the term of this structure it will be
+ the name of the new group. GrSpecId is the name
of the group in the structural specification, and SuperGrId is the
- identification of the super group instance. The second parameter is
+ identification of the super group instance. The third parameter is
used in case a sub-groups is being created. If the last argument is
a variable, it unifies with the unique identification given to the
new group.
@@ -32,6 +34,8 @@
<ul>
<li> <code>jmoise.create_group(team)</code>:
creates a new root group based on specification of a team.</li>
+<li> <code>jmoise.create_group(gr_name(g1), team)</code>:
+ creates a new root group named g1 based on specification of a team.</li>
<li> <code>jmoise.create_group(team,G)</code>:
creates a new root group based on specification of a team and unifies in G the identification of the new group.</li>
<li> <code>jmoise.create_group(defence, team0)</code>:
Modified: trunk/applications/jason-moise/src/jmoise/create_scheme.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/create_scheme.java 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/applications/jason-moise/src/jmoise/create_scheme.java 2008-10-21 14:26:54 UTC (rev 1400)
@@ -6,9 +6,10 @@
/**
-<p>Organisational action: <b><code>jmoise.create_scheme( SchSpecId [, ListOfRespGrs] )</code></b>:
- used by an agent to create a new scheme. The second optional parameter is a list of initial
- responsible groups.
+<p>Organisational action: <b><code>jmoise.create_scheme( [sch_name(SchId), ] SchSpecId [, ListOfRespGrs] )</code></b>:
+ used by an agent to create a new scheme.
+ The first optional parameter is the name of the new scheme.
+ The third optional parameter is a list of initial responsible groups.
SchSpecId is the name of the scheme specification and
ListOfRespGrs is a list of group's identifications.
@@ -22,6 +23,8 @@
<ul>
<li> <code>jmoise.create_scheme(wp)</code>:
creates new scheme based on specification wp.</li>
+<li> <code>jmoise.create_scheme(sch_name(s1), wp)</code>:
+ creates new scheme identified by s1 based on specification wp.</li>
<li> <code>jmoise.create_scheme(wp, [g1, g2])</code>:
creates new scheme based on specification wp and set g1 and g2 as responsible
groups.</li>
Modified: trunk/src/asl/kqmlPlans.asl
===================================================================
--- trunk/src/asl/kqmlPlans.asl 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/src/asl/kqmlPlans.asl 2008-10-21 14:26:54 UTC (rev 1400)
@@ -12,7 +12,7 @@
@kqmlReceivedTellStructure
+!kqml_received(Sender, tell, Content, _)
- : .structure(Content) &
+ : .literal(Content) &
.ground(Content) &
not .list(Content)
<- .add_nested_source(Content, Sender, CA);
@@ -27,7 +27,7 @@
@kqmlReceivedTellList2
+!add_all_kqml_received(Sender,[H|T])
- : .structure(H) &
+ : .literal(H) &
.ground(H)
<- .add_nested_source(H, Sender, CA);
+CA;
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/src/jason/asSemantics/Agent.java 2008-10-21 14:26:54 UTC (rev 1400)
@@ -661,6 +661,9 @@
* and generate the event.
*/
public boolean delBel(Literal bel) throws RevisionFailedException {
+ if (!bel.hasSource()) {
+ bel.addAnnot(BeliefBase.TSelf);
+ }
List<Literal>[] result = brf(null, bel, Intention.EmptyInt);
if (result != null && ts != null) {
ts.updateEvents(result, Intention.EmptyInt);
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-10-21 14:26:54 UTC (rev 1400)
@@ -56,22 +56,13 @@
}
public BodyType getBodyType() {
- if (term instanceof VarTerm) { // do not use .isVar
- return ((VarTerm)term).getBodyType();
- } else {
- return formType;
- }
+ return formType;
}
public void setBodyType(BodyType bt) {
formType = bt;
}
public Term getBodyTerm() {
- if (term instanceof VarTerm) {
- VarTerm v = (VarTerm)term;
- if (v.hasValue())
- return v.getValue();
- }
return term;
}
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-10-20 19:08:01 UTC (rev 1399)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-10-21 14:26:54 UTC (rev 1400)
@@ -904,8 +904,6 @@
public BodyType getBodyType() {
if (value != null && getValue() instanceof PlanBody)
return ((PlanBody) getValue()).getBodyType();
- else if (value != null && getValue().isInternalAction())
- return BodyType.internalAction;
else
return BodyType.none;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|