|
From: <jom...@us...> - 2008-10-20 14:12:44
|
Revision: 1398
http://jason.svn.sourceforge.net/jason/?rev=1398&view=rev
Author: jomifred
Date: 2008-10-20 14:12:34 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
start a new example in jmoise
Modified Paths:
--------------
trunk/src/jason/architecture/AgArch.java
trunk/src/jason/asSyntax/ASSyntax.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/VarTerm.java
Added Paths:
-----------
trunk/applications/jason-moise/example/moise-tutorial/
trunk/applications/jason-moise/example/moise-tutorial/jojOS.xml
trunk/applications/jason-moise/example/moise-tutorial/lucio.asl
trunk/applications/jason-moise/example/moise-tutorial/marcos.asl
trunk/applications/jason-moise/example/moise-tutorial/orgManager.asl
trunk/applications/jason-moise/example/moise-tutorial/src/
trunk/applications/jason-moise/example/moise-tutorial/src/gui/
trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java
trunk/applications/jason-moise/example/moise-tutorial/src/gui/list_bels.java
trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j
Added: trunk/applications/jason-moise/example/moise-tutorial/jojOS.xml
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/jojOS.xml (rev 0)
+++ trunk/applications/jason-moise/example/moise-tutorial/jojOS.xml 2008-10-20 14:12:34 UTC (rev 1398)
@@ -0,0 +1,126 @@
+<?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>
+
Added: trunk/applications/jason-moise/example/moise-tutorial/lucio.asl
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/lucio.asl (rev 0)
+++ trunk/applications/jason-moise/example/moise-tutorial/lucio.asl 2008-10-20 14:12:34 UTC (rev 1398)
@@ -0,0 +1,4 @@
+// the agent is controled by GUI
+
++!do(X) <- .print("doing ",X); X; gui.list_bels.
+
Added: trunk/applications/jason-moise/example/moise-tutorial/marcos.asl
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/marcos.asl (rev 0)
+++ trunk/applications/jason-moise/example/moise-tutorial/marcos.asl 2008-10-20 14:12:34 UTC (rev 1398)
@@ -0,0 +1,4 @@
+// the agent is controled by GUI
+
++!do(X) <- .print("doing ",X); X; gui.list_bels.
+
Added: trunk/applications/jason-moise/example/moise-tutorial/orgManager.asl
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/orgManager.asl (rev 0)
+++ trunk/applications/jason-moise/example/moise-tutorial/orgManager.asl 2008-10-20 14:12:34 UTC (rev 1398)
@@ -0,0 +1 @@
+/* nothing here, everything is implemented in the arhitecture */
\ No newline at end of file
Added: trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java (rev 0)
+++ trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java 2008-10-20 14:12:34 UTC (rev 1398)
@@ -0,0 +1,143 @@
+package gui;
+
+import jason.JasonException;
+import jason.asSemantics.Intention;
+import jason.asSyntax.ASSyntax;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Term;
+import jason.asSyntax.parser.ParseException;
+import jason.mas2j.ClassParameters;
+import jason.runtime.Settings;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.border.TitledBorder;
+
+import jmoise.OrgAgent;
+
+public class OrgAgentGUI extends OrgAgent {
+
+ @Override
+ public void initAg(String agClass, ClassParameters bbPars, String asSrc, Settings stts) throws JasonException {
+ super.initAg(agClass, bbPars, asSrc, stts);
+ startGUI();
+ }
+
+ @Override
+ public void stopAg() {
+ super.stopAg();
+ frame.setVisible(false);
+ }
+
+ JTextArea bels = new JTextArea(20,50);
+ JTextField args = new JTextField(30);
+ JFrame frame;
+
+ String[][] actions = { { "create_group", "spec [,superGrId]" },
+ { "remove_group", "groupID" },
+ { "adopt_role", "role,groupId" },
+ { "remove_role", "role,groupId" }
+ };
+
+ protected void startGUI() {
+
+ // top
+ JScrollPane pbb = new JScrollPane(bels);
+ pbb.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Belief Base", TitledBorder.LEFT, TitledBorder.TOP));
+ listBels();
+
+ // south
+ //control.add(new JLabel("Organisational action: "));
+
+ final JComboBox actionsCB = new JComboBox();
+ for (String[] a: actions) {
+ actionsCB.addItem(a[0]);
+ }
+ actionsCB.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent ievt) {
+ int a = actionsCB.getSelectedIndex();
+ args.setText(getInternalAction(a));
+ }
+ });
+
+ args.setText(getInternalAction(0));
+
+ JButton doBT = new JButton("Do");
+ doBT.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ executeAction(args.getText());
+ }
+ });
+ }
+ });
+ args.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ executeAction(args.getText());
+ }
+ });
+ }
+ });
+
+ JPanel control = new JPanel(new FlowLayout());
+ control.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Actions", TitledBorder.LEFT, TitledBorder.TOP));
+ control.add(actionsCB);
+ control.add(args);
+ control.add(doBT);
+
+
+ frame = new JFrame(":: "+getAgName()+" interface ::");
+ frame.getContentPane().setLayout(new BorderLayout());
+ frame.getContentPane().add(BorderLayout.CENTER, pbb);
+ frame.getContentPane().add(BorderLayout.SOUTH, control);
+
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ private String getInternalAction(int i) {
+ return "jmoise."+actions[i][0] + "(" + actions[i][1] + ")";
+ }
+
+ protected void executeAction(String actionText) {
+ bels.setText("Doing: "+ actionText);
+ try {
+ Term ia = ASSyntax.parsePlanBody(actionText);
+ Literal action = ASSyntax.createLiteral("do", ia);
+ getTS().getC().addAchvGoal(action, Intention.EmptyInt);
+ getArchInfraTier().wake();
+ } catch (ParseException e) {
+ bels.setText("Error parsing "+actionText+" as an Jason internal action!\n"+e);
+ } catch (Exception e) {
+ bels.setText("Error performing action "+actionText+": "+e);
+ e.printStackTrace();
+ }
+ }
+
+ public void listBels() {
+ bels.setText("");
+ for (Literal b: getTS().getAg().getBB()) {
+ bels.append(b+"\n");
+ }
+ }
+
+
+
+}
Added: trunk/applications/jason-moise/example/moise-tutorial/src/gui/list_bels.java
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/src/gui/list_bels.java (rev 0)
+++ trunk/applications/jason-moise/example/moise-tutorial/src/gui/list_bels.java 2008-10-20 14:12:34 UTC (rev 1398)
@@ -0,0 +1,16 @@
+package gui;
+
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Term;
+
+public class list_bels extends DefaultInternalAction {
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ OrgAgentGUI arch = (OrgAgentGUI)ts.getUserAgArch();
+ arch.listBels();
+ return true;
+ }
+}
Added: trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j (rev 0)
+++ trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j 2008-10-20 14:12:34 UTC (rev 1398)
@@ -0,0 +1,12 @@
+MAS write_paper {
+ infrastructure: Centralised
+ agents:
+ orgManager [osfile="jojOS.xml",gui=yes]
+ agentArchClass jmoise.OrgManager;
+
+ marcos agentArchClass gui.OrgAgentGUI;
+ lucio agentArchClass gui.OrgAgentGUI;
+
+ classpath: "../../lib/moise.jar";"../../lib/jmoise.jar";
+}
+
Modified: trunk/src/jason/architecture/AgArch.java
===================================================================
--- trunk/src/jason/architecture/AgArch.java 2008-10-19 19:39:24 UTC (rev 1397)
+++ trunk/src/jason/architecture/AgArch.java 2008-10-20 14:12:34 UTC (rev 1398)
@@ -140,7 +140,10 @@
/** Gets the agent's name */
public String getAgName() {
- return archTier.getAgName();
+ if (archTier == null)
+ return "no-named";
+ else
+ return archTier.getAgName();
}
/** Sends a Jason message */
Modified: trunk/src/jason/asSyntax/ASSyntax.java
===================================================================
--- trunk/src/jason/asSyntax/ASSyntax.java 2008-10-19 19:39:24 UTC (rev 1397)
+++ trunk/src/jason/asSyntax/ASSyntax.java 2008-10-20 14:12:34 UTC (rev 1398)
@@ -153,4 +153,8 @@
return (LogicalFormula)new as2j(new StringReader(sExpr)).log_expr();
}
+ /** creates a new plan's body */
+ public static PlanBody parsePlanBody(String sExpr) throws ParseException {
+ return (PlanBody)new as2j(new StringReader(sExpr)).plan_body();
+ }
}
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-10-19 19:39:24 UTC (rev 1397)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-10-20 14:12:34 UTC (rev 1398)
@@ -56,15 +56,25 @@
}
public BodyType getBodyType() {
- return formType;
+ if (term instanceof VarTerm) { // do not use .isVar
+ return ((VarTerm)term).getBodyType();
+ } else {
+ 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;
}
+
public void setBodyTerm(Term t) {
term = t;
}
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-10-19 19:39:24 UTC (rev 1397)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-10-20 14:12:34 UTC (rev 1398)
@@ -904,6 +904,8 @@
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.
|
|
From: <jom...@us...> - 2008-10-20 19:08:11
|
Revision: 1399
http://jason.svn.sourceforge.net/jason/?rev=1399&view=rev
Author: jomifred
Date: 2008-10-20 19:08:01 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
improve OrgArch for jason-moise
Modified Paths:
--------------
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/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-team/todo.org
trunk/demos/persistent-belief-base/VoidBB.java
trunk/src/jason/bb/BeliefBase.java
trunk/src/jason/bb/ChainBBAdapter.java
trunk/src/jason/bb/DefaultBeliefBase.java
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 14:12:34 UTC (rev 1398)
+++ trunk/applications/jason-moise/example/moise-tutorial/src/gui/OrgAgentGUI.java 2008-10-20 19:08:01 UTC (rev 1399)
@@ -47,10 +47,20 @@
JTextField args = new JTextField(30);
JFrame frame;
- String[][] actions = { { "create_group", "spec [,superGrId]" },
- { "remove_group", "groupID" },
- { "adopt_role", "role,groupId" },
- { "remove_role", "role,groupId" }
+ String[][] actions = { { "create_group", "g1,wpgroup" },
+ { "remove_group", "g1" },
+ { "adopt_role", "editor,g1" },
+ { "adopt_role", "writer,g1" },
+ { "remove_role", "role,groupId" },
+ { "create_scheme", "p1, writePaperSch, [g1]" },
+ { "abort_scheme", "schemeId" },
+ { "remove_scheme", "schemeId" },
+ { "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" }
};
protected void startGUI() {
@@ -96,11 +106,25 @@
}
});
+
+ JButton listBT = new JButton("Update Beliefs");
+ listBT.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ listBels();
+ }
+ });
+ }
+ });
+
+
JPanel control = new JPanel(new FlowLayout());
control.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Actions", TitledBorder.LEFT, TitledBorder.TOP));
control.add(actionsCB);
control.add(args);
control.add(doBT);
+ control.add(listBT);
frame = new JFrame(":: "+getAgName()+" interface ::");
Modified: trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j 2008-10-20 14:12:34 UTC (rev 1398)
+++ trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j 2008-10-20 19:08:01 UTC (rev 1399)
@@ -1,7 +1,7 @@
MAS write_paper {
infrastructure: Centralised
agents:
- orgManager [osfile="jojOS.xml",gui=yes]
+ orgManager [osfile="../writePaper/wp-os.xml",gui=yes] // jojOS
agentArchClass jmoise.OrgManager;
marcos agentArchClass gui.OrgAgentGUI;
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-20 14:12:34 UTC (rev 1398)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-20 19:08:01 UTC (rev 1399)
@@ -1,5 +1,6 @@
package jmoise;
+import static jason.asSyntax.ASSyntax.*;
import jason.JasonException;
import jason.RevisionFailedException;
import jason.architecture.AgArch;
@@ -31,6 +32,7 @@
import jason.runtime.Settings;
import java.util.ArrayList;
+import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -182,26 +184,74 @@
logger.log(Level.SEVERE, "Error!", e);
}
}
+
/** update the bel base according to the current OE */
void updateBB() throws RevisionFailedException {
- Agent ag = getTS().getAg();
- // add players
+
+ // update "play"
+ List<Literal> toAdd = new ArrayList<Literal>();
+
+ // create list of groups
+ for (GroupInstance gi: currentOE.getAllSubGroupsTree()) {
+ Term typeAnnot;
+ if (gi.getSuperGroup() != null)
+ typeAnnot = createStructure("super_gr", new Atom(gi.getSuperGroup().getId()));
+ else
+ typeAnnot = new Atom("root");
+ Literal l = createLiteral("group", new Atom(gi.getGrSpec().getId()), new Atom(gi.getId()));
+ l.addAnnots(createStructure("owner", new Atom(gi.getOwner().getId())), typeAnnot, managerSource);
+ toAdd.add(l);
+ }
+ orgBUF(toAdd, groupLiteral);
+
+ // create list of players
+ toAdd.clear();
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 = rolePlayer2literal(rp);
+ Literal l = createLiteral("play", new Atom(rp.getPlayer().getId()), new Atom(rp.getRole().getId()), new Atom(rp.getGroup().getId()));
l.addAnnot(managerSource);
- ag.addBel(l);
+ toAdd.add(l);
}
- }
- // remove old players
- }
+ }
+ orgBUF(toAdd, playLiteral);
- Literal rolePlayer2literal(RolePlayer rp) {
- return ASSyntax.createLiteral("play", new Atom(rp.getPlayer().getId()), new Atom(rp.getRole().getId()), new Atom(rp.getGroup().getId()));
}
-
+ private void orgBUF(List<Literal> toAdd, PredicateIndicator bel) throws RevisionFailedException {
+ try {
+ Agent ag = getTS().getAg();
+ List<Literal> toDel = new ArrayList<Literal>();
+
+ // remove old bels
+ Iterator<Literal> i = ag.getBB().getCandidateBeliefs(bel);
+ if (i != null) {
+ 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) {
+ if (p.equalsAsStructure(l)) {
+ isInOE = true;
+ break;
+ }
+ }
+ if (!isInOE) {
+ toDel.add(l);
+ }
+ }
+ }
+ for (Literal l: toDel)
+ ag.delBel(l);
+
+ // add new players
+ for (Literal l: toAdd)
+ ag.addBel(l);
+ } catch (ConcurrentModificationException e) {}
+ }
+
+
private Literal addAsBel(String b) throws RevisionFailedException {
Literal l = Literal.parseLiteral(b);
l.addAnnot(managerSource);
@@ -371,6 +421,9 @@
}
}
+ private static final PredicateIndicator groupLiteral = new PredicateIndicator("group", 2);
+ private static final PredicateIndicator playLiteral = new PredicateIndicator("play", 3);
+
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);
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-10-20 14:12:34 UTC (rev 1398)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-10-20 19:08:01 UTC (rev 1399)
@@ -26,7 +26,6 @@
import moise.oe.OE;
import moise.oe.OEAgent;
import moise.oe.Player;
-import moise.oe.RolePlayer;
import moise.oe.SchemeInstance;
import moise.tools.SimOE;
@@ -223,20 +222,27 @@
String roleId = command.getTerm(0).toString();
String grId = command.getTerm(1).toString();
- RolePlayer orp = sender.removeRole(roleId, grId);
+ sender.removeRole(roleId, grId);
GroupInstance gr = currentOE.findGroup(grId);
// notify other players
+ updateMembersOE(gr.getAgents(true), null, true, false);
+ // and the sender (that is not in the group anymore)
+ updateMembersOE(sender, null, true, false);
+
+ /*
+ // 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()) {
+ /*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);
}
@@ -343,7 +349,8 @@
}
newGr.setOwner(sender);
- updateMembersOE(currentOE.getAgents(), group2str(newGr), false, true);
+ //updateMembersOE(currentOE.getAgents(), group2str(newGr), false, true);
+ updateMembersOE(currentOE.getAgents(), null, true, true);
sendReply(sender, mId, newGr.getId());
}
}
@@ -364,35 +371,41 @@
sendReply(sender, mId, "error(\"you are not the owner of the group " + grId + ", so you can not remove it\")");
}
- gr.checkRemove();
+ gr.checkRemove(); // TODO: does not work!
// 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);
+ //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(), group2str(gr), true, false);
+ updateMembersOE(currentOE.getAgents(), null, true, true);
sendReply(sender, mId, "ok");
}
}
@@ -404,17 +417,20 @@
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);
}
+ */
}
+ /*
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 {
@@ -484,7 +500,7 @@
return;
}
- if (sch.getSpec().getFS().getBoolProperty("only-owner-can-remove-scheme") && !sender.equals(sch.getOwner())) {
+ 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\")");
}
@@ -583,6 +599,7 @@
}
}
+ /*
String group2str(GroupInstance gr) {
String sga = "root";
if (gr.getSuperGroup() != null)
@@ -590,9 +607,11 @@
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() + ")]";
Modified: trunk/applications/jason-team/todo.org
===================================================================
--- trunk/applications/jason-team/todo.org 2008-10-20 14:12:34 UTC (rev 1398)
+++ trunk/applications/jason-team/todo.org 2008-10-20 19:08:01 UTC (rev 1399)
@@ -1,19 +1,24 @@
-* team formations (moise+ representation of the team)
+* 2009 team
+** communication link is intra-group
+** leaders group
+** merging scheme
+* 2008 team
+** team formations (moise+ representation of the team)
** Structure (we have something from the proposal)
** Functioning (we have noting, but I not sure we need...)
** computation of ideal locations of an agent to maintain a formation (can we use maintainance goal pattern?)
-* herding strategy
-* exploration strategy
-* protocols
-* faster simulator
-* DONE new scenarios
-* DONE Vectors (operations)
- CLOSED: [2008-04-20 Sun 22:23]
-* DONE develop a team of dummies to play against
- CLOSED: [2008-04-20 Sun 22:23]
+** herding strategy
+** exploration strategy
+** protocols
+** faster simulator
+** DONE new scenarios
+** DONE Vectors (operations)
+ CLOSED: [2008-04-20 Sun 22:23]
+** DONE develop a team of dummies to play against
+ CLOSED: [2008-04-20 Sun 22:23]
** what is a dummy strategy?
-* DONE A* (update previous to new directions)
- CLOSED: [2008-03-16 Sun 15:29]
-* DONE integration with new simulator
- CLOSED: [2008-03-16 Sun 15:28]
- add perceptions to the agents
+** DONE A* (update previous to new directions)
+ CLOSED: [2008-03-16 Sun 15:29]
+** DONE integration with new simulator
+ CLOSED: [2008-03-16 Sun 15:28]
+ add perceptions to the agents
Modified: trunk/demos/persistent-belief-base/VoidBB.java
===================================================================
--- trunk/demos/persistent-belief-base/VoidBB.java 2008-10-20 14:12:34 UTC (rev 1398)
+++ trunk/demos/persistent-belief-base/VoidBB.java 2008-10-20 19:08:01 UTC (rev 1399)
@@ -56,6 +56,10 @@
return true;
}
+ public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi) {
+ return new ArrayList<Literal>().iterator();
+ }
+
public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) {
return new ArrayList<Literal>().iterator();
}
Modified: trunk/src/jason/bb/BeliefBase.java
===================================================================
--- trunk/src/jason/bb/BeliefBase.java 2008-10-20 14:12:34 UTC (rev 1398)
+++ trunk/src/jason/bb/BeliefBase.java 2008-10-20 19:08:01 UTC (rev 1399)
@@ -82,6 +82,12 @@
public Iterator<Literal> getAll();
/**
+ * Returns an iterator for all literals in BB that match the functor/arity
+ * of the parameter.<br>
+ */
+ public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi);
+
+ /**
* Returns an iterator for all literals relevant for l's predicate
* indicator, if l is a var, returns all beliefs.<br>
*
Modified: trunk/src/jason/bb/ChainBBAdapter.java
===================================================================
--- trunk/src/jason/bb/ChainBBAdapter.java 2008-10-20 14:12:34 UTC (rev 1398)
+++ trunk/src/jason/bb/ChainBBAdapter.java 2008-10-20 19:08:01 UTC (rev 1399)
@@ -110,6 +110,10 @@
return nextBB.iterator();
}
+ public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi) {
+ return nextBB.getCandidateBeliefs(pi);
+ }
+
public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) {
return nextBB.getCandidateBeliefs(l, u);
}
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-10-20 14:12:34 UTC (rev 1398)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-10-20 19:08:01 UTC (rev 1399)
@@ -229,17 +229,24 @@
}
}
+ public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi) {
+ BelEntry entry = belsMap.get(pi);
+ if (entry != null)
+ return Collections.unmodifiableList(entry.list).iterator();
+ else
+ return null;
+ }
+
public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) {
if (l.isVar()) {
// all bels are relevant
return iterator();
} else {
BelEntry entry = belsMap.get(l.getPredicateIndicator());
- if (entry != null) {
+ if (entry != null)
return Collections.unmodifiableList(entry.list).iterator();
- } else {
+ else
return null;
- }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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>();
...
[truncated message content] |
|
From: <jom...@us...> - 2008-10-29 12:54:20
|
Revision: 1403
http://jason.svn.sourceforge.net/jason/?rev=1403&view=rev
Author: jomifred
Date: 2008-10-29 12:54:13 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
fix some problems in the Jason AgentContest team for the new version
of JMoise
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-moise/src/jmoise/OrgManager.java
trunk/applications/jason-team/dummies.xml
trunk/applications/jason-team/gauchos.xml
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/jia/cluster.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/team-os.xml
trunk/src/jason/asSyntax/ASSyntax.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/test/TermTest.java
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-29 12:54:13 UTC (rev 1403)
@@ -67,6 +67,8 @@
private Set<GoalInstance> alreadyGeneratedEvents = new HashSet<GoalInstance>();
private String orgManagerName = "orgManager";
+ private boolean checkCommLink = true;
+
@Override
public void initAg(String agClass, ClassParameters bbPars, String asSrc, Settings stts) throws JasonException {
super.initAg(agClass, bbPars, asSrc, stts);
@@ -95,16 +97,24 @@
logger.fine("Error sending add_agent to OrgManager!");
}
}
+
+ public void setCheckCommunicationLink(boolean check) {
+ checkCommLink = check;
+ }
@Override
public void sendMsg(Message m) throws Exception {
// check communication link
- String to = m.getReceiver();
- if (currentOE == null || to.equals(orgManagerName) || to.equals(getAgName()) ||
- getMyOEAgent().hasLink("communication", getOE().getAgent(to))) {
+ if (checkCommLink) {
+ String to = m.getReceiver();
+ if (currentOE == null || to.equals(orgManagerName) || to.equals(getAgName()) ||
+ getMyOEAgent().hasLink("communication", getOE().getAgent(to))) {
+ super.sendMsg(m);
+ } else {
+ throw new MoiseException(getAgName()+" is not allowed to communicate with "+to+", sender roles are "+getMyOEAgent().getRoles());
+ }
+ } else {
super.sendMsg(m);
- } else {
- throw new MoiseException(getAgName()+" is not allowed to communicate with "+to);
}
}
@@ -241,7 +251,9 @@
Set<Permission> obligations = new HashSet<Permission>();
List<Literal> toAdd = new ArrayList<Literal>();
toAdd = createObligation(obligations);
- orgBUF(toAdd, obligationLiteral);
+ //getTS().getLogger().info("** obliations "+toAdd);
+ List<Literal> deleted = orgBUF(toAdd, obligationLiteral);
+ //getTS().getLogger().info("** new obli "+toAdd+", deleted "+deleted);
toAdd.clear();
toAdd = createPermission(obligations);
orgBUF(toAdd, permissionLiteral);
Modified: trunk/applications/jason-moise/src/jmoise/OrgManager.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-moise/src/jmoise/OrgManager.java 2008-10-29 12:54:13 UTC (rev 1403)
@@ -8,6 +8,7 @@
import jason.asSyntax.StringTerm;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
+import jason.infra.centralised.CentralisedAgArch;
import jason.mas2j.ClassParameters;
import jason.runtime.Settings;
@@ -580,7 +581,11 @@
if (!ag.getId().equals("orgManager")) {
try {
Message moe = new Message("tell", null, ag.getId(), null);
- moe.setPropCont(currentOE.clone()); //partialOE(ag)); // TODO: the clone of OE is not working!
+ // need to clone only on centralised execution, otherwise the serialization will clone
+ if (getArchInfraTier() instanceof CentralisedAgArch)
+ moe.setPropCont(currentOE.clone()); //partialOE(ag)); // TODO: the clone of OE is not working!
+ else
+ moe.setPropCont(currentOE);
sendMsg(moe);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending update to " + ag, e);
Modified: trunk/applications/jason-team/dummies.xml
===================================================================
--- trunk/applications/jason-team/dummies.xml 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/dummies.xml 2008-10-29 12:54:13 UTC (rev 1403)
@@ -25,68 +25,16 @@
<fileset dir="${basedir}/lib" > <include name="*.jar" /> </fileset>
</path>
- <!-- tasks the user can override in his/her c-build.xml script -->
- <target name="user-init">
- <ant antfile="../jason-moise/build.xml" target="jar" inheritall="false" />
- <copy file="../jason-moise/lib/jmoise.jar" todir="lib" />
- <copy file="../jason-moise/lib/moise.jar" todir="lib" />
- </target>
- <target name="user-end">
- </target>
-
<target name="init">
<mkdir dir="${build.dir}" />
- <antcall target="user-init" />
</target>
<target name="compile" depends="init">
- <condition property="srcdir" value="${basedir}/src/java" else="${basedir}" >
- <available file="${basedir}/src/java" />
- </condition>
- <javac srcdir="${srcdir}" destdir="${build.dir}" debug="true" optimize="true" >
+ <javac srcdir="${basedir}/src/java" destdir="${build.dir}" debug="true" optimize="true" >
<classpath refid="project.classpath"/>
</javac>
</target>
- <target name="jar" depends="compile">
- <delete file="${ant.project.name}.jar" />
- <copy file="${jasonJar}" tofile="${ant.project.name}.jar" />
- <copy file="${mas2j.project.file}" tofile="default.mas2j" />
- <jar update="yes" jarfile="${ant.project.name}.jar" >
- <fileset dir="${basedir}">
- <include name="**/*.asl" />
- <include name="**/*.mas2j" />
- </fileset>
- <fileset dir="${build.dir}">
- <include name="**/*.class" />
- </fileset>
- </jar>
- <delete file="default.mas2j" />
- </target>
-
-
- <target name="jnlp" depends="jar" >
- <mkdir dir="${basedir}/${ant.project.name}-jws"/>
- <java classname="jason.infra.centralised.CreateJNLP"
- failonerror="true" fork="yes" dir="${basedir}/${ant.project.name}-jws" >
- <classpath refid="project.classpath"/>
- <arg line="${ant.project.name} ${mas2j.project.file}"/>
- </java>
- <copy todir="${basedir}/${ant.project.name}-jws" failonerror="no">
- <fileset dir="${basedir}/lib" includes="**/*.jar" />
- <fileset dir="${basedir}" includes="${ant.project.name}.jar" />
- <fileset dir="/Users/jomi/Jason/Jason-svn/src/images" includes="Jason-GMoreau-Icon.jpg" />
- </copy>
- <signjar jar="${basedir}/${ant.project.name}-jws/${ant.project.name}.jar" alias="jason"
- storepass="rbjhja" keypass="rbjhja" keystore="/Users/jomi/Jason/Jason-svn/src/jasonKeystore" />
- <echo message="**" />
- <echo message="** Java Web Start application created in directory ${ant.project.name}-jws" />
- <echo message="** Update the codebase (in the second line of the .jnlp file)" />
- <echo message="** with the URL where you will upload the application." />
- <echo message="**" />
- </target>
-
-
<target name="run" depends="compile" >
<echo message="Running project ${ant.project.name}" />
<java classname="jason.infra.centralised.RunCentralisedMAS"
@@ -95,15 +43,5 @@
<arg line="${mas2j.project.file} ${debug} "/>
<jvmarg line="-Xmx750M"/>
</java>
- <antcall target="user-end" />
</target>
-
- <target name="clean" >
- <delete failonerror="no" includeEmptyDirs="true" verbose="true">
- <fileset dir="${basedir}" includes="**/*.class"/>
- </delete>
- </target>
-
-
-
</project>
Modified: trunk/applications/jason-team/gauchos.xml
===================================================================
--- trunk/applications/jason-team/gauchos.xml 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/gauchos.xml 2008-10-29 12:54:13 UTC (rev 1403)
@@ -29,7 +29,7 @@
<target name="user-init">
<ant antfile="../jason-moise/build.xml" target="jar" inheritall="false" />
<copy file="../jason-moise/lib/jmoise.jar" todir="lib" />
- <copy file="../jason-moise/lib/moise.jar" todir="lib" />
+ <copy file="../jason-moise/lib/moise.jar" todir="lib" />
<delete failonerror="no" includeEmptyDirs="true" verbose="false">
<fileset dir="massim-server/backup" includes="**/*"/>
@@ -67,30 +67,8 @@
</jar>
<delete file="default.mas2j" />
</target>
-
- <target name="jnlp" depends="jar" >
- <mkdir dir="${basedir}/${ant.project.name}-jws"/>
- <java classname="jason.infra.centralised.CreateJNLP"
- failonerror="true" fork="yes" dir="${basedir}/${ant.project.name}-jws" >
- <classpath refid="project.classpath"/>
- <arg line="${ant.project.name} ${mas2j.project.file}"/>
- </java>
- <copy todir="${basedir}/${ant.project.name}-jws" failonerror="no">
- <fileset dir="${basedir}/lib" includes="**/*.jar" />
- <fileset dir="${basedir}" includes="${ant.project.name}.jar" />
- <fileset dir="/Users/jomi/Jason/Jason-svn/src/images" includes="Jason-GMoreau-Icon.jpg" />
- </copy>
- <signjar jar="${basedir}/${ant.project.name}-jws/${ant.project.name}.jar" alias="jason"
- storepass="rbjhja" keypass="rbjhja" keystore="/Users/jomi/Jason/Jason-svn/src/jasonKeystore" />
- <echo message="**" />
- <echo message="** Java Web Start application created in directory ${ant.project.name}-jws" />
- <echo message="** Update the codebase (in the second line of the .jnlp file)" />
- <echo message="** with the URL where you will upload the application." />
- <echo message="**" />
- </target>
-
<target name="run" depends="compile" >
<delete failonerror="no" includeEmptyDirs="true" verbose="false">
<fileset dir="mind-ag" includes="**/*.xml"/>
@@ -119,6 +97,4 @@
</delete>
</target>
-
-
</project>
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-10-29 12:54:13 UTC (rev 1403)
@@ -45,15 +45,21 @@
+play(Me,explorer,G)
: .my_name(Me) &
not scheme_group(_,G)
- <- jmoise.create_scheme(explore_sch, [G]).
+ <- .print("Creating explore scheme");
+ jmoise.create_scheme(explore_sch, [G]).
-// If I stop playing explorer, destroy the explore groups I've created
+// If I stop playing explorer, destroy the explore scheme/group I've created
-play(Me,explorer,_)
: .my_name(Me)
- <- for( group(exploration_grp,G)[owner(Me)] ) {
+ <- for( scheme(explore_sch,S)[owner(Me)] ) {
+ .print("ooo Removing scheme ",S);
+ jmoise.remove_scheme(S);
+ .wait(1000)
+ };
+ for( group(exploration_grp,G)[owner(Me)] ) {
.print("ooo Removing group ",G," since I am not in the group anymore");
jmoise.remove_group(G);
- .wait(4000)
+ .wait(1000)
}.
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-10-29 12:54:13 UTC (rev 1403)
@@ -151,24 +151,25 @@
+!quit_all_missions_roles
<- .my_name(Me);
+ // if I play any other role, give it up
+ while( play(Me,R,OG) ) {
+ .print("ooo removing my role ",R," in ",OG);
+ jmoise.remove_role(R,OG)
+ }/*;
+
// give up all missions
while( commitment(Me,M,Sch) ) {
.print("ooo removing my mission ",M," in ",Sch);
jmoise.remove_mission(M,Sch)
- };
+ }*/.
- // if I play any other role, give it up
- while( play(Me,R,OG) ) {
- .print("ooo removing my role ",R," in ",OG);
- jmoise.remove_role(R,OG)
- }.
// 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).
+//+sch_players(Sch,0)
+// : .my_name(Me) & scheme(_, Sch)[owner(Me)]
+// <- jmoise.remove_scheme(Sch).
// when I have an obligation or permission to a mission, commit to it
@@ -180,14 +181,16 @@
jmoise.commit_mission(Mission,Sch).
// when I am not obligated to a mission anymore, uncommit
+/*
-obligation(Sch, Mission)
: .my_name(Me) & commitment(Me,Mission,Sch)
- <- .print("ooo I don't have obligation for the mission ",Mission," anymore, remove the commit");
+ <- .print("ooo I don't have obligation for the mission ",Mission," in ",Sch," anymore, remove the commitment");
jmoise.remove_mission(Mission,Sch).
-permission(Sch, Mission)
: .my_name(Me) & commitment(Me,Mission,Sch)
- <- .print("ooo I don't have permission for the mission ",Mission," anymore, remove the commit");
+ <- .print("ooo I don't have permission for the mission ",Mission," in ",Sch," anymore, remove the commitment");
jmoise.remove_mission(Mission,Sch).
+*/
// when I am not committed to a mission anymore, remove all goals based on that mission
-commitment(Me,Mission,Sch)
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-10-29 12:54:13 UTC (rev 1403)
@@ -35,12 +35,17 @@
// If I stop playing herder, destroy the herding groups I've created
-play(Me,herder,_)
: .my_name(Me)
- <- for( group(herding_grp,G)[owner(Me)] ) {
+ <- for( scheme(herd_sch,S)[owner(Me)] ) {
+ .print("ooo Removing scheme ",S);
+ jmoise.remove_scheme(S);
+ .wait(1000)
+ };
+ for( group(herding_grp,G)[owner(Me)] ) {
-group_leader(G,Me);
.broadcast(untell, group_leader(G,Me));
.print("ooo removing the group ",G);
jmoise.remove_group(G);
- .wait(4000)
+ .wait(1000)
}.
// If I stop playing herdboy (because the group was destroied by the herder),
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-10-29 12:54:13 UTC (rev 1403)
@@ -71,6 +71,8 @@
if (massimBackDir != null && massimBackDir.startsWith("\""))
massimBackDir = massimBackDir.substring(1,massimBackDir.length()-1);
logger = Logger.getLogger(CowboyArch.class.getName() + ".CA-" + getAgName());
+
+ setCheckCommunicationLink(false);
}
@Override
Modified: trunk/applications/jason-team/src/java/jia/cluster.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/cluster.java 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/src/java/jia/cluster.java 2008-10-29 12:54:13 UTC (rev 1403)
@@ -1,13 +1,13 @@
package jia;
+import static jason.asSyntax.ASSyntax.createNumber;
+import static jason.asSyntax.ASSyntax.createStructure;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
-import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.ObjectTermImpl;
-import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.environment.grid.Location;
@@ -47,9 +47,7 @@
ListTerm r = new ListTermImpl();
ListTerm tail = r;
for (Location l: locs) {
- Structure p = new Structure("pos",2);
- p.addTerms(new NumberTermImpl(l.x), new NumberTermImpl(l.y));
- tail = tail.append(p);
+ tail = tail.append(createStructure("pos", createNumber(l.x), createNumber(l.y)));
}
return un.unifies(args[0], new ObjectTermImpl(locs)) &&
un.unifies(args[1], r);
Modified: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-10-29 12:54:13 UTC (rev 1403)
@@ -1,5 +1,7 @@
package jia;
+import static jason.asSyntax.ASSyntax.createNumber;
+import static jason.asSyntax.ASSyntax.createStructure;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
@@ -8,7 +10,6 @@
import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.ObjectTerm;
-import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.environment.grid.Location;
@@ -101,9 +102,7 @@
ListTerm r = new ListTermImpl();
ListTerm tail = r;
for (Location l: locs) {
- Structure p = new Structure("pos",2);
- p.addTerms(new NumberTermImpl(l.x), new NumberTermImpl(l.y));
- tail = tail.append(p);
+ tail = tail.append(createStructure("pos", createNumber(l.x), createNumber(l.y)));
}
return un.unifies(args[2], r);
} else {
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/applications/jason-team/src/team-os.xml 2008-10-29 12:54:13 UTC (rev 1403)
@@ -16,6 +16,7 @@
<properties>
<property id="check-players-in-remove-group" value="false" />
<property id="check-sub-group-in-remove-group" value="false" />
+ <property id="check-missions-in-remove-role" value="false" />
</properties>
<role-definitions>
@@ -70,8 +71,9 @@
<functional-specification>
<properties>
<property id="check-players-in-remove-responsible-group" value="false" />
+ <property id="check-players-in-remove-scheme" value="false" />
<property id="only-owner-can-remove-scheme" value="false" />
- <!--property id="check-goals-in-remove-mission" value="false" /-->
+ <property id="check-goals-in-remove-mission" value="false" />
</properties>
<scheme id="explore_sch" >
Modified: trunk/src/jason/asSyntax/ASSyntax.java
===================================================================
--- trunk/src/jason/asSyntax/ASSyntax.java 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/src/jason/asSyntax/ASSyntax.java 2008-10-29 12:54:13 UTC (rev 1403)
@@ -81,7 +81,8 @@
* and the n remainder arguments are terms.
*/
public static Structure createStructure(String functor, Term... terms) {
- return (Structure)new Structure(functor).addTerms(terms);
+ int size = (terms == null || terms.length == 0 ? 3 : terms.length);
+ return (Structure)new Structure(functor, size).addTerms(terms);
}
/** creates a new Atom term */
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/src/jason/asSyntax/Structure.java 2008-10-29 12:54:13 UTC (rev 1403)
@@ -192,9 +192,8 @@
@Override
public Literal addTerms(Term ... ts ) {
- for (Term t: ts) {
+ for (Term t: ts)
terms.add(t);
- }
predicateIndicatorCache = null;
resetHashCodeCache();
return this;
@@ -202,9 +201,8 @@
@Override
public Literal addTerms(List<Term> l) {
- for (Term t: l) {
+ for (Term t: l)
terms.add(t);
- }
predicateIndicatorCache = null;
resetHashCodeCache();
return this;
Modified: trunk/src/test/TermTest.java
===================================================================
--- trunk/src/test/TermTest.java 2008-10-28 22:24:40 UTC (rev 1402)
+++ trunk/src/test/TermTest.java 2008-10-29 12:54:13 UTC (rev 1403)
@@ -1,5 +1,6 @@
package test;
+import static jason.asSyntax.ASSyntax.*;
import jason.asSemantics.Unifier;
import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
@@ -318,8 +319,8 @@
public void testAnnotsUnify7() throws ParseException {
// p[a,b,c,d] = p[a,c|R] - ok and R=[b,d]
- Term t1 = ASSyntax.parseTerm("p[a,b,c,d]");
- Term t2 = ASSyntax.parseTerm("p[a,c|R]");
+ Term t1 = parseTerm("p[a,b,c,d]");
+ Term t2 = parseTerm("p[a,c|R]");
Unifier u = new Unifier();
assertTrue(u.unifies(t1, t2));
assertEquals(u.get("R").toString(),"[b,d]");
@@ -330,7 +331,7 @@
assertEquals(u.get("R").toString(),"[b,d]");
// p[H|R] = p[a,b,c,d] - ok and R=[b,c,d], H=a
- Term t3 = ASSyntax.parseTerm("p[H|R]");
+ Term t3 = parseTerm("p[H|R]");
u = new Unifier();
assertTrue(u.unifies(t1, t3));
assertEquals(u.get("H").toString(),"a");
@@ -338,17 +339,17 @@
}
public void testApplyAnnots() throws ParseException {
- Term t1 = ASSyntax.parseTerm("p[a,X,c,d]");
+ Term t1 = parseTerm("p[a,X,c,d]");
Unifier u = new Unifier();
u.unifies(new VarTerm("X"), new Atom("z"));
t1.apply(u);
assertEquals("p[a,z,c,d]",t1.toString());
- t1 = ASSyntax.parseTerm("p[X,b,c,d]");
+ t1 = parseTerm("p[X,b,c,d]");
t1.apply(u);
assertEquals("p[z,b,c,d]",t1.toString());
- t1 = ASSyntax.parseTerm("p[a,b,c,X]");
+ t1 = parseTerm("p[a,b,c,X]");
t1.apply(u);
assertEquals("p[a,b,c,z]",t1.toString());
}
@@ -678,15 +679,16 @@
}
public void testGetTermsArray() {
- Structure s2 = Structure.parse("a(1,2,3)");
+ Structure s2 = createStructure("a");
+ s2.addTerms(createNumber(1), createNumber(2), createNumber(3));
Term[] a = s2.getTermsArray();
assertEquals(3,a.length);
assertEquals("1",a[0].toString());
assertEquals("3",a[2].toString());
}
- public void testIALiteral() {
- Literal l = Literal.parseLiteral(".print(a)");
+ public void testIALiteral() throws ParseException {
+ Literal l = parseLiteral(".print(a)");
assertTrue(l.isInternalAction());
l = Literal.parseLiteral("print(a)");
@@ -703,8 +705,8 @@
assertEquals(0,s.getArity());
}
- public void testHasVar() {
- Literal l = Literal.parseLiteral("a(Test,X,Y,b(g([V1,X,V2,V1]),c))[b,source(Y),B,kk(_),oo(oo(OO))]");
+ public void testHasVar() throws ParseException {
+ Literal l = parseLiteral("a(Test,X,Y,b(g([V1,X,V2,V1]),c))[b,source(Y),B,kk(_),oo(oo(OO))]");
assertTrue(l.hasVar(new VarTerm("X")));
assertTrue(l.hasVar(new VarTerm("V2")));
assertTrue(l.hasVar(new VarTerm("OO")));
@@ -755,8 +757,8 @@
}
- public void testAtomParsing() {
- Literal l = Literal.parseLiteral("b");
+ public void testAtomParsing() throws ParseException {
+ Literal l = parseLiteral("b");
assertTrue(l instanceof Literal);
assertTrue(l.isAtom());
@@ -764,12 +766,12 @@
@SuppressWarnings("unused")
Atom x = (Atom)l;
- l = Literal.parseLiteral("b(10,a,c(10,x))[ant1,source(c)]");
+ l = parseLiteral("b(10,a,c(10,x))[ant1,source(c)]");
assertTrue(l.getTerm(1) instanceof Atom);
assertFalse(l.getTerm(2).isAtom());
assertTrue(l.getAnnots().get(0) instanceof Atom);
- l = Literal.parseLiteral("b(a.r)"); // internal actions should not be atoms
+ l = parseLiteral("b(a.r)"); // internal actions should not be atoms
assertFalse(l.getTerm(0).isAtom());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-10-29 16:59:05
|
Revision: 1404
http://jason.svn.sourceforge.net/jason/?rev=1404&view=rev
Author: jomifred
Date: 2008-10-29 16:59:01 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
improve error messages in jason team (for AgentContest)
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/src/jason/JasonException.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/DefaultTerm.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/LiteralImpl.java
trunk/src/jason/asSyntax/SourceInfo.java
trunk/src/jason/asSyntax/StringTermImpl.java
trunk/src/jason/stdlib/fail.java
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -1,6 +1,8 @@
package jmoise;
import static jason.asSyntax.ASSyntax.createLiteral;
+import static jason.asSyntax.ASSyntax.createNumber;
+import static jason.asSyntax.ASSyntax.createString;
import static jason.asSyntax.ASSyntax.createStructure;
import jason.JasonException;
import jason.RevisionFailedException;
@@ -222,7 +224,7 @@
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())));
+ getTS().getAg().addBel(createLiteral( "sch_players", new Atom(sch.getId()), createNumber(sch.getPlayersQty())));
}
}
List<Literal> deleted = orgBUF(toAdd, schemeLiteral);
@@ -251,9 +253,7 @@
Set<Permission> obligations = new HashSet<Permission>();
List<Literal> toAdd = new ArrayList<Literal>();
toAdd = createObligation(obligations);
- //getTS().getLogger().info("** obliations "+toAdd);
- List<Literal> deleted = orgBUF(toAdd, obligationLiteral);
- //getTS().getLogger().info("** new obli "+toAdd+", deleted "+deleted);
+ orgBUF(toAdd, obligationLiteral);
toAdd.clear();
toAdd = createPermission(obligations);
orgBUF(toAdd, permissionLiteral);
@@ -323,8 +323,16 @@
if (content.startsWith("error")) {
// fail the IA
PlanBody pbody = pi.peek().getPlan().getBody();
- pbody.add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
- getTS().getLogger().warning("Error in organisational action '"+body+"': "+content);
+ Literal fail = new InternalActionLiteral(".fail");
+ String msg = content.substring(7,content.length()-2);
+ fail.addTerm(createStructure("error_msg", createString(msg)));
+ fail.addTerm(createStructure("code", createString(body.toString())));
+ if (body.getSrcInfo() != null) {
+ fail.addTerm(createStructure("code_src", createString(body.getSrcInfo().getSrcFile())));
+ fail.addTerm(createStructure("code_line", createNumber(body.getSrcInfo().getBeginSrcLine())));
+ }
+ pbody.add(0, new PlanBodyImpl(BodyType.internalAction, fail));
+ //getTS().getLogger().warning("Error in organisational action '"+body+"': "+content);
} else {
// try to unify the return value
//System.out.println("answer is "+content+" or "+DefaultTerm.parse(content)+" with body "+body);
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-10-29 16:59:01 UTC (rev 1404)
@@ -32,7 +32,7 @@
if( not group(exploration_grp,_)[owner(Me)] ) {
?group(team,TeamGroup); // get the team Id
jmoise.create_group(exploration_grp,TeamGroup,G);
- .print("ooo Group ",G," created")
+ .print("ooo Exploration group ",G," created")
} {
?group(exploration_grp,G)[owner(Me)]
};
@@ -153,7 +153,7 @@
!ask_all_cows(Leaders,LCows);
.findall(cow(ID,X,Y), cow(ID,X,Y), MyCows);
.intersection(MyCows, LCows, Common);
- //.print("xxx all cows in herding groups are ",LCows," my are ",MyCows," intersection is ",Common);
+ //.print("xxx all cows in herding groups are ",LCows," mine are ",MyCows," intersection is ",Common);
if ( Common == [] ) {
!!create_herding_gr
}{
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-10-29 16:59:01 UTC (rev 1404)
@@ -147,23 +147,25 @@
+!play_role(Role,Group)[source(Ag)]
<- .print("ooo Adopting role ",Role," in group ",Group,", as asked by ",Ag);
jmoise.adopt_role(Role, Group).
+-!play_role(_,_)[error_msg(M),code(C)]
+ <- .print("* Error in ",C,": ",M).
+!quit_all_missions_roles
<- .my_name(Me);
// if I play any other role, give it up
while( play(Me,R,OG) ) {
- .print("ooo removing my role ",R," in ",OG);
+ .print("ooo Removing my role ",R," in ",OG);
jmoise.remove_role(R,OG)
- }/*;
+ };
// give up all missions
while( commitment(Me,M,Sch) ) {
- .print("ooo removing my mission ",M," in ",Sch);
+ .print("ooo Removing my mission ",M," in ",Sch);
jmoise.remove_mission(M,Sch)
- }*/.
+ }.
+-!quit_all_missions_roles[error_msg(M),code(C)] <- .println("*** ",C," - ",M). // no problem if it fails, it is better to continue
-
// finish the scheme if it has no more players
// and it was created by me
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-10-29 16:59:01 UTC (rev 1404)
@@ -11,7 +11,7 @@
// create the new group
?group(team,TeamId);
jmoise.create_group(herding_grp, TeamId, HG);
- .print("ooo Group ",HG," created.");
+ .print("ooo Herding group ",HG," created.");
// store the list of scouter in my group
?play(Me,explorer,EG);
Modified: trunk/src/jason/JasonException.java
===================================================================
--- trunk/src/jason/JasonException.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/JasonException.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -26,11 +26,10 @@
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.InternalAction;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
-import jason.asSyntax.StringTermImpl;
-import jason.asSyntax.Structure;
import jason.asSyntax.Term;
@@ -44,6 +43,8 @@
private static final Term defaultError = new Atom("internal_action");
private Term error = defaultError;
+ private ListTerm errorAnnots = null;
+
/**
* Creates a new instance of <code>JasonException</code> without detail message.
*/
@@ -81,8 +82,17 @@
this.error = error;
}
+ public void addErrorAnnot(Term t) {
+ if (errorAnnots == null)
+ errorAnnots = new ListTermImpl();
+ errorAnnots.append(t);
+ }
+
public ListTerm getErrorTerms() {
- return createBasicErrorAnnots(error, getMessage());
+ ListTerm e = createBasicErrorAnnots(error, getMessage());
+ if (errorAnnots != null)
+ e.concat(errorAnnots.cloneLT());
+ return e;
}
@SuppressWarnings("unchecked")
@@ -107,6 +117,10 @@
return createBasicErrorAnnots(new Atom(id), msg);
}
public static ListTerm createBasicErrorAnnots(Term id, String msg) {
+ return ASSyntax.createList(
+ ASSyntax.createStructure("error", id),
+ ASSyntax.createStructure("error_msg", ASSyntax.createString(msg)));
+ /*
ListTerm failAnnots = new ListTermImpl();
Structure e = new Structure("error", 1);
e.addTerm(id);
@@ -115,5 +129,6 @@
m.addTerm(new StringTermImpl(msg));
failAnnots.add(m);
return failAnnots;
+ */
}
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -869,41 +869,39 @@
return null;
}
- private static final Term aNOCODE = new Atom("no_code");
+ private static final Atom aNOCODE = new Atom("no_code");
private static void setDefaultFailureAnnots(Event failEvent, Term body, List<Term> failAnnots) {
// add default failure annots
if (failAnnots == null)
failAnnots = JasonException.createBasicErrorAnnots( JasonException.UNKNOW_ERROR, "");
+
+ Literal eventLiteral = failEvent.getTrigger().getLiteral();
+ eventLiteral.addAnnots(failAnnots);
// add failure annots in the event related to the code source
- Literal bodyterm = null;
- Term codesrc = null;
- Term codeline = null;
+ Literal bodyterm = aNOCODE;
+ Term codesrc = aNOCODE;
+ Term codeline = aNOCODE;
if (body != null && body instanceof Literal) {
bodyterm = (Literal)body;
- codesrc = new StringTermImpl(bodyterm.getSrcFile());
- codeline = new NumberTermImpl(bodyterm.getSrcLine());
- } else {
- bodyterm = new Atom("no_code");
- codesrc = aNOCODE;
- codeline = aNOCODE;
+ if (bodyterm.getSrcInfo() != null) {
+ if (bodyterm.getSrcInfo().getSrcFile() != null)
+ codesrc = new StringTermImpl(bodyterm.getSrcInfo().getSrcFile());
+ codeline = new NumberTermImpl(bodyterm.getSrcInfo().getSrcLine());
+ }
}
// code
- Structure code = new Structure("code", 1);
- code.addTerm(bodyterm);
- failAnnots.add(code);
+ if (eventLiteral.getAnnots("code").isEmpty())
+ eventLiteral.addAnnot(ASSyntax.createStructure("code", bodyterm));
// ASL source
- Structure src = new Structure("code_src", 1);
- src.addTerm(codesrc);
- failAnnots.add(src);
+ if (eventLiteral.getAnnots("code_src").isEmpty())
+ eventLiteral.addAnnot(ASSyntax.createStructure("code_src", codesrc));
// line in the source
- Structure line = new Structure("code_line", 1);
- line.addTerm(codeline);
- failAnnots.add(line);
- failEvent.getTrigger().getLiteral().addAnnots(failAnnots);
+ if (eventLiteral.getAnnots("code_line").isEmpty())
+ eventLiteral.addAnnot(ASSyntax.createStructure("code_line", codeline));
}
public boolean canSleep() {
Modified: trunk/src/jason/asSyntax/DefaultTerm.java
===================================================================
--- trunk/src/jason/asSyntax/DefaultTerm.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/asSyntax/DefaultTerm.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -109,20 +109,6 @@
srcInfo = s;
}
- public String getSrcFile() {
- if (srcInfo == null)
- return null;
- else
- return srcInfo.getSrcFile();
- }
-
- public int getSrcLine() {
- if (srcInfo == null)
- return 0;
- else
- return srcInfo.getSrcLine();
- }
-
public String getErrorMsg() {
if (srcInfo == null)
return "";
Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -142,8 +142,8 @@
@Override
public String getErrorMsg() {
- String line = (getSrcLine() >= 0 ? ":"+getSrcLine() : "");
- return "Error in internal action '"+this+"' ("+ getSrcFile() + line + ")";
+ String src = getSrcInfo() == null ? "" : " ("+ getSrcInfo().getErrorMsg() + ")";
+ return "Error in internal action '"+this+"'"+ src;
}
public InternalActionLiteral clone() {
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/asSyntax/Literal.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -164,6 +164,8 @@
* [t(a), t(b), source(tom)]
* and functor "t",
* it returns [t(a),t(b)]
+ *
+ * in case that there is no such an annot, it returns an empty list.
*/
public ListTerm getAnnots(String functor) { return new ListTermImpl(); }
/**
Modified: trunk/src/jason/asSyntax/LiteralImpl.java
===================================================================
--- trunk/src/jason/asSyntax/LiteralImpl.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/asSyntax/LiteralImpl.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -101,7 +101,8 @@
@Override
public String getErrorMsg() {
- return "Error in '"+this+"' ("+ super.getErrorMsg() + ")";
+ String src = getSrcInfo() == null ? "" : " ("+ getSrcInfo().getErrorMsg() + ")";
+ return "Error in '"+this+"'"+src;
}
@Override
Modified: trunk/src/jason/asSyntax/SourceInfo.java
===================================================================
--- trunk/src/jason/asSyntax/SourceInfo.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/asSyntax/SourceInfo.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -23,13 +23,16 @@
endSrcLine = endLine;
}
public SourceInfo(SourceInfo o) {
- source = o.source;
- beginSrcLine = o.beginSrcLine;
- endSrcLine = o.endSrcLine;
+ if (o == null) {
+ source = null;
+ beginSrcLine = 0;
+ endSrcLine = 0;
+ } else {
+ source = o.source;
+ beginSrcLine = o.beginSrcLine;
+ endSrcLine = o.endSrcLine;
+ }
}
- public SourceInfo(DefaultTerm o) {
- this(o.getSrcInfo());
- }
public SourceInfo clone() {
return this;
Modified: trunk/src/jason/asSyntax/StringTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/StringTermImpl.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/asSyntax/StringTermImpl.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -94,7 +94,10 @@
if (t != null && t instanceof StringTerm) {
StringTerm st = (StringTerm)t;
- return value.equals(st.getString());
+ if (value == null)
+ return st.getString() == null;
+ else
+ return value.equals(st.getString());
}
return false;
}
Modified: trunk/src/jason/stdlib/fail.java
===================================================================
--- trunk/src/jason/stdlib/fail.java 2008-10-29 12:54:13 UTC (rev 1403)
+++ trunk/src/jason/stdlib/fail.java 2008-10-29 16:59:01 UTC (rev 1404)
@@ -23,10 +23,13 @@
package jason.stdlib;
+import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.InternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.StringTerm;
+import jason.asSyntax.Structure;
import jason.asSyntax.Term;
/**
@@ -52,12 +55,31 @@
return singleton;
}
- @Override public int getMinArgs() { return 0; }
- @Override public int getMaxArgs() { return 0; }
-
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- checkArguments(args);
+ if (args.length > 0) { // add all arguments as annotations in the exception
+ // find message
+ Term smsg = null;
+ String msg = "fail";
+ for (Term t: args) {
+ if (t.isStructure() && ((Structure)t).getFunctor().equals("error_msg")) {
+ smsg = t;
+ Term tm = ((Structure)t).getTerm(0);
+ if (tm.isString())
+ msg = ((StringTerm)tm).getString();
+ else
+ msg = tm.toString();
+ break;
+ }
+ }
+
+ JasonException e = new JasonException(msg);
+ for (Term t: args) {
+ if (t != smsg)
+ e.addErrorAnnot(t);
+ }
+ throw e;
+ }
return false;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-10-30 16:45:07
|
Revision: 1405
http://jason.svn.sourceforge.net/jason/?rev=1405&view=rev
Author: jomifred
Date: 2008-10-30 16:45:03 +0000 (Thu, 30 Oct 2008)
Log Message:
-----------
move to jade 3.6
Modified Paths:
--------------
trunk/lib/http.jar
trunk/lib/jade.jar
trunk/lib/jadeTools.jar
trunk/src/jason/infra/jade/RunJadeMAS.java
Added Paths:
-----------
trunk/applications/jason-team/doc/cowz.txt
Added: trunk/applications/jason-team/doc/cowz.txt
===================================================================
--- trunk/applications/jason-team/doc/cowz.txt (rev 0)
+++ trunk/applications/jason-team/doc/cowz.txt 2008-10-30 16:45:03 UTC (rev 1405)
@@ -0,0 +1,4526 @@
+ --==>> THE COMPLETE GUIDE TO COWS <<==--
+ as you've NEVER seen them before!
+- - - - - - - - - - - - - - - - - - - - - - - - -
+
+ (__) (__) (__) (__)
+ (oo) (oo) (oo) (oo)
+ /-------\/ /-------\/ /-------\/ /-------\/
+ / | || / | || / | || / | ||
+* ||----|| * ||W---|| * ||w---|| * ||V---||
+ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^
+ Cow Cow laden Same cow Nancy Reagan-type
+ with milk after milking cow with milk
+
+
+ (___) (___) * (___) (___)
+ (o o) (o o) \ (o o) (o o)
+ /-------\ / /-------\ / \-------\ / /-------\ /
+ / | ||O / | ||O | ||O / | ~#>-+|O *
+* ||@\--|| ||,---|| * ||,----| ||,---||
+ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^
+ Bull Same bull after Rotc bull after Red-blooded American Bull
+ seeing above cow seeing other bull shooting the Rotc
+
+
+
+
+
+
+
+ (__) (__) (__) (__)
+ (oo) (oo) (oo) (oo)
+ /-------\/-* /-------\/ /-------\/ ~~~~~~~~~~~~~~~~~~~~~
+ / | || \ )*)(\/* / * / | ||
+* ||----|| * \ |||/)|/()( ~~~~~~~~~~~~~~
+\/|(/)(/\/(,,/ \)|(/\/|)(/\
+ Cow munching Grass munching Cow in water Cow in trouble
+ on grass on cow
+
+ (__) (__) * (__) * (__)
+ (oo) (oo) \ (oo) | (oo)
+ /--------\/ /-oooooo-\/ \-------\/ \-------\/
+ * o| || * ooooooooo o o| || / ||
+ ||----|| ooooooooooooo ||----||>==/-----||
+ ooo^^ ^^ ooooooooooooooooo ^^ ^^ ^^
+ Cow taking Cow in deep Cow getting the shit
+ a shit shit kicked out of her
+
+
+ (__)
+ (oo) U
+ /-------\/ /---V
+ / | || * |--| .
+* ||----||
+ ^^ ^^
+
+Cow at 1 meter. Cow at 100 meters. Cow at 10,000 meters.
+
+
+
+ (__) )__( vv vv
+ (oo) (oo) ||----|| *
+ /-------\/ *-------\/ || | /
+ / | || / | || /\-------/
+* ||----|| / ||----|| (oo)
+ ^^ ^^ vv vv (~~)
+
+American Cow Polish Cow Australian Cow
+
+
+
+ (__) (__) (__)
+ (oo) ____ (oo) _---_(oo)
+ /-------\/ /- --\/ /- -\/
+ / | || / | || /| ||
+* ||----|| * ||___-|| * ||___-||
+ ^^ ^^ ^^ ^^ ^^ ^^
+
+Freshman Cow at Freshman Cow Freshman Cow
+start of school After the "Freshman 15" After the "Freshman 20"
+
+
+ (__) (__) (__)
+ (OO) (@@) (xx)
+ /-------\/ /-------\/ /-------\/
+ / | || / | || / | ||
+* ||----|| * ||----|| * ||----||
+ ^^ ^^ ^^ ^^ ^^ ^^
+
+Cow who drank Jolt Cow who ate Cow who used Jolt to wash
+ psychadelic mushrooms down psychadelic mushrooms
+
+
+ /\ __
+ / \ ||
+ (__) (__) \ / (_||_)
+ SooS (oo) \/ (oo)
+ /------S\/S /-------\/ /S /-------\/
+ / | || / | || / S / | ||
+ * ||----|| * ||----||___/ S * ||----||
+ ^^ ^^ ^^ ^^ ^^ ^^
+ This cow belonged Ben Franklin owned Abe Lincoln's
+ to George Washington this cow cow
+
+
+ (__)
+ * (__) (oo)
+ \ (oo) /------\/
+ \-------\/ /| |/ |
+ | ==$ || / | [) ||
+ ||----|| * ||----||
+ ^^ ^^ ^^ ^^
+ Old "One Arm" belonged This cow was given to
+ to Ceasar's Palace Hugh Hefner for his Birthday
+
+
+ (___) (__) (__)
+ ( O ) (oo) (oo)
+ /-------\ / \/--------\/
+ / | ||V | |
+ * ||----|| ||------||
+ ^^ ^^ ^^ ^^
+ The cyclops that Jason and This cow lived with
+ cow had four legs or e
+
+
+
+ O__O \_|_/
+ (oo) (oo)
+ /-------\/ /-------\/
+ / | || / | ||
+ * ||----|| * ||----||
+ ^^ ^^ ^^ ^^
+ Cow at Disneyland Cow visiting the Statue of Liberty
+
+
+
+ (__) (__)
+ ^^ (oo) (--)
+ ^^^^ /-------\/ /-\/-\
+ ^^^^^ / | || /| |\
+ ^^^^^ * ||----|| ^ | | ^
+ ^^^^^^^^ ====^^====^^==== | |
+^^^^^^^^^^^^^/ /----\
+^^^^^^^^^^^^^^^^^^ / \ \
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ * ^
+ Cow Hanging Ten at Malibu Cow sunning at Fort Lauderdale
+ (What a bod, huh guys?)
+
+
+ )\ (__)
+ / \ (oo)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Cow swimming at Amityville
+(Where Jaws was filmed, for those less educated)
+
+
+ * (__)
+ \ (DD)
+ \ /-------\/
+ |\ / | ||_\_/
+ \ | \ (__) * ||----|
+ \\|| \(oo) ^^ ^
+ \||\ \\/ Cow chugging brews and staring at
+ ^^ \|| sunbathers at Fort Lauderdale
+ \\ ||
+ \\||
+ \||
+ ^^ / / / / / / / / / / /
+ \\_ / / / / / / / / / / / /
+ \_ / / / / / _______ / /
+ Cow skiing a Black Diamond at Aspen / / / / | \ / /
+ / / / (__)| / /
+ / / / (oo)| / /
+ ( @@@ ) /-------\/ |
+ ( @@ ) (------------) / | ||^_|
+ @@ (__) ( *>COUGH<* ) * ||----|
+ @@ (oo) . . . ( *>COUGH<* ) ^^ ^
+ /--UU--\/ (____________)
+ / | || Cow sheltering from English Weather
+ * ||---||
+
+ (New) Jersey Cow
+
+
+ O O O O
+ \ \ / /
+ \ \ (__) /
+ (__) \ \ (xx)/
+ (DD) \ +--------+\//
+ /-------\/ \| | /
+ / | || +--------+
+ * ||----||
+ ^^ ^^
+Cow fantasizing about "Riding the Mechanical Bull"
+ at Gillies in Texas
+
+
+ o o
+ |__| (__) (__)
+ (oo) (oo) =(oo)= oo
+ /-------\/ /-------vv /-------\/
+ / | || / | || / | ||
+* ||----|| * ||----|| * ||----||
+ ~~ ~~ ~~ ~~ ~~ ~~
+ bill bixby bela lugosi boris karloff claude rains
+ male relative cow cow cow
+ cow
+
+
+
+
+
+ x
+ xxxx|xxxx
+ xxxxxxx|xxxxxxx
+ |
+ //
+ (__) // (__) (__)
+ (oo)// (oo)===(oo)
+ /-------\// /-------\/ \/-------\
+ / | |// / | || || | \
+ * ||----| * ||----|| ||----|| *
+ ^^ ^^ ^^ ^^ ^^ ^^
+ Julie Andrews Cow Siamese cows
+
+
+ o o (__) ^
+ \ / (oo) /
+ \ / _____\/___/
+ (__) \__/ / /\ / /
+ (oo) _______(oo) ^ / * /
+ /---------\/ /| ___ \/ / ___/
+ / | x=a(b)|| / | { }|| *----/\
+ * ||------|| * ||{___}|| / \
+ ^^ ^^ ||-----|| / /
+ ^^ ^^ ^ ^
+
+ Mathematical Television This cow does Disco
+ Cow Cow (That's what comes of
+ (developer of (Cow-thode snorting cow-caine)
+ cow-culus) Ray Tube)
+
+
+
+ o
+ | [---]
+ | |
+ | | |------========|
+ /----|---|\ | **** |=======|
+ /___/___\___\ o | **** |=======|
+ | | ___| |==============|
+ | | ___ {(__)} |==============|
+ \-----------/ []( )={(oo)} |==============|
+ \ \ / / /---===--{ \/ } |
+ ----------------- / | NASA |==== |
+ | | * ||------||-----^
+ ----------------- || | |
+ / / \ \ ^^ ^ |
+ / ---- \
+ ^^ ^^ This cow jumped over the Moon
+
+
+
+
+ (__)
+ ([][]) "I have this recurring dream
+ __\/_--U about golden arches.".. (__)
+ /\ \__ ^ :..("")
+ /\\\ / / //\ ____\_____\/ //
+ /----^/__/\ /\ // \\/ \___ / //
+ \\\____/--\-- // /-/__________/ //
+ | | | H H ||
+ |_____________|_____________| H H ||
+ ^^^^^^^^^^^^^^^^^^ ^^^^^^^
+ Some cows get in trouble... Cattle Guard
+
+
+ ( ( )
+ ( ( ) )
+ ( ( )
+ ( / )
+ ( ( \\ )
+ ( | // )
+ | | (__)
+ | | (oo) (__)
+ | | ----\/ ______(oo)_____
+ | | || ( _)_______(__) )
+ **| | ---|| \ __________/
+ ``'---------^^
+ Cow Hide Cow Pie
+
+
+ \ | / ___________
+ ____________ \ \_# / | ___ | _________
+ | | \ #/ | | | | | = = = = |
+ | | | | | \\# | |`v'| | | |
+ | | \# // | --- ___ | | | || | |
+ | | | | | #_// | | | | | |
+ | | \\ #_/_______ | | | | | | || | |
+ | | | | | \\# /_____/ \ | --- | | |
+ | | \# |+ ++| | | |^^^^^^| | | | || | |
+ | | \# |+ ++| | | |^^^^^^| | | | || | |
+^^^| (^^^^^) |^^^^^#^| H |_ |^| | |||| | |^^^^^^| |
+ | ( ||| ) | # ^^^^^^ | | |||| | | | ||||||| |
+ ^^^^^^^^^^^^^________/ /_____ | | |||| | | | ||||||| |
+ `v'- ^^^^^^^^^^^^^ | ||||||| |
+ || |`. (__) (__) ( )
+ (oo) (oo) /---V
+ /-------\/ \/ --------\ * | |
+ / | || ||_______| \
+ * ||W---|| || || *
+ ^^ ^^ ^^ ^^
+
+ "Cow Town"
+
+
+ \ (__) (__)
+ \\(oo) (\/)
+ /-----\\\/ /-------\/
+ / | (##) / | ||
+ * ||----||" * ||----||
+ ^^ ^^ ~~ ~~
+ This cow plays bagpipes. Cow from Beijing
+
+
+ (__) (__) (__)
+ (\/) ($$) (**)
+ /-------\/ /-------\/ /-------\/
+ / | 666 || / |=====|| / | ||
+* ||----|| * ||----|| * ||----||
+ ^^ ^^ ^^ ^^ ^^ ^^
+
+Satanic cow This cow is a Yuppie Cow in love
+
+
+ (__) (__)
+ (oo) (oo)
+ /-'''''-\/ /-------------------\/
+ / |'''''|| / | ||
+* ||''''|| * ||----------------||
+ ^^ ^^ ^^ ^^
+ Cow in Argyle Stretch Cow
+ *
+ ** **
+ * ** * * * **
+ * / / \ * *
+ \ \ / \ / / (__)
+ * / / \ \ (__) \ \ /--------(00)
+ / (00) / / / | |( )
+ \ /-------\/ \ \ * ||---- ||()
+ / / | || / / || ||
+ \ \ * ||----|| \ \ ^^ ^^
+ / / ^^ ^^ / / Cow Chewing Marbles
+ Cow in Heat
+
+
+ (___)
+ (o o)
+ /------\ / (__) (__)
+ / ____O (oo) (oo)
+ | / /----\----\/ /-------\/
+ /\oo===| / || / | ||
+ | || *||^-----|| * OO----OO
+ * ^^ ^^ ^^
+ Cowt in the Act low rider cow
+
+
+
+ (__) \__\ (__)
+ (oo) o (oo) (oo)
+ /-------\/ ____\___\/ *+-------\/
+ / | || / | || ||______||
+* ||----|| * ||----|| ||----||
+ OO OO OO OO OO OO
+Detroit cow Mustang cow pickup cow
+
+
+ (__) (__) \_||_~
+ (oo) (oo) (*||*)
+ /---------------\/ /----\/ /-------\||/
+ / | || / || / | ||
+* ||------------|| *-||----|| * ||----||
+ OO OO OO OO OO }{
+ li-moo-cow fastback cow teenager's cow
+
+
+ ____
+ (____)
+ .xxxx.
+ (__) '(oo)`
+ (oo) /-----'-\/ `
+ /-------\/ / | |============>
+ / | || * ||----| (~)
+* ||----|| ~~ ~
+ ~~ ~~ Moo-ammar Cowdafi
+ holy cow armed and dangerous
+
+
+ (___) (___)
+ (o o) (o o)
+ /-------\ / /-------\ /
+ / | ||O / | O~ ||O
+* ||,---|| * ||,---||
+ ^^ ^^ ^^ ^^
+ A Bull A-bomb-in-a-bull No-bull
+
+
+
+
+
+ (---)
+ ( )
+ /-----\ (___)
+ | | (o o)
+ | | | (-----) \ /
+ | | | / / \ O
+ | * | * | O |
+ ^^ ^^ -----
+ Coward Phone Bull
+
+
+
+ |______| ^^ |______| . : \ (oo)
+ . (__||__) . . : \-------\/
+ . /_\ /_\ . . . : 8-| ||
+ !!! !!! : ||----||
+ : ^^ ^^
+ The cow that jumped over the moon. : Flying Cow
+
+
+
+
+
+
+ ...---...
+ ../ / | \ \..
+ ./ / / | \ \ \.
+ / / / | \ \ \
+ / / / | \ \ \
+ ^^^^^^^^^^^^^^^^^^^^^^^
+ \ | /
+ \ | /
+ \ | /
+ \ | /
+ \ | /
+ \ | /
+ \ | /
+ \ | /
+ \ | /
+ \ | /(__)
+ \|/ (oo)
+ /---++--\/
+ / | || ||
+ * ||-++-||
+ ^^ ^^ Cow surviving attack by Red Baron
+
+
+
+
+ ..---.. (__)
+ / \ (oo)
+ | RIP | /-------\/
+ | | / | ||
+ | | * ||----||
+ | | ^^ ^^
+ | |
+ \\\\\\\\\\\\\\\\\/////////////////
+
+ Elvis's Cow.....Or is it alive and living in tax exile???
+
+
+ (__)
+ (oo)
+ /---+ +--\/
+ / | | | ||
+ * ||-+ +-||
+ ^^ ^^ *
+
+ David Copperfield's Cow David Copperfield's other Cow
+
+
+
+ (__)
+ (oo)
+ /-------\/
+ / | ||
+ * ||----||
+ ^^ ^^
+ (__) (__)
+ (oo) (oo)
+ /-------\/ \/-------\
+ / | || -^^- || | \
+ * ||---- -^^- || *
+ ^^ ^^
+ (__) (__)
+ (oo) (oo)
+ /-------\/ \/-------\
+ / | || || | \
+ * ||----|| ||----|| *
+ ^^ ^^ ^^ ^^
+ Barnum's Troupe of performing cows
+
+
+
+ (__) _--------_
+ (oo) |__________| BIG
+ /-------\/ XXXXXXXXXX MAC
+ / | 007 || __________
+ * ||----|| |_ _|
+ ^^ ^^ --------
+ Cow licenced to kill Enemy Cow after having met previous cow
+
+
+ (__)
+ (oo)
+ /'^^^-m
+ (__) / '' ` )
+ (oo) o /| /|/|_ | /|
+ / \/ / / _ / | | | |
+ / _\===^ ___\_____/___ |_____|_|
+ ___|__/ |/\ (___________(_) //|| ||
+ * ^ ^ * ww ww
+
+ Mrs. O'Leary's Cow Cow'nt Dracula
+
+
+
+
+ _(__)_ \ ----------------------------------
+ o ( oo /_______________________| (oo) \ | __
+ | _/\_| | M O O - B U S T E R S|__\/\ /| | /oo| - Bleaurgh!
+ |-| \\____ ------ )_ /| /\
+ -|_ \_|-_|^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 _| * \/ *
+ \ | __________________________________/
+ | W| \ \_/ /----------------- \ \_/ /
+ / /\ \ \___/ \___/
+ / / \ \
+ ^^^ ^^^ Who you gonna call...?
+
+
+ (__) (__) (__) (----------)
+ (00) (-o) (--) . . . ( *>YAWN<* )
+ /------\/ /------\/ /------\/ (----------)
+ /| || /| || /| ||
+ * ||----|| * ||----|| * ||----||
+
+Cow w/ Glasses Flirtatious cow (winking) Cow after pulling an all nighter
+
+
+ * (__) (__) (__) (__)
+ \ (oo) (oo) (oo) (oo)
+ \-------\/ /-------\/ /-------\/ /-------\/
+ /| |\ / / \ / \ / / \ \
+ //||----||\\ * //------\\ * \\--// * \\----\\
+ ^ ^^ ^^ ^ ^ ^ ^ ^ ^ ^
+ Cow walking Cow jogging Same cow Cow breaking
+
+
+
+ (__)
+ (oo) (__) o * (__)
+ \/ (oo)/ " | (oo)
+ ____| \____ /-------\/(__ o=o=o=|------\/
+ ---/ --** / | / | |
+ *____/ |___// * ||----|| ||----||
+ //--------/ ^^ ^^ ^^ ^^
+
+ |
+ |
+ |
+ |(push)
+ |
+ (__) |=====|
+ (==) \
+ /-\/-\ \
+ /| |\ \
+ ^ | | ^====~~~~==== \
+ | | \
+ /----\ \
+ / \ \ O O O O
+ ^ * ^ === / /
+ \ \ (__) /
+ Cow-abunga Dudes \ \ (xx)/
+ \ +--------+\//
+ \| | /
+ +--------+
+
+ Cow-a-bungee
+
+ ______________
+ | D.A.B.'S | (__) (__) (__) (__)
+ | USED | (uu) (uu) (uu) (uu)
+ | COWS | /-------\/ /-------\/ /-------\/ /-------\/
+ |____________| / | || / | || / | || / | ||
+ || * ||----|| * ||----|| * ||----|| * ||----||
+ || ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
+ ______||_______
+ | EASY CREDIT | (__) (__) (__) (__)
+ |_____________| (uu) (uu) (uu) (uu)
+ || /-------\/ /-------\/ /-------\/ /-------\/
+ || / | || / | || / | || / | ||
+ || * ||----|| * ||----|| * ||----|| * ||----||
+ || ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
+
+
+ (__) (__) (__) (__)
+ (oo) (oo) (oo) (oo)
+ /-------\/ /-------\/ /-------\/ /-------\/
+ / | || / | || / | || / | ||
+* ||----|| * ||W---|| * ||w---|| * ||V---||
+ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^
+ Cow Cow laden Same cow Nancy Reagan-type
+ with milk after milking cow with milk
+
+ (___) (___) * (___) (___)
+ (o o) (o o) \ (o o) (o o)
+ /-------\ / /-------\ / \-------\ / /-------\ /
+ / | ||O / | ||O | ||O / | ~#>-+|O
+* ||,---|| * ||@\--|| ||,---|| * ||,----|
+ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^
+ Bull Same bull after Rotc bull after Red-blooded American Bull
+ seeing above cow seeing other bull shooting the Rotc bull
+
+
+
+ (__) (__) (__) (__)
+ (oo) (oo) (oo) (oo)
+ /-------\/-* /-------\/ /-------\/ ~~~~~~~~~~~~~~~~~~~~~
+ / | || \ )*)(\/* / * / | ||
+* ||----|| * \ |||/)|/()( ~~~~~~~~~~~~~~
+\/|(/)(/\/(,,/ \)|(/\/|)(/\
+ Cow munching Grass munching Cow in water Cow in trouble
+ on grass on cow
+
+ (__) (__) * (__) * (__)
+ (oo) (oo) \ (oo) | (oo)
+ /--------\/ /-oooooo-\/ \-------\/ \-------\/
+ * o| || * ooooooooo o o| || / ||
+ ||----|| ooooooooooooo ||----||>==/-----||
+ ooo^^ ^^ ooooooooooooooooo ^^ ^^ ^^
+ Cow taking Cow in deep Cow getting the shit
+ a shit shit kicked out of her
+
+
+ (__)
+ (oo) U
+ /-------\/ /---V
+ / | || * |--| .
+* ||----||
+ ^^ ^^
+
+Cow at 1 meter. Cow at 100 meters. Cow at 10,000 meters.
+
+
+
+ (__) )__( vv vv
+ (oo) (oo) ||----|| *
+ /-------\/ *-------\/ || | /
+ / | || / | || /\-------/
+* ||----|| / ||----|| (oo)
+ ^^ ^^ vv vv (~~)
+
+American Cow Polish Cow Australian Cow
+
+
+
+ (__) (__) (__)
+ (oo) ____ (oo) _---_(oo)
+ /-------\/ /- --\/ /- -\/
+ / | || / | || /| ||
+* ||----|| * ||___-|| * ||___-||
+ ^^ ^^ ^^ ^^ ^^ ^^
+
+Freshman Cow at Freshman Cow Freshman Cow
+start of school After the "Freshman 15" After the "Freshman 20"
+
+
+ (__) (__) (__)
+ (OO) (@@) (xx)
+ /-------\/ /-------\/ /-------\/
+ / | || / | || / | ||
+* ||----|| * ||----|| * ||----||
+ ^^ ^^ ^^ ^^ ^^ ^^
+
+Cow who drank Jolt Cow who ate Cow who used Jolt to wash
+ psychadelic mushrooms down psychadelic mushrooms
+
+
+ /\ __
+ / \ ||
+ (__) (__) \ / (_||_)
+ SooS (oo) \/ (oo)
+ /---...
[truncated message content] |
|
From: <jom...@us...> - 2008-10-31 10:46:43
|
Revision: 1406
http://jason.svn.sourceforge.net/jason/?rev=1406&view=rev
Author: jomifred
Date: 2008-10-31 10:46:35 +0000 (Fri, 31 Oct 2008)
Log Message:
-----------
update eclipse plugin for version 1.2
Modified Paths:
--------------
trunk/applications/jason-eclipse-plugin/META-INF/MANIFEST.MF
trunk/applications/jason-eclipse-plugin/build.xml
trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/ASLEditor.java
trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/MAS2JEditor.java
trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/swtContainers/MAS2JDesignComposite.java
trunk/release-notes.txt
Modified: trunk/applications/jason-eclipse-plugin/META-INF/MANIFEST.MF
===================================================================
--- trunk/applications/jason-eclipse-plugin/META-INF/MANIFEST.MF 2008-10-30 16:45:03 UTC (rev 1405)
+++ trunk/applications/jason-eclipse-plugin/META-INF/MANIFEST.MF 2008-10-31 10:46:35 UTC (rev 1406)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: JasonIDE Plug-in
Bundle-SymbolicName: net.sourceforge.jasonide;singleton:=true
-Bundle-Version: 1.1.1
+Bundle-Version: 1.2
Bundle-Activator: net.sourceforge.jasonide.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
Modified: trunk/applications/jason-eclipse-plugin/build.xml
===================================================================
--- trunk/applications/jason-eclipse-plugin/build.xml 2008-10-30 16:45:03 UTC (rev 1405)
+++ trunk/applications/jason-eclipse-plugin/build.xml 2008-10-31 10:46:35 UTC (rev 1406)
@@ -12,7 +12,7 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="1.2" />
+ <property name="release" value="2" />
<property name="distDir" value="${basedir}/dist" />
<property name="distDirPlugins" value="${distDir}/plugins" />
Modified: trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/ASLEditor.java
===================================================================
--- trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/ASLEditor.java 2008-10-30 16:45:03 UTC (rev 1405)
+++ trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/ASLEditor.java 2008-10-31 10:46:35 UTC (rev 1406)
@@ -1,6 +1,7 @@
package net.sourceforge.jasonide.editors;
import jason.JasonException;
+import jason.asSemantics.Agent;
import java.io.File;
import java.io.FileNotFoundException;
@@ -52,7 +53,9 @@
String asfileName = iproject.getLocation().toString() + getFilePathWithoutProjectName(ifile);
jason.asSyntax.parser.as2j parser = new jason.asSyntax.parser.as2j(new FileReader(new File(asfileName)));
if (parser != null) {
- parser.agent(null);
+ Agent ag = new Agent();
+ ag.setASLSrc(asfileName);
+ parser.agent(ag);
}
} catch (FileNotFoundException e) {
@@ -62,8 +65,8 @@
showError(msg, e);
} catch (jason.asSyntax.parser.ParseException e) {
String msg = e.getMessage();
-
- int lineError = PluginMarkerUtils.getLineNumberFromMsg(msg);
+
+ int lineError = e.currentToken.beginLine; //PluginMarkerUtils.getLineNumberFromMsg(msg);
PluginMarkerUtils.createMarker(ifile, e.getMessage().replace("\r", "").replace("\n", ""),
lineError,
PluginMarkerUtils.getCharStart(document.get(), lineError, msg),
Modified: trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/MAS2JEditor.java
===================================================================
--- trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/MAS2JEditor.java 2008-10-30 16:45:03 UTC (rev 1405)
+++ trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/MAS2JEditor.java 2008-10-31 10:46:35 UTC (rev 1406)
@@ -178,7 +178,7 @@
} catch (ParseException e) {
try {
String msg = e.getMessage();
- int lineError = PluginMarkerUtils.getLineNumberFromMsg(msg);
+ int lineError = e.currentToken.beginLine; //PluginMarkerUtils.getLineNumberFromMsg(msg);
PluginMarkerUtils.createMarker(ifile, e.getMessage().replace("\r", "").replace("\n", ""),
lineError,
PluginMarkerUtils.getCharStart(document.get(), lineError, msg),
Modified: trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/swtContainers/MAS2JDesignComposite.java
===================================================================
--- trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/swtContainers/MAS2JDesignComposite.java 2008-10-30 16:45:03 UTC (rev 1405)
+++ trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/editors/swtContainers/MAS2JDesignComposite.java 2008-10-31 10:46:35 UTC (rev 1406)
@@ -248,10 +248,10 @@
ClassParameters envClass = project2.getEnvClass();
if (envClass != null) {
if (!tEnvironmentHost.getText().equals("")) {
- envClass.host = "\"" + tEnvironmentHost.getText() + "\"";
+ envClass.setHost("\"" + tEnvironmentHost.getText() + "\"");
}
else {
- envClass.host = null;
+ envClass.setHost(null);
}
}
@@ -405,10 +405,10 @@
ClassParameters controlClass = project2.getControlClass();
if (controlClass != null) {
if (!tExeControlHost.getText().equals("")) {
- controlClass.host = "\"" + tExeControlHost.getText() + "\"";
+ controlClass.setHost("\"" + tExeControlHost.getText() + "\"");
}
else {
- controlClass.host = null;
+ controlClass.setHost(null);
}
}
@@ -924,11 +924,11 @@
}
public void setEnv(ClassParameters clazz) {
- if (clazz != null && (!clazz.className.equals(jason.environment.Environment.class.getName()))) {
+ if (clazz != null && (!clazz.getClassName().equals(jason.environment.Environment.class.getName()))) {
tEnvironment.setText(clazz.toString());
- if (clazz.host != null) {
- tEnvironmentHost.setText(clazz.host.replace("\"", ""));
+ if (clazz.getHost() != null) {
+ tEnvironmentHost.setText(clazz.getHost().replace("\"", ""));
}
else {
tEnvironmentHost.setText("");
@@ -944,8 +944,8 @@
if (clazz != null) {
tExeControl.setText(clazz.toString());
- if (clazz.host != null) {
- tExeControlHost.setText(clazz.host.replace("\"", ""));
+ if (clazz.getHost() != null) {
+ tExeControlHost.setText(clazz.getHost().replace("\"", ""));
}
else {
tExeControlHost.setText("");
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-10-30 16:45:03 UTC (rev 1405)
+++ trunk/release-notes.txt 2008-10-31 10:46:35 UTC (rev 1406)
@@ -29,6 +29,8 @@
see demo/failure for an example
see code of JasonException and TS for more information
+. the version of JADE is upgraded to 3.6
+
New internal actions
. .term2string: transform term into strings and vice-versa.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-11-02 11:55:05
|
Revision: 1407
http://jason.svn.sourceforge.net/jason/?rev=1407&view=rev
Author: jomifred
Date: 2008-11-02 11:55:03 +0000 (Sun, 02 Nov 2008)
Log Message:
-----------
jason-moise: produce failure events for org. actions with new error annotations.
Modified Paths:
--------------
trunk/applications/jason-moise/example/writePaper/jaime.asl
trunk/applications/jason-moise/src/jmoise/OrgAgent.java
trunk/release-notes.txt
trunk/src/jason/asSemantics/ConcurrentInternalAction.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/bb/JDBCPersistentBB.java
Modified: trunk/applications/jason-moise/example/writePaper/jaime.asl
===================================================================
--- trunk/applications/jason-moise/example/writePaper/jaime.asl 2008-10-31 10:46:35 UTC (rev 1406)
+++ trunk/applications/jason-moise/example/writePaper/jaime.asl 2008-11-02 11:55:03 UTC (rev 1407)
@@ -15,11 +15,12 @@
// create a group to write a paper
+!create_group : true
<- //.send(orgManager, achieve, create_group(wpgroup)).
- jmoise.create_group(wpgroup,G);
+ jmoise.create_group(wpgroupa,G);
.print("Group ",G," created").
+-!create_group[error_msg(M),code(C),code_line(L)]
+ <- .print("Error creating group, command: ",C,", line ",L,", message: ",M).
-
/* Organisational Events */
/* Structural events */
Modified: trunk/applications/jason-moise/src/jmoise/OrgAgent.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-10-31 10:46:35 UTC (rev 1406)
+++ trunk/applications/jason-moise/src/jmoise/OrgAgent.java 2008-11-02 11:55:03 UTC (rev 1407)
@@ -10,16 +10,16 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Circumstance;
import jason.asSemantics.Event;
+import jason.asSemantics.IntendedMeans;
import jason.asSemantics.Intention;
import jason.asSemantics.Message;
import jason.asSemantics.Unifier;
import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
-import jason.asSyntax.InternalActionLiteral;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.LiteralImpl;
-import jason.asSyntax.PlanBody;
-import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Pred;
import jason.asSyntax.PredicateIndicator;
import jason.asSyntax.Structure;
@@ -27,7 +27,6 @@
import jason.asSyntax.Trigger;
import jason.asSyntax.UnnamedVar;
import jason.asSyntax.VarTerm;
-import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.asSyntax.parser.ParseException;
@@ -317,23 +316,32 @@
private void resumeIntention(Intention pi, String content, Circumstance C) {
pi.setSuspended(false);
- C.addIntention(pi); // add it back in I
- Structure body = (Structure)pi.peek().removeCurrentStep(); // remove the internal action
- if (content.startsWith("error")) {
- // fail the IA
- PlanBody pbody = pi.peek().getPlan().getBody();
- Literal fail = new InternalActionLiteral(".fail");
- String msg = content.substring(7,content.length()-2);
- fail.addTerm(createStructure("error_msg", createString(msg)));
- fail.addTerm(createStructure("code", createString(body.toString())));
- if (body.getSrcInfo() != null) {
- fail.addTerm(createStructure("code_src", createString(body.getSrcInfo().getSrcFile())));
- fail.addTerm(createStructure("code_line", createNumber(body.getSrcInfo().getBeginSrcLine())));
+ if (content.startsWith("error")) { // fail the IA
+ IntendedMeans im = pi.peek();
+ Event failEvent = getTS().findEventForFailure(pi, im.getTrigger());
+ if (failEvent != null) {
+ Structure body = (Structure)im.getCurrentStep().getBodyTerm(); // get the internal action
+
+ ListTerm failAnnots = new ListTermImpl(); // create a list of error annotations
+ String msg = content.substring(7,content.length()-2);
+ failAnnots.add(createStructure("error", new Atom("org_error")));
+ failAnnots.add(createStructure("error_msg", createString(msg)));
+ failAnnots.add(createStructure("code", createString(body.toString())));
+ if (body.getSrcInfo() != null) {
+ failAnnots.add(createStructure("code_src", createString(body.getSrcInfo().getSrcFile())));
+ failAnnots.add(createStructure("code_line", createNumber(body.getSrcInfo().getBeginSrcLine())));
+ }
+ failEvent.getTrigger().getLiteral().addAnnots(failAnnots);
+ C.addEvent(failEvent);
+ if (logger.isLoggable(Level.FINE)) logger.fine("Generating goal deletion " + failEvent.getTrigger() + " from goal: " + im.getTrigger());
+ } else {
+ logger.warning("No fail event was generated for " + im.getTrigger());
}
- pbody.add(0, new PlanBodyImpl(BodyType.internalAction, fail));
- //getTS().getLogger().warning("Error in organisational action '"+body+"': "+content);
} else {
+ C.addIntention(pi); // add the intention back in I
+ Structure body = (Structure)pi.peek().removeCurrentStep(); // remove the internal action
+
// try to unify the return value
//System.out.println("answer is "+content+" or "+DefaultTerm.parse(content)+" with body "+body);
// if the last arg of body is a free var
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-10-31 10:46:35 UTC (rev 1406)
+++ trunk/release-notes.txt 2008-11-02 11:55:03 UTC (rev 1407)
@@ -31,6 +31,15 @@
. the version of JADE is upgraded to 3.6
+. new base class for internal actions: ConcurrentInternalAction. This
+ class can be used in place of DefaultInternalAction to create an IA
+ that suspend the intention while it is being executed. For example:
+ a plan may ask something to an user and wait the answer. If
+ DefaultInternalAction is used for that, all the agent thread is
+ blocked until the answer. With ConcurrentInternalAction, only the
+ intention using the IA is suspended. See demos/gui/gui1 and the API
+ doc of the new class.
+
New internal actions
. .term2string: transform term into strings and vice-versa.
Modified: trunk/src/jason/asSemantics/ConcurrentInternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-10-31 10:46:35 UTC (rev 1406)
+++ trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-11-02 11:55:03 UTC (rev 1407)
@@ -15,7 +15,7 @@
Example: a plan may ask something to an user and wait the answer.
If DefaultInternalAction is used for that, all the agent thread is blocked until
- the answer. With SuspendInternalAction, only the intention using the IA is
+ the answer. With ConcurrentInternalAction, only the intention using the IA is
suspended. See demos/gui/gui1.
The code of an internal action that extends this class looks like:
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-10-31 10:46:35 UTC (rev 1406)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-11-02 11:55:03 UTC (rev 1407)
@@ -870,6 +870,8 @@
}
private static final Atom aNOCODE = new Atom("no_code");
+
+ /** add default error annotations (error, error_msg, code, code_src, code_line) in the failure event */
private static void setDefaultFailureAnnots(Event failEvent, Term body, List<Term> failAnnots) {
// add default failure annots
if (failAnnots == null)
Modified: trunk/src/jason/bb/JDBCPersistentBB.java
===================================================================
--- trunk/src/jason/bb/JDBCPersistentBB.java 2008-10-31 10:46:35 UTC (rev 1406)
+++ trunk/src/jason/bb/JDBCPersistentBB.java 2008-11-02 11:55:03 UTC (rev 1407)
@@ -8,6 +8,7 @@
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.LiteralImpl;
+import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.PredicateIndicator;
import jason.asSyntax.StringTerm;
@@ -23,6 +24,7 @@
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
+import java.sql.Timestamp;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Calendar;
@@ -461,7 +463,6 @@
/** translates the current line of a result set into a Literal */
- @SuppressWarnings("deprecation")
protected Literal resultSetToLiteral(ResultSet rs, PredicateIndicator pi) throws SQLException {
ResultSetMetaData meta = belsDB.get(pi);
boolean isJasonTable = isCreatedByJason(pi);
@@ -482,15 +483,7 @@
break;
case Types.TIMESTAMP:
- Calendar time = Calendar.getInstance();
- time.setTime(rs.getTimestamp(c));
- parsed = ASSyntax.createStructure("timestamp",
- createNumber(time.get(Calendar.YEAR)),
- createNumber(time.get(Calendar.MONTH)),
- createNumber(time.get(Calendar.DAY_OF_MONTH)),
- createNumber(time.get(Calendar.HOUR_OF_DAY)),
- createNumber(time.get(Calendar.MINUTE)),
- createNumber(time.get(Calendar.SECOND)));
+ parsed = timestamp2structure(rs.getTimestamp(c));
break;
default:
@@ -525,6 +518,7 @@
}
return ldb;
}
+
protected String getTableName(Literal l) throws SQLException {
return getTableName(l.getPredicateIndicator());
@@ -610,7 +604,12 @@
if (t.isString()) {
q.append("'" + ((StringTerm) t).getString() + "'");
} else {
- q.append("'" + t.toString() + "'");
+ Timestamp timestamp = structure2timestamp(t);
+ if (timestamp != null) {
+ q.append("TIMESTAMP '" + structure2timestamp(t) + "'");
+ } else {
+ q.append("'" + t.toString() + "'");
+ }
}
if (i < meta.getColumnCount() - 1) {
q.append(",");
@@ -664,4 +663,40 @@
}
}
}
+
+ public static final String timestampFunctor = "timestamp";
+
+ /** translates a SQL timestamp into a structure like "timestamp(Y,M,D,H,M,S)" */
+ public static Structure timestamp2structure(Timestamp timestamp) throws SQLException {
+ Calendar time = Calendar.getInstance();
+ time.setTime(timestamp);
+ return ASSyntax.createStructure(timestampFunctor,
+ createNumber(time.get(Calendar.YEAR)),
+ createNumber(time.get(Calendar.MONTH)),
+ createNumber(time.get(Calendar.DAY_OF_MONTH)),
+ createNumber(time.get(Calendar.HOUR_OF_DAY)),
+ createNumber(time.get(Calendar.MINUTE)),
+ createNumber(time.get(Calendar.SECOND)));
+ }
+
+ /** translates structure like "timestamp(Y,M,D,H,M,S)" into a SQL timestamp */
+ @SuppressWarnings("deprecation")
+ public static Timestamp structure2timestamp(Term timestamp) throws SQLException {
+ if (timestamp.isStructure()) {
+ Structure s = (Structure)timestamp;
+ if (s.getFunctor().equals(timestampFunctor) && s.getArity() == 6) {
+ return new Timestamp(
+ (int)((NumberTerm)s.getTerm(0)).solve() - 1900,
+ (int)((NumberTerm)s.getTerm(1)).solve(),
+ (int)((NumberTerm)s.getTerm(2)).solve(),
+ (int)((NumberTerm)s.getTerm(3)).solve(),
+ (int)((NumberTerm)s.getTerm(4)).solve(),
+ (int)((NumberTerm)s.getTerm(5)).solve(),
+ 0
+ );
+ }
+ }
+ return null;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-11-17 09:55:28
|
Revision: 1409
http://jason.svn.sourceforge.net/jason/?rev=1409&view=rev
Author: jomifred
Date: 2008-11-17 09:55:14 +0000 (Mon, 17 Nov 2008)
Log Message:
-----------
small update in file release-notes.
Modified Paths:
--------------
trunk/doc/faq/Makefile
trunk/release-notes.txt
Modified: trunk/doc/faq/Makefile
===================================================================
--- trunk/doc/faq/Makefile 2008-11-02 17:21:25 UTC (rev 1408)
+++ trunk/doc/faq/Makefile 2008-11-17 09:55:14 UTC (rev 1409)
@@ -18,4 +18,4 @@
find . -name *~ -exec rm {} \; || true
publish:
- scp html/*.html jom...@ss...:/home/groups/j/ja/jason/htdocs/faq
+ scp html/*.html jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/faq
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-11-02 17:21:25 UTC (rev 1408)
+++ trunk/release-notes.txt 2008-11-17 09:55:14 UTC (rev 1409)
@@ -40,6 +40,9 @@
intention using the IA is suspended. See demos/gui/gui1 and the API
doc of the new class.
+. API doc uses UMLGraph to show relations between classes
+
+
New internal actions
. .term2string: transform term into strings and vice-versa.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-11-23 22:00:31
|
Revision: 1410
http://jason.svn.sourceforge.net/jason/?rev=1410&view=rev
Author: jomifred
Date: 2008-11-23 22:00:29 +0000 (Sun, 23 Nov 2008)
Log Message:
-----------
fix problem in Rule clone method
Modified Paths:
--------------
trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j
trunk/demos/communication/Communication.mas2j
trunk/src/jason/asSyntax/Rule.java
Added Paths:
-----------
trunk/applications/jason-moise/example/moise-tutorial/logging.properties
trunk/demos/communication/logging.properties
Added: trunk/applications/jason-moise/example/moise-tutorial/logging.properties
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/logging.properties (rev 0)
+++ trunk/applications/jason-moise/example/moise-tutorial/logging.properties 2008-11-23 22:00:29 UTC (rev 1410)
@@ -0,0 +1,49 @@
+# Jason Default log configuration
+#
+# Comment/uncomment the following lines to setup your log
+#
+
+# default Jason MAS Console
+handlers = jason.runtime.MASConsoleLogHandler
+
+# To use the ConsoleHandler, use the following line instead.
+#handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default logging level. Other values are:
+# SEVERE (only severe messages)
+# WARNING (only warnings and severe messages)
+# INFO (normal output)
+# FINE (debug level of messages)
+.level = INFO
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# Jason Handler parameters
+jason.runtime.MASConsoleLogHandler.level = ALL
+jason.runtime.MASConsoleLogHandler.formatter = jason.runtime.MASConsoleLogFormatter
+# set one text area for each agent
+jason.runtime.MASConsoleLogHandler.tabbed = true
+
+# default file output is in project's directory.
+java.util.logging.FileHandler.pattern = mas.log
+#java.util.logging.FileHandler.pattern = mas-%u.log
+java.util.logging.FileHandler.limit = 500000
+java.util.logging.FileHandler.count = 1
+java.util.logging.FileHandler.formatter = jason.runtime.MASConsoleLogFormatter
+#java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to FINE and above.
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = jason.runtime.MASConsoleLogFormatter
+
+java.level=OFF
+javax.level=OFF
+sun.level=OFF
+jade.level=OFF
+
Modified: trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j 2008-11-17 09:55:14 UTC (rev 1409)
+++ trunk/applications/jason-moise/example/moise-tutorial/tutorial.mas2j 2008-11-23 22:00:29 UTC (rev 1410)
@@ -4,8 +4,8 @@
orgManager [osfile="../writePaper/wp-os.xml",gui=yes]
agentArchClass jmoise.OrgManager;
- marcos agentArchClass gui.OrgAgentGUI;
- lucio agentArchClass gui.OrgAgentGUI;
+ marcos agentArchClass gui.OrgAgentGUI;
+ lucio agentArchClass gui.OrgAgentGUI;
classpath: "../../lib/moise.jar";"../../lib/jmoise.jar";
}
Modified: trunk/demos/communication/Communication.mas2j
===================================================================
--- trunk/demos/communication/Communication.mas2j 2008-11-17 09:55:14 UTC (rev 1409)
+++ trunk/demos/communication/Communication.mas2j 2008-11-23 22:00:29 UTC (rev 1410)
@@ -13,6 +13,6 @@
agents:
bob;
- maria;
+ maria [verbose=1]; // set verbose=2 to see more details
}
Added: trunk/demos/communication/logging.properties
===================================================================
--- trunk/demos/communication/logging.properties (rev 0)
+++ trunk/demos/communication/logging.properties 2008-11-23 22:00:29 UTC (rev 1410)
@@ -0,0 +1,49 @@
+# Jason Default log configuration
+#
+# Comment/uncomment the following lines to setup your log
+#
+
+# default Jason MAS Console
+handlers = jason.runtime.MASConsoleLogHandler
+
+# To use the ConsoleHandler, use the following line instead.
+#handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default logging level. Other values are:
+# SEVERE (only severe messages)
+# WARNING (only warnings and severe messages)
+# INFO (normal output)
+# FINE (debug level of messages)
+.level = INFO
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# Jason Handler parameters
+jason.runtime.MASConsoleLogHandler.level = ALL
+jason.runtime.MASConsoleLogHandler.formatter = jason.runtime.MASConsoleLogFormatter
+# set one text area for each agent
+jason.runtime.MASConsoleLogHandler.tabbed = true
+
+# default file output is in project's directory.
+java.util.logging.FileHandler.pattern = mas.log
+#java.util.logging.FileHandler.pattern = mas-%u.log
+java.util.logging.FileHandler.limit = 500000
+java.util.logging.FileHandler.count = 1
+java.util.logging.FileHandler.formatter = jason.runtime.MASConsoleLogFormatter
+#java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to FINE and above.
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = jason.runtime.MASConsoleLogFormatter
+
+java.level=OFF
+javax.level=OFF
+sun.level=OFF
+jade.level=OFF
+
Modified: trunk/src/jason/asSyntax/Rule.java
===================================================================
--- trunk/src/jason/asSyntax/Rule.java 2008-11-17 09:55:14 UTC (rev 1409)
+++ trunk/src/jason/asSyntax/Rule.java 2008-11-23 22:00:29 UTC (rev 1410)
@@ -78,7 +78,7 @@
}
public Rule clone() {
- Rule r = new Rule(super.copy(), (LogicalFormula)body.clone());
+ Rule r = new Rule((Literal)super.clone(), (LogicalFormula)body.clone());
r.predicateIndicatorCache = null;
r.resetHashCodeCache();
return r;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-11-27 18:27:16
|
Revision: 1415
http://jason.svn.sourceforge.net/jason/?rev=1415&view=rev
Author: jomifred
Date: 2008-11-27 18:27:11 +0000 (Thu, 27 Nov 2008)
Log Message:
-----------
rename method in RunTimeServices
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgentConfigurator.java
trunk/doc/faq/faq.tex
trunk/src/jason/control/ExecutionControlGUI.java
trunk/src/jason/environment/SteppedEnvironment.java
trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java
trunk/src/jason/infra/centralised/KillAgentGUI.java
trunk/src/jason/infra/jade/JadeRuntimeServices.java
trunk/src/jason/infra/saci/SaciRuntimeServices.java
trunk/src/jason/runtime/RuntimeServicesInfraTier.java
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgentConfigurator.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgentConfigurator.java 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgentConfigurator.java 2008-11-27 18:27:11 UTC (rev 1415)
@@ -379,7 +379,7 @@
}
public Set<String> getKnownAgentNames(){
- return agent.getTS().getUserAgArch().getArchInfraTier().getRuntimeServices().getAgentsName();
+ return agent.getTS().getUserAgArch().getArchInfraTier().getRuntimeServices().getAgentsNames();
}
public float getTrustRating(Atom name) {
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/doc/faq/faq.tex 2008-11-27 18:27:11 UTC (rev 1415)
@@ -17,7 +17,7 @@
\html{\begin{rawhtml}<h0><b><i>Jason</i></b> FAQ
- <br><font size="-1">(for version 1.1)</font></h0>
+ <br><font size="-1">(for version 1.2)</font></h0>
\end{rawhtml}}
\latex{\begin{center}{\Huge\jason FAQ}\end{center}}
@@ -135,7 +135,7 @@
Once the environment is created before the agents, the set of agents
is empty when the environment is created and thus the method
-\texttt{getEnvironmentInfraTier().getRuntimeServices().getAgentsName()}
+\texttt{getEnvironmentInfraTier().getRuntimeServices().getAgentsNames()}
can not be used. However, if the set of agents is defined only by the
.mas2j project file (i.e., no agent is dynamically created), the name
of the agents can be obtained from that file.
Modified: trunk/src/jason/control/ExecutionControlGUI.java
===================================================================
--- trunk/src/jason/control/ExecutionControlGUI.java 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/src/jason/control/ExecutionControlGUI.java 2008-11-27 18:27:11 UTC (rev 1415)
@@ -290,7 +290,7 @@
void setListOfAgsFromInfra() {
try {
- for (String ag: getExecutionControlInfraTier().getRuntimeServices().getAgentsName()) {
+ for (String ag: getExecutionControlInfraTier().getRuntimeServices().getAgentsNames()) {
listModel.addElement(ag);
}
} catch (Exception e) {
Modified: trunk/src/jason/environment/SteppedEnvironment.java
===================================================================
--- trunk/src/jason/environment/SteppedEnvironment.java 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/src/jason/environment/SteppedEnvironment.java 2008-11-27 18:27:11 UTC (rev 1415)
@@ -95,7 +95,7 @@
* environment.
*/
protected void updateNumberOfAgents() {
- setNbAgs(getEnvironmentInfraTier().getRuntimeServices().getAgentsName().size());
+ setNbAgs(getEnvironmentInfraTier().getRuntimeServices().getAgentsNames().size());
}
/** Returns the number of agents in the MAS (used to test the end of a cycle) */
Modified: trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java
===================================================================
--- trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java 2008-11-27 18:27:11 UTC (rev 1415)
@@ -74,7 +74,7 @@
return agArch.getUserAgArch();
}
- public Set<String> getAgentsName() {
+ public Set<String> getAgentsNames() {
return masRunner.getAgs().keySet();
}
Modified: trunk/src/jason/infra/centralised/KillAgentGUI.java
===================================================================
--- trunk/src/jason/infra/centralised/KillAgentGUI.java 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/src/jason/infra/centralised/KillAgentGUI.java 2008-11-27 18:27:11 UTC (rev 1415)
@@ -29,7 +29,7 @@
getContentPane().setLayout(new BorderLayout());
// Fields
- Vector<String> agNames = new Vector<String>(services.getAgentsName());
+ Vector<String> agNames = new Vector<String>(services.getAgentsNames());
Collections.sort(agNames);
lAgs = new JList(agNames);
lAgs.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
Modified: trunk/src/jason/infra/jade/JadeRuntimeServices.java
===================================================================
--- trunk/src/jason/infra/jade/JadeRuntimeServices.java 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/src/jason/infra/jade/JadeRuntimeServices.java 2008-11-27 18:27:11 UTC (rev 1415)
@@ -62,7 +62,7 @@
}
@SuppressWarnings("unchecked")
- public Set<String> getAgentsName() {
+ public Set<String> getAgentsNames() {
// TODO: make a cache list and update it when a new agent enters the system
if (jadeAgent == null) return null;
try {
@@ -101,7 +101,7 @@
public int getAgentsQty() {
try {
- return getAgentsName().size();
+ return getAgentsNames().size();
} catch (Exception e) {
logger.log(Level.SEVERE, "Error getting agents qty", e);
return 0;
Modified: trunk/src/jason/infra/saci/SaciRuntimeServices.java
===================================================================
--- trunk/src/jason/infra/saci/SaciRuntimeServices.java 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/src/jason/infra/saci/SaciRuntimeServices.java 2008-11-27 18:27:11 UTC (rev 1415)
@@ -86,7 +86,7 @@
@SuppressWarnings("unchecked")
- public Set getAgentsName() {
+ public Set getAgentsNames() {
try {
return facilitator.getAllWP().entrySet();
} catch (Exception e) {
Modified: trunk/src/jason/runtime/RuntimeServicesInfraTier.java
===================================================================
--- trunk/src/jason/runtime/RuntimeServicesInfraTier.java 2008-11-25 17:54:32 UTC (rev 1414)
+++ trunk/src/jason/runtime/RuntimeServicesInfraTier.java 2008-11-27 18:27:11 UTC (rev 1415)
@@ -45,7 +45,7 @@
public boolean killAgent(String agName);
/** Returns a set of all agents' name */
- public Set<String> getAgentsName();
+ public Set<String> getAgentsNames();
/** Gets the number of agents in the MAS. */
public int getAgentsQty();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-12-04 10:10:57
|
Revision: 1417
http://jason.svn.sourceforge.net/jason/?rev=1417&view=rev
Author: jomifred
Date: 2008-12-04 10:10:55 +0000 (Thu, 04 Dec 2008)
Log Message:
-----------
update getting started
Modified Paths:
--------------
trunk/doc/faq/faq.tex
trunk/doc/mini-tutorial/src/getting-started/Makefile
trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java
trunk/doc/mini-tutorial/src/getting-started/getting-started.tex
trunk/examples/cleaning-robots/logging.properties
trunk/release-notes.txt
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2008-11-27 18:40:36 UTC (rev 1416)
+++ trunk/doc/faq/faq.tex 2008-12-04 10:10:55 UTC (rev 1417)
@@ -812,8 +812,88 @@
situations in which the agent can find itself when attempting to
achieve the goal.
+\subsection{Which information is available to failure handling plans ?}
+When a plan fails, the plan that handles the corresponding event (in the form
+\texttt{-!g}) may use failure information to provide a suitable solution. This
+information is provided by two means:
+\begin{description}
+\item[Internal actions:] the internal action \texttt{.current\_intention(I)}
+ unifies in \texttt{I} the stack of the current intention. By inspecting this
+ stack, the context of the failure can be discovered.
+ It follows an example of \texttt{I} (provided by the execution of the
+ example available in \texttt{demos/failure}):
+\begin{verbatim}
+intention(1,
+ [
+ im("l__6[source(self)]",[".current_intention(I)", .....]),
+ im("l__5[source(self)]",[".fail"]),
+ im("l__4[source(self)]",["!g5(X)[source(self)]",".print(endg4)"]),
+ im("l__3[source(self)]",["!g4(X)[source(self)]",".print(endg3)"]),
+ im("l__2[source(self)]",["!g3(X)[source(self)]",".print(endg2)"]),
+ im("l__1[source(self)]",["!g2(X)[source(self)]",".print(endg1)"]),
+ im("l__0[source(self)]",["!g1(X)[source(self)]",".print("End, X=",X)"])
+ ]
+)
+\end{verbatim}
+
+ You find more information in the documentation of the \htlink{current\_intention}{http://jason.sourceforge.net/api/classjason_1_1stdlib_1_1current__intention.html}.
+
+
+\item[Annotations:] every failure event is annotated with at least the
+ following information:
+ \begin{itemize}
+ \item \texttt{error(<atom: error id>)}: the identification of the type of
+ failure, values used by \Jason are
+ \begin{itemize}
+ \item \texttt{no\_applicable}: failure caused by no applicable plan
+ \item \texttt{no\_relevant}: failure caused by no relevant plan
+ \item \texttt{no\_option}: failure caused by no option being selected by
+ selectOption funtion
+ \item \texttt{constraint\_failed}: failure caused by a constraint in the
+ plan that is not satisfied
+ \item \texttt{ia\_failed}: failure caused by an error in an internal
+ action (it throws an exception or returned false)
+ \item \texttt{action\_failed}: the failure is caused by a failure in the
+ execution of an action in the environment
+ \item \texttt{ask\_failed}: the failure is caused by the lack of response
+ to an ask message
+ \item \texttt{wrong\_arguments}: failure caused by wrong number of type of
+ arguments given to an internal action
+ \item \texttt{unknown}: other causes.
+ \end{itemize}
+
+ \item \texttt{error\_msg(<string>)}: the human readable message of the error
+ \item \texttt{code(<literal>)}: the plan's body operator that failed
+ \item \texttt{code\_src(<string>)}: the file's name where the plan that
+ fails is defined
+ \item \texttt{code\_line(<int>)}: the line in the file
+ \end{itemize}
+
+ An example of failure event and its annotations:
+\begin{verbatim}
+-!g[error(ia_failed),
+ error_msg("internal action .my_name failed"),
+ code(".my_name(bob)"),
+ code_src("/tmp/x.asl"),
+ code_line(18)]
+\end{verbatim}
+
+ Note that the plan that handle this event is not obliged to use these
+ annotations, for example:
+\begin{verbatim}
+-!g[error(ia_failed)] <- ... plan to handle error of type \ia_failed' ....
+-!g[error(no_applicable)] <- ... plan to handle error of type 'no_applicable'
+-!g[code_src("/tmp/x.asl")] <- ... plan to handle error in plans of file x.asl
+\end{verbatim}
+
+ The internal actions defined by the user can add new annotations to indicate
+ particular types of errors (see the API documentation of \htlink{JasonException}{http://jason.sourceforge.net/api/classjason_1_1JasonException.html} for
+ more information about that).
+\end{description}
+
+
\section{Developing Jason}
\subsection{How to build \jason from SourceForge SVN (subversion)?}
Modified: trunk/doc/mini-tutorial/src/getting-started/Makefile
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/Makefile 2008-11-27 18:40:36 UTC (rev 1416)
+++ trunk/doc/mini-tutorial/src/getting-started/Makefile 2008-12-04 10:10:55 UTC (rev 1417)
@@ -9,4 +9,4 @@
zip -r ../../getting-started/VacuumCleaning-1.zip VacuumCleaning-1/*.asl VacuumCleaning-1/*.mas2j VacuumCleaning-1/*.java
publish:
- scp ../../getting-started/* jom...@ss...:/home/groups/j/ja/jason/htdocs/mini-tutorial/getting-started
+ scp ../../getting-started/* jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/getting-started
Modified: trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java 2008-11-27 18:40:36 UTC (rev 1416)
+++ trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java 2008-12-04 10:10:55 UTC (rev 1417)
@@ -21,7 +21,7 @@
private int vcx = 0; // the vacuum cleaner location
private int vcy = 0;
- private boolean running = true;
+ private boolean running = true;
private HouseGUI gui = new HouseGUI();
@@ -31,8 +31,8 @@
createPercept();
gui.paint();
- // create a thread to add dirty
- new Thread() {
+ // create a thread to add dirty
+ new Thread() {
public void run() {
try {
while (running) {
@@ -46,8 +46,7 @@
}
} catch (Exception e) {}
}
- }.start();
-
+ }.start();
}
Random r = new Random();
@@ -57,12 +56,6 @@
// remove previous perception
clearPercepts();
- // add dirty first, it has priority
- if (dirty[vcx][vcy]) {
- addPercept(Literal.parseLiteral("dirty"));
- } else {
- addPercept(Literal.parseLiteral("clean"));
- }
if (vcx == 0 && vcy == 0) {
addPercept(Literal.parseLiteral("pos(1)"));
} else if (vcx == 1 && vcy == 0) {
@@ -72,14 +65,26 @@
} else if (vcx == 1 && vcy == 1) {
addPercept(Literal.parseLiteral("pos(4)"));
}
+
+ if (dirty[vcx][vcy]) {
+ addPercept(Literal.parseLiteral("dirty"));
+ } else {
+ addPercept(Literal.parseLiteral("clean"));
+ }
}
@Override
public boolean executeAction(String ag, Structure action) {
+
+ try { Thread.sleep(500);} catch (Exception e) {} //show down the execution
+
// Change the world model based on action
if (action.getFunctor().equals("suck")) {
if (dirty[vcx][vcy]) {
dirty[vcx][vcy] = false;
+ } else {
+ logger.info("suck in a clean location!");
+ Toolkit.getDefaultToolkit().beep();
}
} else if (action.getFunctor().equals("left")) {
if (vcx > 0) {
@@ -105,26 +110,25 @@
createPercept(); // update agents perception for the new world state
gui.paint();
- try { Thread.sleep(500);} catch (Exception e) {}
return true;
}
@Override
public void stop() {
- running = false;
- super.stop();
- gui.setVisible(false);
- }
+ running = false;
+ super.stop();
+ gui.setVisible(false);
+ }
/* a simple GUI */
- class HouseGUI extends JFrame {
+ class HouseGUI extends JFrame {
JLabel[][] labels;
HouseGUI() {
- super("Domestic Robot");
+ super("Domestic Robot");
labels = new JLabel[dirty.length][dirty.length];
- getContentPane().setLayout(new GridLayout(labels.length, labels.length));
+ getContentPane().setLayout(new GridLayout(labels.length, labels.length));
for (int j = 0; j < labels.length; j++) {
for (int i = 0; i < labels.length; i++) {
labels[i][j] = new JLabel();
@@ -133,14 +137,14 @@
labels[i][j].setBorder(new EtchedBorder());
getContentPane().add(labels[i][j]);
}
- }
- pack();
- setVisible(true);
- paint();
- }
+ }
+ pack();
+ setVisible(true);
+ paint();
+ }
- void paint() {
- for (int i = 0; i < labels.length; i++) {
+ void paint() {
+ for (int i = 0; i < labels.length; i++) {
for (int j = 0; j < labels.length; j++) {
String l = "<html><center>";
if (vcx == i && vcy == j) {
@@ -152,9 +156,8 @@
l += "</center></html>";
labels[i][j].setText(l);
}
- }
- }
- }
-
+ }
+ }
+ }
}
Modified: trunk/doc/mini-tutorial/src/getting-started/getting-started.tex
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/getting-started.tex 2008-11-27 18:40:36 UTC (rev 1416)
+++ trunk/doc/mini-tutorial/src/getting-started/getting-started.tex 2008-12-04 10:10:55 UTC (rev 1417)
@@ -395,7 +395,7 @@
You will soon realise that this reactive approach has some limitation
-in defining a good behaviour for our vacuum clearer. In fact, this agent
+in defining a good behaviour for our vacuum cleaner. In fact, this agent
should be defined has having \emph{goals}, in particular, a persistent
goal of maintaining the house clean. The easiest way to define a
persistent goal is by a recursive plan; for example, the code below
Modified: trunk/examples/cleaning-robots/logging.properties
===================================================================
--- trunk/examples/cleaning-robots/logging.properties 2008-11-27 18:40:36 UTC (rev 1416)
+++ trunk/examples/cleaning-robots/logging.properties 2008-12-04 10:10:55 UTC (rev 1417)
@@ -27,7 +27,7 @@
# Jason Handler parameters
jason.runtime.MASConsoleLogHandler.level = ALL
jason.runtime.MASConsoleLogHandler.formatter = jason.runtime.MASConsoleLogFormatter
-jason.runtime.MASConsoleLogHandler.tabbed = true
+jason.runtime.MASConsoleLogHandler.tabbed = false
# default file output is in project's directory.
java.util.logging.FileHandler.pattern = mas-%u.log
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-11-27 18:40:36 UTC (rev 1416)
+++ trunk/release-notes.txt 2008-12-04 10:10:55 UTC (rev 1417)
@@ -6,12 +6,13 @@
. customised belief bases can be organised in a chain so
that several functionalities can be composed. For more
information
- see/run the demo/chain-bb
+ see the demo/chain-bb
see API doc of ChainBB and ChainBBAdapter
. annotations in failure events. All failure events are now
annotated with:
- error(<atom: error id>): values used by Jason are
+ error(<atom: error id>): the identification of the type of error,
+ values used by Jason are
no_applicable: no applicable plan
no_relevant: no relevant plan
no_option: no option selected
@@ -27,6 +28,7 @@
code_src(<string>): the file where the command is
code_line(<int>): the line in the file
see demo/failure for an example
+ see FAQ for more details
see code of JasonException and TS for more information
. the version of JADE is upgraded to 3.6
@@ -65,6 +67,7 @@
see discussion about the Literal class in the
jason-developers list.
+
-------------
version 1.1.2
-------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-12-05 14:36:52
|
Revision: 1419
http://jason.svn.sourceforge.net/jason/?rev=1419&view=rev
Author: jomifred
Date: 2008-12-05 14:36:48 +0000 (Fri, 05 Dec 2008)
Log Message:
-----------
fix bug in 'automatic agent creation' when using jEdit
Modified Paths:
--------------
trunk/doc/faq/faq.tex
trunk/src/jason/jeditplugin/JasonID.java
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2008-12-04 14:25:22 UTC (rev 1418)
+++ trunk/doc/faq/faq.tex 2008-12-05 14:36:48 UTC (rev 1419)
@@ -116,7 +116,7 @@
Most of the internal actions (IAs) are developed from an agent
perspective, since they are conceived to be called by agents. Thus the
\code{execute} method needs an agent's
-\code{TransitionSystem} (TS) to be executed (e.g. \code{.myName} only makes
+\code{TransitionSystem} (TS) to be executed (e.g. \code{.my_name} only makes
sense when called by an agent).
%However, some internal actions can be executed without a reference for
Modified: trunk/src/jason/jeditplugin/JasonID.java
===================================================================
--- trunk/src/jason/jeditplugin/JasonID.java 2008-12-04 14:25:22 UTC (rev 1418)
+++ trunk/src/jason/jeditplugin/JasonID.java 2008-12-05 14:36:48 UTC (rev 1419)
@@ -269,24 +269,35 @@
void openAgentBuffer(AgentParameters ap) {
try {
- boolean newFile = !(new File(ap.asSource.getAbsolutePath()).exists());
- Buffer nb = org.gjt.sp.jedit.jEdit.openFile(view, ap.asSource.getAbsolutePath());
+ if (ap == null || ap.asSource == null)
+ return;
+
+ // fix file name
+ Buffer projectb = getProjectBuffer();
+ String file = ap.asSource.toString();
+ if (file.indexOf('/') < 0)
+ file = projectb.getDirectory() + "/" + file;
+ file = new File(file).getAbsolutePath();
+
+ boolean newFile = !(new File(file).exists());
+ Buffer nb = org.gjt.sp.jedit.jEdit.openFile(view, file);
// textArea.append(lstAgs.getSelectedValue()+"");
if (newFile) {
try {
- Buffer projectb = getProjectBuffer();
ap.asSource = new File(projectb.getDirectory() + ap.name + "." + MAS2JProject.AS_EXT);
String agcode = Config.get().getTemplate("agent.asl");
agcode = agcode.replace("<AG_NAME>", ap.getAgName());
agcode = agcode.replace("<PROJECT_NAME>", projectb.getName());
nb.writeLock();
nb.insert(0, agcode);
- nb.save(view, ap.asSource.getAbsolutePath());
+ nb.save(view, file);
} finally {
nb.writeUnlock();
}
}
- } catch (Exception ex) {}
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
}
public void handleMessage(EBMessage message) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-12-10 07:03:33
|
Revision: 1420
http://jason.svn.sourceforge.net/jason/?rev=1420&view=rev
Author: jomifred
Date: 2008-12-10 07:03:29 +0000 (Wed, 10 Dec 2008)
Log Message:
-----------
fix problem in ConcurrentIA
minor changes everywhere
Modified Paths:
--------------
trunk/applications/jason-moise/src/jmoise/create_scheme.java
trunk/src/jason/asSemantics/ConcurrentInternalAction.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/ASSyntax.java
trunk/src/jason/asSyntax/DefaultTerm.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/asSyntax/LiteralImpl.java
trunk/src/jason/asSyntax/NumberTermImpl.java
trunk/src/jason/asSyntax/SourceInfo.java
trunk/src/jason/asSyntax/Term.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/bb/DefaultBeliefBase.java
Modified: trunk/applications/jason-moise/src/jmoise/create_scheme.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/create_scheme.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/applications/jason-moise/src/jmoise/create_scheme.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -6,7 +6,7 @@
/**
-<p>Organisational action: <b><code>jmoise.create_scheme( [sch_name(SchId), ] SchSpecId [, ListOfRespGrs] )</code></b>:
+<p>Organisational action: <b><code>jmoise.create_scheme( [sch_name(SchId), ] SchSpecId [, ListOfRespGrs] [, newSchId] )</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.
@@ -30,7 +30,7 @@
groups.</li>
<li> <code>jmoise.create_scheme(wp, [g1, g2], S)</code>:
creates new scheme based on specification wp and set g1 and g2 as responsible
- groups. The identification of the new group will be unified with G.</li>
+ groups. The identification of the new scheme will be unified with S.</li>
</ul>
@see jmoise.remove_scheme
Modified: trunk/src/jason/asSemantics/ConcurrentInternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -1,5 +1,6 @@
package jason.asSemantics;
+import jason.JasonException;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.PlanBody;
import jason.asSyntax.PlanBodyImpl;
@@ -120,14 +121,19 @@
Intention pi = C.getPendingIntentions().remove(intentionKey);
if (pi != null) {
pi.setSuspended(false);
- C.addIntention(pi); // add it back in I
pi.peek().removeCurrentStep(); // remove the internal action that put the intention in suspend
+ try {
+ ts.applyClrInt(pi);
+ } catch (JasonException e) {
+ e.printStackTrace();
+ }
if (abort) {
// fail the IA
PlanBody pbody = pi.peek().getPlan().getBody();
pbody.add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
}
+ C.addIntention(pi); // add it back in I
ts.getUserAgArch().getArchInfraTier().wake();
}
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -463,7 +463,10 @@
logger.log(Level.SEVERE, body.getErrorMsg()+": "+ e.getMessage());
ok = true; // just to not generate the event again
} catch (Exception e) {
- logger.log(Level.SEVERE, body.getErrorMsg()+": "+ e.getMessage(), e);
+ if (body == null)
+ logger.log(Level.SEVERE, "Body is not a literal for body '"+h+"' and IM "+im, e);
+ else
+ logger.log(Level.SEVERE, body.getErrorMsg()+": "+ e.getMessage(), e);
}
if (!ok)
generateGoalDeletion(errorAnnots);
@@ -476,7 +479,7 @@
im.unif = iu.next();
updateIntention();
} else {
- String msg = "Constraint "+h+" was not satisfied ("+h.getSrcInfo().getErrorMsg()+").";
+ String msg = "Constraint "+h+" was not satisfied ("+h.getSrcInfo()+").";
generateGoalDeletion(JasonException.createBasicErrorAnnots(new Atom("constraint_failed"), msg));
logger.fine(msg);
}
@@ -531,7 +534,7 @@
}
}
if (fail) {
- if (logger.isLoggable(Level.FINE)) logger.fine("Test '"+h+"' failed ("+h.getSrcInfo().getErrorMsg()+").");
+ if (logger.isLoggable(Level.FINE)) logger.fine("Test '"+h+"' failed ("+h.getSrcInfo()+").");
generateGoalDeletion();
}
}
@@ -626,76 +629,78 @@
}
public void applyClrInt(Intention i) throws JasonException {
- // Rule ClrInt
- if (i == null)
- return;
-
- if (i.isFinished()) {
- // intention finished, remove it
- confP.C.removeIntention(i);
- //conf.C.SI = null;
- return;
- }
-
- IntendedMeans im = i.peek();
- if (!im.isFinished()) {
- // nothing to do
- return;
- }
-
- // remove the finished IM from the top of the intention
- IntendedMeans topIM = i.pop();
- Literal topLiteral = topIM.getTrigger().getLiteral();
- if (logger.isLoggable(Level.FINE)) logger.fine("Returning from IM "+topIM.getPlan().getLabel()+", te="+topIM.getPlan().getTrigger());
-
- // if finished a failure handling IM ...
- if (im.getTrigger().isGoal() && !im.getTrigger().isAddition() && i.size() > 0) {
- // needs to get rid of the IM until a goal that
- // has failure handling. E.g,
- // -!b
- // +!c
- // +!d
- // +!b
- // +!s: !b; !z
- // should became
- // +!s: !z
- im = i.peek();
- if (im.isFinished() || !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral))
- im = i.pop(); // +!c above
- while (i.size() > 0 &&
- !im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) &&
- !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral)) {
- im = i.pop();
+ while (true) { // quit the method by return
+ // Rule ClrInt
+ if (i == null)
+ return;
+
+ if (i.isFinished()) {
+ // intention finished, remove it
+ confP.C.removeIntention(i);
+ //conf.C.SI = null;
+ return;
}
- }
- if (!i.isFinished()) {
- im = i.peek(); // +!s or +?s
+
+ IntendedMeans im = i.peek();
if (!im.isFinished()) {
- // removes !b or ?s
- /* I am trying against comments below and use topIM.getTrigger!
- * since I don't remember why the trigger cann't be used
- * probably the reason is the old buggy makeVarAnnos
-
- Term g = im.removeCurrentStep();
- // make the TE of finished plan ground and unify that
- // with goal/test in the body (to "return" values).
- // (it must be the plan TE and not the IM.trigger because the
- // vars have name only in the plan TE, in the IM.trigger
- // they are anonymous)
- Literal tel = topIM.getPlan().getTrigger().getLiteral();
- // but import annots from IM.trigger
- tel.addAnnots(topIM.getTrigger().getLiteral().getAnnots());
- tel.topLiteral.makeVarsAnnon(topIM.unif);
- */
- // unifies the final event with the body that called it
- topLiteral.apply(topIM.unif);
- im.unif.unifies(im.removeCurrentStep(), topLiteral);
+ // nothing to do
+ return;
}
+
+ // remove the finished IM from the top of the intention
+ IntendedMeans topIM = i.pop();
+ Literal topLiteral = topIM.getTrigger().getLiteral();
+ if (logger.isLoggable(Level.FINE)) logger.fine("Returning from IM "+topIM.getPlan().getLabel()+", te="+topIM.getPlan().getTrigger());
+
+ // if finished a failure handling IM ...
+ if (im.getTrigger().isGoal() && !im.getTrigger().isAddition() && i.size() > 0) {
+ // needs to get rid of the IM until a goal that
+ // has failure handling. E.g,
+ // -!b
+ // +!c
+ // +!d
+ // +!b
+ // +!s: !b; !z
+ // should became
+ // +!s: !z
+ im = i.peek();
+ if (im.isFinished() || !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral))
+ im = i.pop(); // +!c above
+ while (i.size() > 0 &&
+ !im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) &&
+ !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral)) {
+ im = i.pop();
+ }
+ }
+ if (!i.isFinished()) {
+ im = i.peek(); // +!s or +?s
+ if (!im.isFinished()) {
+ // removes !b or ?s
+ /* I am trying against comments below and use topIM.getTrigger!
+ * since I don't remember why the trigger cann't be used
+ * probably the reason is the old buggy makeVarAnnos
+
+ Term g = im.removeCurrentStep();
+ // make the TE of finished plan ground and unify that
+ // with goal/test in the body (to "return" values).
+ // (it must be the plan TE and not the IM.trigger because the
+ // vars have name only in the plan TE, in the IM.trigger
+ // they are anonymous)
+ Literal tel = topIM.getPlan().getTrigger().getLiteral();
+ // but import annots from IM.trigger
+ tel.addAnnots(topIM.getTrigger().getLiteral().getAnnots());
+ tel.topLiteral.makeVarsAnnon(topIM.unif);
+ */
+ // unifies the final event with the body that called it
+ topLiteral.apply(topIM.unif);
+ im.unif.unifies(im.removeCurrentStep(), topLiteral);
+ }
+ }
+
+ // the new top may have become
+ // empty! need to keep checking.
+ //applyClrInt(i);
}
-
- // the new top may have become
- // empty! need to keep checking.
- applyClrInt(i);
}
/**********************************************/
Modified: trunk/src/jason/asSyntax/ASSyntax.java
===================================================================
--- trunk/src/jason/asSyntax/ASSyntax.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/ASSyntax.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -4,6 +4,7 @@
import jason.asSyntax.parser.as2j;
import java.io.StringReader;
+import java.util.Collection;
/**
Factory for objects used in Jason AgentSpeak syntax.
@@ -114,12 +115,26 @@
return l;
}
+ /** Creates a new list from a collection of terms */
+ public static ListTerm createList(Collection<Term> terms) {
+ ListTerm l = new ListTermImpl();
+ ListTerm tail = l;
+ for (Term t: terms)
+ tail = tail.append(t);
+ return l;
+ }
+
/** creates a new literal by parsing a string */
public static Literal parseLiteral(String sLiteral) throws ParseException {
return new as2j(new StringReader(sLiteral)).literal();
}
-
+
+ /** creates a new number term by parsing a string */
+ public static NumberTerm parseNumber(String number) throws NumberFormatException {
+ return new NumberTermImpl(Double.parseDouble(number));
+ }
+
/** creates a new structure (a kind of term) by parsing a string */
public static Structure parseStructure(String sTerm) throws ParseException {
Term t = new as2j(new StringReader(sTerm)).term();
Modified: trunk/src/jason/asSyntax/DefaultTerm.java
===================================================================
--- trunk/src/jason/asSyntax/DefaultTerm.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/DefaultTerm.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -113,6 +113,6 @@
if (srcInfo == null)
return "";
else
- return srcInfo.getErrorMsg();
+ return srcInfo.toString();
}
}
Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -142,7 +142,7 @@
@Override
public String getErrorMsg() {
- String src = getSrcInfo() == null ? "" : " ("+ getSrcInfo().getErrorMsg() + ")";
+ String src = getSrcInfo() == null ? "" : " ("+ getSrcInfo() + ")";
return "Error in internal action '"+this+"'"+ src;
}
Modified: trunk/src/jason/asSyntax/LiteralImpl.java
===================================================================
--- trunk/src/jason/asSyntax/LiteralImpl.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/LiteralImpl.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -101,7 +101,7 @@
@Override
public String getErrorMsg() {
- String src = getSrcInfo() == null ? "" : " ("+ getSrcInfo().getErrorMsg() + ")";
+ String src = getSrcInfo() == null ? "" : " ("+ getSrcInfo() + ")";
return "Error in '"+this+"'"+src;
}
Modified: trunk/src/jason/asSyntax/NumberTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/NumberTermImpl.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/NumberTermImpl.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -42,6 +42,7 @@
value = 0;
}
+ /** @deprecated prefer to use ASSyntax.parseNumber */
public NumberTermImpl(String sn) {
double t = 0;
try {
Modified: trunk/src/jason/asSyntax/SourceInfo.java
===================================================================
--- trunk/src/jason/asSyntax/SourceInfo.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/SourceInfo.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -54,8 +54,8 @@
return endSrcLine;
}
- public String getErrorMsg() {
+ public String toString() {
return (source == null ? "nofile" : source)
- + (beginSrcLine >= 0 ? ":"+beginSrcLine : "");
- }
+ + (beginSrcLine >= 0 ? ":"+beginSrcLine : "");
+ }
}
Modified: trunk/src/jason/asSyntax/Term.java
===================================================================
--- trunk/src/jason/asSyntax/Term.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/Term.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -40,6 +40,7 @@
/** Removes the value cached for hashCode */
//public void resetHashCodeCache();
-
+
+ public void setSrcInfo(SourceInfo s);
public SourceInfo getSrcInfo();
}
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -117,7 +117,7 @@
*/
public boolean setValue(Term vl) {
if (vl.isVar()) {
- logger.warning("Attempted set a variable as a value for a variable, in " + this.getFunctor());
+ logger.log(Level.WARNING, "Attempted set a variable as a value for a variable, in " + this.getFunctor(), new Exception());
return false;
}
@@ -149,9 +149,14 @@
Term vl = u.get(this);
//System.out.println("applying "+this+"="+vl+" un="+u);
if (vl != null) { // && !(vl instanceof VarsCluster)) {
- setValue(vl);
- value.apply(u); // in case t has var args
- return true;
+ if (!vl.hasVar(this)) {
+ setValue(vl);
+ value.apply(u); // in case t has var args
+ return true;
+ } else {
+ logger.warning("Value of variable contains itself, variable "+super.getFunctor()+" "+super.getSrcInfo()+", value="+value);
+ return false;
+ }
}
} else {
return getValue().apply(u);
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-12-10 07:03:29 UTC (rev 1420)
@@ -637,7 +637,7 @@
Object arithm_expr_simple():
{ Token K; Object t; VarTerm v; }
{
- ( K = <NUMBER> { NumberTermImpl ni = new NumberTermImpl(K.image);
+ ( K = <NUMBER> { NumberTerm ni = ASSyntax.parseNumber(K.image);
ni.setSrcInfo(new SourceInfo(asSource, K.beginLine));
return ni;
}
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -1107,7 +1107,7 @@
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NUMBER:
K = jj_consume_token(NUMBER);
- NumberTermImpl ni = new NumberTermImpl(K.image);
+ NumberTerm ni = ASSyntax.parseNumber(K.image);
ni.setSrcInfo(new SourceInfo(asSource, K.beginLine));
{if (true) return ni;}
break;
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-12-05 14:36:48 UTC (rev 1419)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-12-10 07:03:29 UTC (rev 1420)
@@ -74,7 +74,6 @@
return size;
}
- @SuppressWarnings("unchecked")
public Iterator<Literal> getPercepts() {
final Iterator<Literal> i = percepts.iterator();
return new Iterator<Literal>() {
@@ -281,7 +280,6 @@
final private List<Literal> list = new LinkedList<Literal>(); // maintains the order of the bels
final private Map<LiteralWrapper,Literal> map = new HashMap<LiteralWrapper,Literal>(); // to fastly find contents, from literal do list index
- @SuppressWarnings("unchecked")
public void add(Literal l, boolean addInEnd) {
//try {
// minimise the allocation space of terms
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-12-10 09:58:25
|
Revision: 1421
http://jason.svn.sourceforge.net/jason/?rev=1421&view=rev
Author: jomifred
Date: 2008-12-10 09:58:20 +0000 (Wed, 10 Dec 2008)
Log Message:
-----------
in .wait and ConcurrentIA, do not add IA .fail to fail an intention, but generate an event
Modified Paths:
--------------
trunk/demos/gui/gui1/sample.asl
trunk/src/jason/JasonException.java
trunk/src/jason/asSemantics/ConcurrentInternalAction.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/infra/jade/JadeRuntimeServices.java
trunk/src/jason/infra/saci/SaciRuntimeServices.java
trunk/src/jason/stdlib/wait.java
trunk/src/test/BeliefBaseTest.java
trunk/src/test/VarTermTest.java
Modified: trunk/demos/gui/gui1/sample.asl
===================================================================
--- trunk/demos/gui/gui1/sample.asl 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/demos/gui/gui1/sample.asl 2008-12-10 09:58:20 UTC (rev 1421)
@@ -11,7 +11,7 @@
// note that this IA blocks only the intention using it (the !start) and not all the
// intentions (the agent continues to print "." while the interface is being shown
-+!start <- gui.yes_no("Is it Ok?"); .print(ok).
++!start <- gui.yes_no("Is it Ok?"); .print(ok); .drop_intention(print(_)).
-!start <- .print(nok).
+!print(S) <- .wait(500); .print(". ", system.time-S); !!print(system.time).
Modified: trunk/src/jason/JasonException.java
===================================================================
--- trunk/src/jason/JasonException.java 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/src/jason/JasonException.java 2008-12-10 09:58:20 UTC (rev 1421)
@@ -95,7 +95,6 @@
return e;
}
- @SuppressWarnings("unchecked")
public static JasonException createWrongArgumentNb(DefaultInternalAction ia) {
String msg;
if (ia.getMinArgs() == ia.getMaxArgs())
@@ -108,7 +107,6 @@
return new JasonException("The internal action '"+ia.getClass().getSimpleName()+"' has not received the required number of argument(s)."+msg , WRONG_ARGS);
}
- @SuppressWarnings("unchecked")
public static JasonException createWrongArgument(InternalAction ia, String reason) {
return new JasonException("Wrong argument for internal action '"+ia.getClass().getSimpleName()+"': "+reason, WRONG_ARGS);
}
Modified: trunk/src/jason/asSemantics/ConcurrentInternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2008-12-10 09:58:20 UTC (rev 1421)
@@ -1,13 +1,10 @@
package jason.asSemantics;
import jason.JasonException;
-import jason.asSyntax.InternalActionLiteral;
-import jason.asSyntax.PlanBody;
-import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Term;
-import jason.asSyntax.PlanBody.BodyType;
import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
/**
@@ -121,19 +118,18 @@
Intention pi = C.getPendingIntentions().remove(intentionKey);
if (pi != null) {
pi.setSuspended(false);
- pi.peek().removeCurrentStep(); // remove the internal action that put the intention in suspend
try {
- ts.applyClrInt(pi);
+ if (abort) {
+ // fail the IA
+ ts.generateGoalDeletion(pi, null);
+ } else {
+ pi.peek().removeCurrentStep(); // remove the internal action that put the intention in suspend
+ ts.applyClrInt(pi);
+ C.addIntention(pi); // add it back in I
+ }
} catch (JasonException e) {
- e.printStackTrace();
+ ts.getLogger().log(Level.SEVERE, "Error resuming intention", e);
}
-
- if (abort) {
- // fail the IA
- PlanBody pbody = pi.peek().getPlan().getBody();
- pbody.add(0, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
- }
- C.addIntention(pi); // add it back in I
ts.getUserAgArch().getArchInfraTier().wake();
}
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-12-10 09:58:20 UTC (rev 1421)
@@ -185,8 +185,7 @@
if (intention.peek().getUnif().unifies(send.getTerm(3), content)) {
getC().addIntention(intention);
} else {
- conf.C.SI = intention;
- generateGoalDeletion(JasonException.createBasicErrorAnnots("ask_failed", ""));
+ generateGoalDeletion(intention, JasonException.createBasicErrorAnnots("ask_failed", "answer of ask does no unify forth argument of .send"));
}
// the message is not an ask answer
@@ -371,7 +370,7 @@
updateIntention();
applyClrInt(confP.C.SI);
} else {
- generateGoalDeletion(JasonException.createBasicErrorAnnots("action_failed", ""));
+ generateGoalDeletion(conf.C.SI, JasonException.createBasicErrorAnnots("action_failed", ""));
}
} else {
applyProcAct(); // get next action
@@ -459,7 +458,7 @@
updateIntention();
} catch (JasonException e) {
errorAnnots = e.getErrorTerms();
- if (!generateGoalDeletion(errorAnnots))
+ if (!generateGoalDeletion(conf.C.SI, errorAnnots))
logger.log(Level.SEVERE, body.getErrorMsg()+": "+ e.getMessage());
ok = true; // just to not generate the event again
} catch (Exception e) {
@@ -469,7 +468,7 @@
logger.log(Level.SEVERE, body.getErrorMsg()+": "+ e.getMessage(), e);
}
if (!ok)
- generateGoalDeletion(errorAnnots);
+ generateGoalDeletion(conf.C.SI, errorAnnots);
break;
@@ -480,7 +479,7 @@
updateIntention();
} else {
String msg = "Constraint "+h+" was not satisfied ("+h.getSrcInfo()+").";
- generateGoalDeletion(JasonException.createBasicErrorAnnots(new Atom("constraint_failed"), msg));
+ generateGoalDeletion(conf.C.SI, JasonException.createBasicErrorAnnots(new Atom("constraint_failed"), msg));
logger.fine(msg);
}
break;
@@ -535,7 +534,7 @@
}
if (fail) {
if (logger.isLoggable(Level.FINE)) logger.fine("Test '"+h+"' failed ("+h.getSrcInfo()+").");
- generateGoalDeletion();
+ generateGoalDeletion(conf.C.SI, null);
}
}
break;
@@ -560,7 +559,7 @@
updateEvents(result,Intention.EmptyInt);
}
} catch (RevisionFailedException re) {
- generateGoalDeletion();
+ generateGoalDeletion(conf.C.SI, null);
break;
}
@@ -595,7 +594,7 @@
updateIntention();
}
} catch (RevisionFailedException re) {
- generateGoalDeletion();
+ generateGoalDeletion(conf.C.SI, null);
}
break;
@@ -622,7 +621,7 @@
updateIntention();
}
} catch (RevisionFailedException re) {
- generateGoalDeletion();
+ generateGoalDeletion(conf.C.SI, null);
}
break;
}
@@ -793,15 +792,12 @@
}
}
- /** generate a failure event for the current intention */
- private void generateGoalDeletion() throws JasonException {
- generateGoalDeletion(null);
- }
- private boolean generateGoalDeletion(List<Term> failAnnots) throws JasonException {
+ /** generate a failure event for an intention */
+ public boolean generateGoalDeletion(Intention i, List<Term> failAnnots) throws JasonException {
boolean failEeventGenerated = false;
- IntendedMeans im = conf.C.SI.peek();
+ IntendedMeans im = i.peek();
if (im.isGoalAdd()) {
- Event failEvent = findEventForFailure(conf.C.SI, im.getTrigger());
+ Event failEvent = findEventForFailure(i, im.getTrigger());
if (failEvent != null) {
setDefaultFailureAnnots(failEvent, im.getCurrentStep().getBodyTerm(), failAnnots);
confP.C.addEvent(failEvent);
@@ -816,10 +812,10 @@
else if (setts.requeue()) {
// get the external event (or the one that started
// the whole focus of attention) and requeue it
- im = conf.C.SI.get(0);
+ im = i.get(0);
confP.C.addExternalEv(im.getTrigger());
} else {
- logger.warning("Could not finish intention: " + conf.C.SI);
+ logger.warning("Could not finish intention: " + i);
}
return failEeventGenerated;
}
Modified: trunk/src/jason/infra/jade/JadeRuntimeServices.java
===================================================================
--- trunk/src/jason/infra/jade/JadeRuntimeServices.java 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/src/jason/infra/jade/JadeRuntimeServices.java 2008-12-10 09:58:20 UTC (rev 1421)
@@ -61,7 +61,6 @@
throw new JasonException("clone for JADE is not implemented!");
}
- @SuppressWarnings("unchecked")
public Set<String> getAgentsNames() {
// TODO: make a cache list and update it when a new agent enters the system
if (jadeAgent == null) return null;
Modified: trunk/src/jason/infra/saci/SaciRuntimeServices.java
===================================================================
--- trunk/src/jason/infra/saci/SaciRuntimeServices.java 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/src/jason/infra/saci/SaciRuntimeServices.java 2008-12-10 09:58:20 UTC (rev 1421)
@@ -85,7 +85,6 @@
}
- @SuppressWarnings("unchecked")
public Set getAgentsNames() {
try {
return facilitator.getAllWP().entrySet();
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/src/jason/stdlib/wait.java 2008-12-10 09:58:20 UTC (rev 1421)
@@ -23,6 +23,7 @@
package jason.stdlib;
+import jason.JasonException;
import jason.asSemantics.Circumstance;
import jason.asSemantics.CircumstanceListener;
import jason.asSemantics.DefaultInternalAction;
@@ -87,9 +88,8 @@
public class wait extends DefaultInternalAction {
public static final String waitAtom = ".wait";
- //static Logger logger = Logger.getLogger(wait.class.getName());
- @Override public boolean canBeUsedInContext() { return false; }
+ @Override public boolean canBeUsedInContext() { return false; }
@Override public boolean suspendIntention() { return true; }
@Override public int getMinArgs() { return 1; }
@@ -170,20 +170,26 @@
// add SI again in C.I if it was not removed and this wait was not dropped
if (c.getPendingIntentions().remove(sTE) == si && !c.getIntentions().contains(si) && !dropped) {
if (stopByTimeout && te != null && elapsedTimeTerm == null) {
- // fail the .wait
- PlanBody body = si.peek().getPlan().getBody();
- body.add(1, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
- }
- si.peek().removeCurrentStep();
- if (elapsedTimeTerm != null) {
- long elapsedTime = System.currentTimeMillis() - startTime;
- un.unifies(elapsedTimeTerm, new NumberTermImpl(elapsedTime));
- }
- if (si.isSuspended()) { // if the intention was suspended by .suspend
- String k = suspend.SUSPENDED_INT+si.getId();
- c.getPendingIntentions().put(k, si);
+ // fail the .wait by timeout
+ if (si.isSuspended()) { // if the intention was suspended by .suspend
+ PlanBody body = si.peek().getPlan().getBody();
+ body.add(1, new PlanBodyImpl(BodyType.internalAction, new InternalActionLiteral(".fail")));
+ c.getPendingIntentions().put(suspend.SUSPENDED_INT+si.getId(), si);
+ } else {
+ ts.generateGoalDeletion(si, JasonException.createBasicErrorAnnots("wait_timeout", "timeout in .wait"));
+ }
} else {
- c.addIntention(si);
+ si.peek().removeCurrentStep();
+
+ if (elapsedTimeTerm != null) {
+ long elapsedTime = System.currentTimeMillis() - startTime;
+ un.unifies(elapsedTimeTerm, new NumberTermImpl(elapsedTime));
+ }
+ if (si.isSuspended()) { // if the intention was suspended by .suspend
+ c.getPendingIntentions().put(suspend.SUSPENDED_INT+si.getId(), si);
+ } else {
+ c.addIntention(si);
+ }
}
ts.getUserAgArch().getArchInfraTier().wake();
}
Modified: trunk/src/test/BeliefBaseTest.java
===================================================================
--- trunk/src/test/BeliefBaseTest.java 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/src/test/BeliefBaseTest.java 2008-12-10 09:58:20 UTC (rev 1421)
@@ -6,8 +6,8 @@
import jason.asSemantics.Intention;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
-import jason.asSyntax.DefaultTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.LiteralImpl;
@@ -18,6 +18,7 @@
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.asSyntax.VarTerm;
+import jason.asSyntax.parser.ParseException;
import jason.bb.BeliefBase;
import jason.bb.DefaultBeliefBase;
import jason.bb.JDBCPersistentBB;
@@ -184,7 +185,7 @@
assertEquals(iteratorSize(bb.iterator()), 0);
}
- public void testAdd2() {
+ public void testAdd2() throws ParseException {
BeliefBase bb = new DefaultBeliefBase();
Literal l1 = Literal.parseLiteral("pos[source(ag1)]");
assertTrue(bb.add(l1));
@@ -198,7 +199,7 @@
u.unifies(c, l3);
c.apply(u);
c.addSource(Structure.parse("ag3"));
- assertTrue(c.hasAnnot(DefaultTerm.parse("source(ag3)")));
+ assertTrue(c.hasAnnot(ASSyntax.parseTerm("source(ag3)")));
Literal inBB = bb.contains(c);
assertTrue(inBB != null);
assertFalse(c.hasSubsetAnnot(inBB));
@@ -217,7 +218,7 @@
u.unifies(c, Literal.parseLiteral("pos"));
c.apply(u);
try {
- new jason.stdlib.add_annot().execute(null, u, new Term[] { c, DefaultTerm.parse("source(ag4)"), ca });
+ new jason.stdlib.add_annot().execute(null, u, new Term[] { c, ASSyntax.parseTerm("source(ag4)"), ca });
} catch (Exception e) {
e.printStackTrace();
}
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-12-10 07:03:29 UTC (rev 1420)
+++ trunk/src/test/VarTermTest.java 2008-12-10 09:58:20 UTC (rev 1421)
@@ -5,8 +5,8 @@
import jason.asSemantics.Agent;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.ArithExpr;
-import jason.asSyntax.DefaultTerm;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
@@ -19,6 +19,7 @@
import jason.asSyntax.UnnamedVar;
import jason.asSyntax.VarTerm;
import jason.asSyntax.ArithExpr.ArithmeticOp;
+import jason.asSyntax.parser.ParseException;
import jason.asSyntax.parser.SimpleCharStream;
import jason.asSyntax.parser.Token;
import jason.asSyntax.parser.as2jTokenManager;
@@ -42,7 +43,7 @@
}
/** test when a var is ground with a Term or another var */
- public void testVarTermAsTerm() {
+ public void testVarTermAsTerm() throws ParseException {
VarTerm k = new VarTerm("K");
Unifier u = new Unifier();
u.unifies(k, new Structure("a1"));
@@ -102,8 +103,8 @@
i.next();
i.next();
Term third = i.next();
- Term toi1 = DefaultTerm.parse("a(oi)");
- Term toi2 = DefaultTerm.parse("a(B)");
+ Term toi1 = ASSyntax.parseTerm("a(oi)");
+ Term toi2 = ASSyntax.parseTerm("a(B)");
toi2.apply(u);
assertEquals(toi1,toi2);
assertTrue(third.equals(toi1));
@@ -378,7 +379,7 @@
assertTrue(u.unifies(exp, dois));
}
- public void testSimple2() {
+ public void testSimple2() throws ParseException {
VarTerm v = new VarTerm("X");
assertFalse(v.isAtom());
assertTrue(v.isVar());
@@ -392,15 +393,15 @@
assertFalse(t.isAtom());
assertTrue(t.isVar());
- t = DefaultTerm.parse("Event");
+ t = ASSyntax.parseTerm("Event");
assertFalse(t.isAtom());
assertTrue(t.isVar());
}
- public void testUnify1() {
- Term a1 = DefaultTerm.parse("s(1,2)");
- Term a2 = DefaultTerm.parse("s(X1,X2)");
+ public void testUnify1() throws ParseException {
+ Term a1 = ASSyntax.parseTerm("s(1,2)");
+ Term a2 = ASSyntax.parseTerm("s(X1,X2)");
Unifier u = new Unifier();
assertTrue(u.unifies(new VarTerm("X1"),new VarTerm("X3")));
assertTrue(u.unifies(a1,a2));
@@ -429,15 +430,15 @@
assertEquals(l.toString(),"op(1)");
}
- public void testUnnamedVar1() {
- Term a1 = DefaultTerm.parse("a(_,_)");
- Term a2 = DefaultTerm.parse("a(10,20)");
- Term a3 = DefaultTerm.parse("a(30,40)");
+ public void testUnnamedVar1() throws ParseException {
+ Term a1 = ASSyntax.parseTerm("a(_,_)");
+ Term a2 = ASSyntax.parseTerm("a(10,20)");
+ Term a3 = ASSyntax.parseTerm("a(30,40)");
Unifier u = new Unifier();
assertTrue(u.unifies(a1,a2));
assertFalse(u.unifies(a1,a3));
a1.apply(u);
- assertEquals(a1.toString(), DefaultTerm.parse("a(10,20)").toString());
+ assertEquals(a1.toString(), ASSyntax.parseTerm("a(10,20)").toString());
}
public void testUnnamedVar2() {
@@ -461,8 +462,8 @@
assertFalse(v.isGround());
}
- public void testUnamedVarAnnots() {
- Term t = DefaultTerm.parse("_[scheme(Id)]");
+ public void testUnamedVarAnnots() throws ParseException {
+ Term t = ASSyntax.parseTerm("_[scheme(Id)]");
Map<VarTerm,Integer> c = new HashMap<VarTerm, Integer>();
t.countVars(c);
assertEquals(1,c.get(new VarTerm("Id")).intValue());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-12-14 13:13:11
|
Revision: 1424
http://jason.svn.sourceforge.net/jason/?rev=1424&view=rev
Author: jomifred
Date: 2008-12-14 13:13:07 +0000 (Sun, 14 Dec 2008)
Log Message:
-----------
use ASSyntax if other examples
improve group_spec IA of jason-moise
Modified Paths:
--------------
trunk/applications/jason-moise/example/moise-tutorial/marcos.asl
trunk/applications/jason-moise/example/writePaper/olivier.asl
trunk/applications/jason-moise/src/jmoise/group_specification.java
trunk/demos/sync-environment/EnvSync.java
trunk/examples/airport/HeathrowEnv.java
trunk/examples/game-of-life/LifeEnvironment.java
trunk/examples/gold-miners/mining/MiningPlanet.java
trunk/examples/gold-miners-II/env/MiningEnvironment.java
trunk/examples/sniffer/comm/SnifferCentralised.java
trunk/release-notes.txt
Modified: trunk/applications/jason-moise/example/moise-tutorial/marcos.asl
===================================================================
--- trunk/applications/jason-moise/example/moise-tutorial/marcos.asl 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/applications/jason-moise/example/moise-tutorial/marcos.asl 2008-12-14 13:13:07 UTC (rev 1424)
@@ -3,3 +3,13 @@
+!do(X) <- .print("doing ",X); X; gui.list_bels.
-!do(X)[code(C)] <- .print("error in ",C).
++play(Me,R,GrInst)
+ : .my_name(Me) & group(GrSpec,GrInst)
+ <- jmoise.group_specification(GrSpec,Roles);
+ .member(role(R,Min,Max,Compat,Links),Roles);
+ .print("I am starting playing ",R);
+ .print(" -- cardinality of my role (Min,Max): (",Min,",",Max,")");
+ .print(" -- roles compatible with mine: ", Compat);
+ .print(" -- all roles of the group are ",Roles);
+ .print(" -- sub-groups are ",SubGroups).
+
Modified: trunk/applications/jason-moise/example/writePaper/olivier.asl
===================================================================
--- trunk/applications/jason-moise/example/writePaper/olivier.asl 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/applications/jason-moise/example/writePaper/olivier.asl 2008-12-14 13:13:07 UTC (rev 1424)
@@ -30,16 +30,14 @@
<- .print("adding ref ",NewRef, " to ", R);
-refs(R); +refs([NewRef|R]).
-+play(Me,R,_)
- : .my_name(Me)
- <- jmoise.group_specification(wpgroup,S);
- S = group_specification(_,Roles,_,_);
++play(Me,R,GrInst)
+ : .my_name(Me) & group(GrSpec,GrInst)
+ <- jmoise.group_specification(GrSpec,Roles);
.member(role(R,Min,Max,Compat,Links),Roles);
.print("I am starting playing ",R);
.print(" -- cardinality of my role (Min,Max): (",Min,",",Max,")");
.print(" -- roles compatible with mine: ", Compat);
- .print(" -- links of my role: ",Links);
- .print(" -- all specification of the group is ",S).
+ .print(" -- all roles of the group are ",Roles).
Modified: trunk/applications/jason-moise/src/jmoise/group_specification.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/group_specification.java 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/applications/jason-moise/src/jmoise/group_specification.java 2008-12-14 13:13:07 UTC (rev 1424)
@@ -6,35 +6,40 @@
import jason.asSemantics.Unifier;
import jason.asSyntax.ASSyntax;
import jason.asSyntax.StringTerm;
+import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import moise.os.ss.Group;
/**
-
+
+ <p><b><code>jmoise.group_specification( GrSpecId [, Roles [, Sub-groups [, Properties ]]] )</code></b>:
Obtains a representation (as a term) of a group specification.
+ Roles is a list with all roles of the group. Each role is a structure like
+ <code>role(RoleId,MinPlayers,MaxPlayers,CompatibleRoles,Links)</code>
+
Example:
<pre>
- +play(Me,R,_)
- : .my_name(Me)
- <- jmoise.group_specification(wpgroup,S);
- S = group_specification(GrId,Roles,SubGroups,Properties);
- .member(role(R,Min,Max,Compat,Links),Roles);
- .print("I am starting playing ",R);
+ +play(Me,R,GrInst) // when I adopted a new role ...
+ : .my_name(Me) & group(GrSpec,GrInst)
+ <- jmoise.group_specification(GrSpec,Roles,SubGroups); // the group's properties are not obtained
+ .member(role(R,Min,Max,Compat,Links),Roles); // find details of my role
+ .print("I am starting playing ",R," in ",GrInst);
.print(" -- cardinality of my role (Min,Max): (",Min,",",Max,")");
.print(" -- roles compatible with mine: ", Compat);
.print(" -- links of my role: ",Links);
- .print(" -- all specification of the group is ",S).
+ .print(" -- all roles of the group are ",Roles);
+ .print(" -- sub-groups are ",SubGroups).
</pre>
- @author hubner
+ @author Jomi Hubner
*/
public class group_specification extends DefaultInternalAction {
- @Override public int getMaxArgs() { return 2; }
- @Override public int getMinArgs() { return 2; }
+ @Override public int getMaxArgs() { return 4; }
+ @Override public int getMinArgs() { return 1; }
@Override protected void checkArguments(Term[] args) throws JasonException {
super.checkArguments(args);
@@ -56,6 +61,15 @@
Group g = oag.getOE().getOS().getSS().getRootGrSpec().findSubGroup(grId);
if (g == null)
throw new JasonException("the group with id '"+grId+"' does not exists in the OS.");
- return un.unifies(args[1], ASSyntax.parseTerm(g.getAsProlog()));
+
+ Structure gstructure = ASSyntax.parseStructure(g.getAsProlog());
+
+ int i = 1;
+ while (i < args.length && i < gstructure.getArity()) {
+ if (! un.unifies(args[i], gstructure.getTerm(i)))
+ return false;
+ i++;
+ }
+ return true;
}
}
Modified: trunk/demos/sync-environment/EnvSync.java
===================================================================
--- trunk/demos/sync-environment/EnvSync.java 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/demos/sync-environment/EnvSync.java 2008-12-14 13:13:07 UTC (rev 1424)
@@ -1,5 +1,6 @@
// Environment code for project act-sync.mas2j
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Literal;
import jason.asSyntax.LiteralImpl;
import jason.asSyntax.NumberTermImpl;
@@ -25,8 +26,7 @@
@Override
public boolean executeAction(String agName, Structure action) {
actionCount++;
- Literal p = new LiteralImpl("executed_actions");
- p.addTerm(new NumberTermImpl(actionCount));
+ Literal p = ASSyntax.createLiteral("executed_actions", ASSyntax.createNumber(actionCount));
clearPercepts();
addPercept(p);
return true;
Modified: trunk/examples/airport/HeathrowEnv.java
===================================================================
--- trunk/examples/airport/HeathrowEnv.java 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/examples/airport/HeathrowEnv.java 2008-12-14 13:13:07 UTC (rev 1424)
@@ -3,16 +3,13 @@
import jason.asSyntax.Structure;
import jason.environment.Environment;
-import java.util.HashMap;
-import java.util.Map;
-
public class HeathrowEnv extends Environment {
Literal[] initialLocations = { Literal.parseLiteral("location(t1,g1)"),
Literal.parseLiteral("location(t1,g2)"),
Literal.parseLiteral("location(t1,g3)")};
- Map agsLocation = new HashMap();
+ //Map agsLocation = new HashMap();
@Override
public void init(String[] args) {
Modified: trunk/examples/game-of-life/LifeEnvironment.java
===================================================================
--- trunk/examples/game-of-life/LifeEnvironment.java 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/examples/game-of-life/LifeEnvironment.java 2008-12-14 13:13:07 UTC (rev 1424)
@@ -1,8 +1,7 @@
// Environment code for project game-of-life.mas2j
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Literal;
-import jason.asSyntax.LiteralImpl;
-import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Structure;
import jason.environment.grid.Location;
@@ -44,8 +43,7 @@
@Override
protected void stepStarted(int step) {
//logger.info("start step "+step);
- lstep = new LiteralImpl("step");
- lstep.addTerm(new NumberTermImpl(step+1));
+ lstep = ASSyntax.createLiteral("step", ASSyntax.createNumber(step+1));
}
private long sum = 0;
@@ -110,8 +108,7 @@
if (model.isAlive(l.x + 1, l.y - 1)) alive++;
if (model.isAlive(l.x + 1, l.y)) alive++;
if (model.isAlive(l.x + 1, l.y + 1)) alive++;
- Literal lAlive = new LiteralImpl("alive_neighbors");
- lAlive.addTerm(new NumberTermImpl(alive));
+ Literal lAlive = ASSyntax.createLiteral("alive_neighbors", ASSyntax.createNumber(alive));
addPercept(agName, lAlive);
addPercept(agName, lstep);
Modified: trunk/examples/gold-miners/mining/MiningPlanet.java
===================================================================
--- trunk/examples/gold-miners/mining/MiningPlanet.java 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/examples/gold-miners/mining/MiningPlanet.java 2008-12-14 13:13:07 UTC (rev 1424)
@@ -2,7 +2,6 @@
// Environment code for project jasonTeamSimLocal.mas2j
-import jason.asSyntax.DefaultTerm;
import jason.asSyntax.Literal;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
@@ -25,16 +24,15 @@
boolean running = true;
boolean hasGUI = true;
- public static final int SIM_TIME = 60; // in
- // seconds
+ public static final int SIM_TIME = 60; // in seconds
- Term up = DefaultTerm.parse("do(up)");
- Term down = DefaultTerm.parse("do(down)");
- Term right = DefaultTerm.parse("do(right)");
- Term left = DefaultTerm.parse("do(left)");
- Term skip = DefaultTerm.parse("do(skip)");
- Term pick = DefaultTerm.parse("do(pick)");
- Term drop = DefaultTerm.parse("do(drop)");
+ Term up = Literal.parseLiteral("do(up)");
+ Term down = Literal.parseLiteral("do(down)");
+ Term right = Literal.parseLiteral("do(right)");
+ Term left = Literal.parseLiteral("do(left)");
+ Term skip = Literal.parseLiteral("do(skip)");
+ Term pick = Literal.parseLiteral("do(pick)");
+ Term drop = Literal.parseLiteral("do(drop)");
public enum Move {
UP, DOWN, RIGHT, LEFT
Modified: trunk/examples/gold-miners-II/env/MiningEnvironment.java
===================================================================
--- trunk/examples/gold-miners-II/env/MiningEnvironment.java 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/examples/gold-miners-II/env/MiningEnvironment.java 2008-12-14 13:13:07 UTC (rev 1424)
@@ -1,9 +1,8 @@
package env;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
-import jason.asSyntax.LiteralImpl;
-import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.environment.SteppedEnvironment;
@@ -179,8 +178,8 @@
logger.warning("Error creating world "+e);
}
}
- public static Atom aCAP = new LiteralImpl("container_has_space");
+ public static Literal aCAP = ASSyntax.createLiteral("container_has_space");
public static Atom aOBSTACLE = new Atom("obstacle");
public static Atom aGOLD = new Atom("gold");
public static Atom aENEMY = new Atom("enemy");
@@ -202,12 +201,13 @@
clearPercepts(agName);
// its location
Location l = model.getAgPos(ag);
- Literal p = new LiteralImpl("pos");
- p.addTerms(new NumberTermImpl(l.x), new NumberTermImpl(l.y), new NumberTermImpl(getStep()));
+ Literal p = ASSyntax.createLiteral("pos",
+ ASSyntax.createNumber(l.x),
+ ASSyntax.createNumber(l.y),
+ ASSyntax.createNumber(getStep()));
addPercept(agName, p);
- Literal cg = new LiteralImpl("carrying_gold");
- cg.addTerm(new NumberTermImpl(model.getGoldsWithAg(ag)));
+ Literal cg = ASSyntax.createLiteral("carrying_gold", ASSyntax.createNumber(model.getGoldsWithAg(ag)));
addPercept(agName, cg);
if (model.mayCarryMoreGold(ag)) {
@@ -255,14 +255,12 @@
}
public static Literal createCellPerception(int x, int y, Atom obj) {
- Literal l = new LiteralImpl("cell");
- l.addTerms(new NumberTermImpl(x),
- new NumberTermImpl(y),
- obj);
- return l;
+ return ASSyntax.createLiteral("cell",
+ ASSyntax.createNumber(x),
+ ASSyntax.createNumber(y),
+ obj);
}
-
Integer nextWorld;
Modified: trunk/examples/sniffer/comm/SnifferCentralised.java
===================================================================
--- trunk/examples/sniffer/comm/SnifferCentralised.java 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/examples/sniffer/comm/SnifferCentralised.java 2008-12-14 13:13:07 UTC (rev 1424)
@@ -4,10 +4,9 @@
import jason.RevisionFailedException;
import jason.architecture.AgArch;
import jason.asSemantics.Message;
+import jason.asSyntax.ASSyntax;
import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
-import jason.asSyntax.LiteralImpl;
-import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Structure;
import jason.infra.centralised.CentralisedAgArch;
@@ -40,20 +39,17 @@
// add a belief in the agent mind
// format: msgSent(time(YY,MM,DD,HH,MM,SS),id,irt,ilf,sender,receiver,content)
- Literal e = new LiteralImpl("msg_sent");
Calendar now = new GregorianCalendar();
- Structure p = new Structure("time");
- p.addTerms(
- new NumberTermImpl(now.get(Calendar.YEAR)),
- new NumberTermImpl(now.get(Calendar.MONTH)),
- new NumberTermImpl(now.get(Calendar.DAY_OF_MONTH)),
- new NumberTermImpl(now.get(Calendar.HOUR)),
- new NumberTermImpl(now.get(Calendar.MINUTE)),
- new NumberTermImpl(now.get(Calendar.SECOND)));
- e.addTerm(p);
+ Structure p = ASSyntax.createStructure("time",
+ ASSyntax.createNumber(now.get(Calendar.YEAR)),
+ ASSyntax.createNumber(now.get(Calendar.MONTH)),
+ ASSyntax.createNumber(now.get(Calendar.DAY_OF_MONTH)),
+ ASSyntax.createNumber(now.get(Calendar.HOUR)),
+ ASSyntax.createNumber(now.get(Calendar.MINUTE)),
+ ASSyntax.createNumber(now.get(Calendar.SECOND)));
+ Literal e = ASSyntax.createLiteral("msg_sent", p);
-
e.addTerm(new StringTermImpl(m.getMsgId()));
if (m.getInReplyTo() == null) {
e.addTerm(new Atom("nirt"));
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-12-14 11:51:45 UTC (rev 1423)
+++ trunk/release-notes.txt 2008-12-14 13:13:07 UTC (rev 1424)
@@ -63,6 +63,8 @@
new Literal(...)
have to be written as
ASSyntax.createLiteral(....)
+ the class ASSyntax is the preferred factory for the creation
+ of all kind of terms.
see API doc for more details.
see discussion about the Literal class in the
jason-developers list.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-12-26 19:59:09
|
Revision: 1425
http://jason.svn.sourceforge.net/jason/?rev=1425&view=rev
Author: jomifred
Date: 2008-12-26 19:59:05 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
latest changes for the 5 years old jason release - 1.2.0 - birthday release for 6/1/2009
Modified Paths:
--------------
trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/core/JasonInternalInfras.java
trunk/applications/jason-team/doc/cowz.txt
trunk/doc/jason.doxygen
trunk/release-notes.txt
trunk/src/jason/architecture/AgArch.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/infra/jade/RunJadeMAS.java
trunk/src/jason/jeditplugin/JasonID.java
trunk/src/jason/jeditplugin/JasonIDOptionPanel.java
trunk/src/jason/jeditplugin/NewEnvironmentGUI.java
trunk/src/jason/jeditplugin/NewInternalActionGUI.java
trunk/src/jason/jeditplugin/NewProjectGUI.java
Modified: trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/core/JasonInternalInfras.java
===================================================================
--- trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/core/JasonInternalInfras.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/applications/jason-eclipse-plugin/src/net/sourceforge/jasonide/core/JasonInternalInfras.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -19,7 +19,7 @@
public static final String SACI = "Saci";
/**
- * Infrastructure Jade based.
+ * Infrastructure JADE based.
*/
- public static final String JADE = "Jade";
+ public static final String JADE = "JADE";
}
Modified: trunk/applications/jason-team/doc/cowz.txt
===================================================================
--- trunk/applications/jason-team/doc/cowz.txt 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/applications/jason-team/doc/cowz.txt 2008-12-26 19:59:05 UTC (rev 1425)
@@ -4523,4 +4523,3 @@
* ||----|| |-----|| |----|| *
^^ ^^ ^ ^^ ^ ^^
Fight, fight, fight!
-
\ No newline at end of file
Modified: trunk/doc/jason.doxygen
===================================================================
--- trunk/doc/jason.doxygen 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/doc/jason.doxygen 2008-12-26 19:59:05 UTC (rev 1425)
@@ -31,7 +31,7 @@
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 1.1.3
+PROJECT_NUMBER = 1.2.0
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/release-notes.txt 2008-12-26 19:59:05 UTC (rev 1425)
@@ -12,21 +12,22 @@
. annotations in failure events. All failure events are now
annotated with:
error(<atom: error id>): the identification of the type of error,
- values used by Jason are
- no_applicable: no applicable plan
- no_relevant: no relevant plan
- no_option: no option selected
- constraint_failed: constraint failed
- ia_failed: internal action returned false
- action_failed: action failed in the environment
- ask_failed: answer for an ask message failed
- wrong_arguments: throw by internal actions
- unknown
+ values used by Jason are:
+ no_applicable: no applicable plan
+ no_relevant: no relevant plan
+ no_option: no option selected
+ constraint_failed: constraint (i.e., a logic expression in
+ the plan body) failed
+ ia_failed: internal action returned false
+ action_failed: environment action failed
+ ask_failed: answer to an ask message failed (due to timeout)
+ wrong_arguments: wrong arguments (type and/or number) passed
+ to an internal action
- error_msg(<string>): the human readable message of the error
- code(<literal>): the command that failed
- code_src(<string>): the file where the command is
- code_line(<int>): the line in the file
+ error_msg(<string>): the human readable message for the error
+ code(<literal>): the part of the plan body where the failure occurred
+ code_src(<string>): the file where the failure was
+ code_line(<int>): the line in that file
see demo/failure for an example
see FAQ for more details
see code of JasonException and TS for more information
@@ -35,39 +36,36 @@
. new base class for internal actions: ConcurrentInternalAction. This
class can be used in place of DefaultInternalAction to create an IA
- that suspend the intention while it is being executed. For example:
- a plan may ask something to an user and wait the answer. If
- DefaultInternalAction is used for that, all the agent thread is
- blocked until the answer. With ConcurrentInternalAction, only the
- intention using the IA is suspended. See demos/gui/gui1 and the API
- doc of the new class.
+ that suspends the intention while it is being executed. For example,
+ if DefaultInternalAction is used for an action that requires user
+ input, the agent's thread is blocked until an answer is given by the
+ user. With ConcurrentInternalAction, only the intention using the IA
+ is suspended. See demos/gui/gui1 and the API doc of this new class.
. API doc uses UMLGraph to show relations between classes
New internal actions
-. .term2string: transform term into strings and vice-versa.
+. .term2string: transforms a term into a string and vice-versa.
New functions
-. .math.sum: sums a list of numbers
-. .math.average: returns the average of a list of numbers
+. .math.sum: sums a list of numbers
+. .math.average: returns the average of a list of numbers
API changes
-. the most significant change is in the Literal class, that
- is abstract now. To create a new literal, the previous
- method
+. the most significant change is in the Literal class, which
+ is now abstract. To create a new literal, the previous method
Literal.parseLiteral(....)
still works, but
new Literal(...)
- have to be written as
+ has to be written as
ASSyntax.createLiteral(....)
- the class ASSyntax is the preferred factory for the creation
- of all kind of terms.
- see API doc for more details.
- see discussion about the Literal class in the
- jason-developers list.
+ the ASSyntax factory is the preferred approach for the creation of all
+ types of terms.
+ see API doc for further details.
+ see discussion about the Literal class in the jason-developers list.
-------------
Modified: trunk/src/jason/architecture/AgArch.java
===================================================================
--- trunk/src/jason/architecture/AgArch.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/architecture/AgArch.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -46,7 +46,7 @@
*
* <p>
* This class normally just calls the AgArchInfraTier methods
- * implemented by the infrastructure tier (Centralised, Jade, Saci, ...).
+ * implemented by the infrastructure tier (Centralised, JADE, Saci, ...).
* However, the user can customise
* these methods overriding some of them in his/her arch. class.
*/
@@ -81,7 +81,7 @@
ag.initAg(asSrc); // load the source code of the agent
} catch (Exception e) {
- throw new JasonException("as2j: error creating the agent class! - ", e);
+ throw new JasonException("as2j: error creating the customised Agent class! - ", e);
}
}
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/asSemantics/Agent.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -141,8 +141,8 @@
logger.warning("The kqmlPlans.asl was not found!");
}
} catch (Exception e) {
- logger.log(Level.SEVERE, "Error creating the agent class!", e);
- throw new JasonException("Error creating the agent class! - " + e);
+ logger.log(Level.SEVERE, "Error creating customised Agent class!", e);
+ throw new JasonException("Error creating customised Agent class! - " + e);
}
}
@@ -553,7 +553,7 @@
return true;
}
} catch (Exception e) {
- logger.log(Level.SEVERE, "Error in believe("+bel+","+un+").",e);
+ logger.log(Level.SEVERE, "** Error in method believes("+bel+","+un+").",e);
}
return false;
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -185,7 +185,7 @@
if (intention.peek().getUnif().unifies(send.getTerm(3), content)) {
getC().addIntention(intention);
} else {
- generateGoalDeletion(intention, JasonException.createBasicErrorAnnots("ask_failed", "answer of ask does no unify forth argument of .send"));
+ generateGoalDeletion(intention, JasonException.createBasicErrorAnnots("ask_failed", "reply of an ask message does not unify with forth argument of .send"));
}
// the message is not an ask answer
@@ -463,7 +463,7 @@
ok = true; // just to not generate the event again
} catch (Exception e) {
if (body == null)
- logger.log(Level.SEVERE, "Body is not a literal for body '"+h+"' and IM "+im, e);
+ logger.log(Level.SEVERE, "Selected an intention with null body in '"+h+"' and IM "+im, e);
else
logger.log(Level.SEVERE, body.getErrorMsg()+": "+ e.getMessage(), e);
}
@@ -804,7 +804,7 @@
failEeventGenerated = true;
if (logger.isLoggable(Level.FINE)) logger.fine("Generating goal deletion " + failEvent.getTrigger() + " from goal: " + im.getTrigger());
} else {
- logger.warning("No fail event was generated for " + im.getTrigger());
+ logger.warning("No failure event was generated for " + im.getTrigger());
}
}
// if "discard" is set, we are deleting the whole intention!
@@ -824,7 +824,7 @@
private boolean generateGoalDeletionFromEvent(List<Term> failAnnots) throws JasonException {
Event ev = conf.C.SE;
if (ev == null) {
- logger.warning("** It is not possible to generate a goal deletion event because SE is null! " + conf.C);
+ logger.warning("** It was not possible to generate a goal deletion event because SE is null! " + conf.C);
return false;
}
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/asSyntax/Pred.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -327,13 +327,13 @@
if (annots != null)
return annots.remove(createSource(agName));
else
- return false;
+ return false;
}
public static Term createSource(Term source) {
- Structure s = new Structure("source",1);
- s.addTerm(source);
- return s;
+ Structure s = new Structure("source",1);
+ s.addTerm(source);
+ return s;
}
@Override
@@ -394,10 +394,10 @@
@Override
public void makeVarsAnnon(Unifier un) {
if (annots != null) {
- Iterator<ListTerm> i = annots.listTermIterator();
- while (i.hasNext()) {
- ListTerm lt = i.next();
- Term ta = lt.getTerm();
+ Iterator<ListTerm> i = annots.listTermIterator();
+ while (i.hasNext()) {
+ ListTerm lt = i.next();
+ Term ta = lt.getTerm();
if (ta.isVar() && !ta.isUnnamedVar()) {
// replace ta to an unnamed var
@@ -411,7 +411,7 @@
}
lt.setTerm(uv);
} else if (ta.isStructure()) {
- ((Structure)ta).makeVarsAnnon(un);
+ ((Structure)ta).makeVarsAnnon(un);
}
}
}
Modified: trunk/src/jason/infra/jade/RunJadeMAS.java
===================================================================
--- trunk/src/jason/infra/jade/RunJadeMAS.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/infra/jade/RunJadeMAS.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -95,7 +95,7 @@
});
MASConsoleGUI.get().addButton(btRMA);
- JButton btSniffer = new JButton("Jade Sniffer", new ImageIcon(jade.tools.sniffer.Sniffer.class.getResource("/jade/tools/sniffer/images/sniffer.gif")));
+ JButton btSniffer = new JButton("JADE Sniffer", new ImageIcon(jade.tools.sniffer.Sniffer.class.getResource("/jade/tools/sniffer/images/sniffer.gif")));
btSniffer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
Modified: trunk/src/jason/jeditplugin/JasonID.java
===================================================================
--- trunk/src/jason/jeditplugin/JasonID.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/jeditplugin/JasonID.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -111,7 +111,7 @@
textArea = new JTextArea(5, 10);
textArea.setEditable(false);
- textArea.setText("Jason functions are also available in the Plugin-Jason menu.");
+ textArea.setText("Further Jason functionalities are available in the menu Plugin->Jason.");
JPanel pane = new JPanel(new BorderLayout());
pane.add(BorderLayout.CENTER, new JScrollPane(textArea));
@@ -393,11 +393,11 @@
textArea.append(" parsed successfully!\n");
return project;
- } catch (ParseException ex) {
- textArea.append("\nmas2j: parsing errors found... \n" + ex + "\n");
+ } catch (ParseException ex) {
+ textArea.append("\nmas2j: syntactic errors found... \n" + ex + "\n");
JasonProjectSideKickParser.addError(ex, errorSource, projectBufffer.getPath());
} catch (TokenMgrError ex) {
- textArea.append("\nmas2j: error parsing tokens ... \n" + ex + "\n");
+ textArea.append("\nmas2j: lexical errors found... \n" + ex + "\n");
} catch (Exception ex) {
textArea.append("Error: " + ex);
ex.printStackTrace();
@@ -425,7 +425,7 @@
return true;
} catch (jason.asSyntax.parser.ParseException ex) {
- textArea.append("\nas2j: parsing errors found... \n" + ex + "\n");
+ textArea.append("\nas2j: syntactic errors found... \n" + ex + "\n");
AgentSpeakSideKickParser.addError(ex, errorSource, asFile.getAbsolutePath());
DockableWindowManager d = view.getDockableWindowManager();
if (!d.isDockableWindowVisible("error-list")) {
@@ -433,7 +433,7 @@
}
} catch (TokenMgrError ex) {
- textArea.append("\nmas2j: error parsing tokens ... \n" + ex + "\n");
+ textArea.append("\nmas2j: lexical errors found... \n" + ex + "\n");
} catch (Exception ex) {
textArea.append("\nError: " + ex);
ex.printStackTrace();
@@ -505,19 +505,19 @@
String jasonJar = Config.get().getJasonJar();
if (!Config.checkJar(jasonJar)) {
System.err.println("The path to the jason.jar file (" + jasonJar
- + ") was not correctly set, the MAS may not run. Go to menu Plugins->Plugins Options->Jason to configure the path.");
+ + ") was not correctly set: the MAS may not run. Go to menu Plugins->Plugins Options->Jason to configure the path.");
return;
}
String javaHome = Config.get().getJavaHome();
if (!Config.checkJavaHomePath(javaHome)) {
System.err.println("The Java home directory (" + javaHome
- + ") was not correctly set, the MAS may not run. Go to the Plugins->Options->Jason menu to configure the path.");
+ + ") was not correctly set: the MAS may not run. Go to the Plugins->Options->Jason menu to configure the path.");
return;
}
String antLib = Config.get().getAntLib();
if (!Config.checkAntLib(antLib)) {
System.err.println("The ant lib directory (" + antLib
- + ") was not correctly set, the MAS may not run. Go to the Plugins->Options->Jason menu to configure the path.");
+ + ") was not correctly set: the MAS may not run. Go to the Plugins->Options->Jason menu to configure the path.");
return;
}
@@ -560,21 +560,21 @@
public void newAg() {
Buffer b = getProjectBuffer();
if (b == null) {
- textArea.setText("There is no Jason project opened to add an agent, create a project first.");
+ textArea.setText("There is no Jason project opened to add an agent to: create a new project first.");
} else {
- new NewAgentGUI("Add an agent in project " + b.getName(), b, view, b.getDirectory());
+ new NewAgentGUI("Adding an agent to project " + b.getName(), b, view, b.getDirectory());
}
}
public void createEnv() {
Buffer b = getProjectBuffer();
if (b == null) {
- textArea.setText("There is no Jason project opened, create a project first.");
+ textArea.setText("There is no Jason project opened: create a new project first.");
} else {
if (b.getText(0, b.getLength()).indexOf("environment") > 0) {
textArea.setText("Your project already has an environment definition!");
} else {
- new NewEnvironmentGUI("Create environment for project " + b.getName(), b, view);
+ new NewEnvironmentGUI("Creating an environment for project " + b.getName(), b, view);
}
}
}
@@ -582,16 +582,16 @@
public void newIA() {
Buffer b = getProjectBuffer();
if (b == null) {
- textArea.setText("There is no Jason project opened, create a project first.");
+ textArea.setText("There is no Jason project opened: create a new project first.");
} else {
- new NewInternalActionGUI("Create new internal action for project " + b.getName(), b, view);
+ new NewInternalActionGUI("Creating new internal action for project " + b.getName(), b, view);
}
}
public void editLog() {
Buffer curBuf = getProjectBuffer();
if (curBuf == null) {
- textArea.setText("You can not edit log properties since there is no Jason project opened.");
+ textArea.setText("There is no Jason project opened: you cannot edit logging properties.");
return;
}
try {
@@ -625,7 +625,7 @@
private void asl2txt(asl2xml transformer, String ext) {
Buffer buf = view.getBuffer();
if (!buf.getPath().endsWith(MAS2JProject.AS_EXT)) {
- textArea.setText("\n** The current buffer is not an asl source!");
+ textArea.setText("\n** The current buffer is not an AgentSpeak source!");
return;
} else {
textArea.setText("");
Modified: trunk/src/jason/jeditplugin/JasonIDOptionPanel.java
===================================================================
--- trunk/src/jason/jeditplugin/JasonIDOptionPanel.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/jeditplugin/JasonIDOptionPanel.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -136,14 +136,14 @@
public void actionPerformed(ActionEvent arg0) {
try {
JFileChooser chooser = new JFileChooser(System.getProperty("user.dir"));
- chooser.setDialogTitle("Select the Java JDK Home directory");
+ chooser.setDialogTitle("Select the Java JDK home directory");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
String javaHome = (new File(chooser.getSelectedFile().getPath())).getCanonicalPath();
if (Config.checkJavaHomePath(javaHome)) {
javaTF.setText(javaHome);
} else {
- JOptionPane.showMessageDialog(null, "The selected JDK home directory has not the file bin/javac inside!");
+ JOptionPane.showMessageDialog(null, "The selected JDK home directory doesn't have the bin/javac file!");
}
}
} catch (Exception e) {}
@@ -172,7 +172,7 @@
if (Config.checkAntLib(antLib)) {
antTF.setText(antLib);
} else {
- JOptionPane.showMessageDialog(null, "The selected directory has not the files ant.jar and ant-launcher.jar!");
+ JOptionPane.showMessageDialog(null, "The selected directory doesn't have the files ant.jar and ant-launcher.jar!");
}
}
} catch (Exception e) {}
@@ -187,7 +187,7 @@
jadeArgsTF = new JTextField(30);
JPanel jadeHomePanel = new JPanel(new GridLayout(0,1));
jadeHomePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory
- .createEtchedBorder(), "Jade", TitledBorder.LEFT, TitledBorder.TOP));
+ .createEtchedBorder(), "JADE", TitledBorder.LEFT, TitledBorder.TOP));
JPanel jadeJarPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
jadeJarPanel.add(new JLabel("jade.jar location"));
@@ -201,12 +201,12 @@
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
jadeRmaCB = new JCheckBox();
- jadeRmaCB.setToolTipText("Whether the Jade management agent should be started in the begin.");
+ jadeRmaCB.setToolTipText("Should the JADE management agent be run at startup?");
p.add(jadeRmaCB);
p.add(new JLabel("Start management agent "));
jadeSnifferCB = new JCheckBox();
- jadeSnifferCB.setToolTipText("Whether the Jade sniffer agent should be started in the begin and sniffing all agents.");
+ jadeSnifferCB.setToolTipText("Should the JADE sniffer agent be run at startup?");
p.add(jadeSnifferCB);
p.add(new JLabel("Start Sniffer"));
jadeHomePanel.add(p);
Modified: trunk/src/jason/jeditplugin/NewEnvironmentGUI.java
===================================================================
--- trunk/src/jason/jeditplugin/NewEnvironmentGUI.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/jeditplugin/NewEnvironmentGUI.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -28,7 +28,7 @@
// Fields
envClass = new JTextField(20);
- createField("Environment class name", envClass, "The name of the environment java class.");
+ createField("Environment class name", envClass, "Enter the name of the environment Java class here.");
JPanel p = new JPanel(new BorderLayout());
p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "New environment parameters", TitledBorder.LEFT, TitledBorder.TOP));
Modified: trunk/src/jason/jeditplugin/NewInternalActionGUI.java
===================================================================
--- trunk/src/jason/jeditplugin/NewInternalActionGUI.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/jeditplugin/NewInternalActionGUI.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -29,10 +29,10 @@
// Fields
iaPkg = new JTextField(20);
- createField("Java package", iaPkg, "The name of the java package of the new internal action.");
+ createField("Java package", iaPkg, "Enter the name of the Java package of the new internal action here.");
iaClass = new JTextField(20);
- createField("Internal action name", iaClass, "The name of the new internal action class.");
+ createField("Internal action name", iaClass, "Enter the name of the new internal action class here.");
JPanel p = new JPanel(new BorderLayout());
p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "New internal action parameters", TitledBorder.LEFT, TitledBorder.TOP));
@@ -45,11 +45,11 @@
protected boolean ok() {
if (iaPkg.getText().trim().length() == 0) {
- JOptionPane.showMessageDialog(this, "An package name must be informed.");
+ JOptionPane.showMessageDialog(this, "A package name must be informed.");
return false;
}
if (iaClass.getText().trim().length() == 0) {
- JOptionPane.showMessageDialog(this, "A name for the action must be informed.");
+ JOptionPane.showMessageDialog(this, "A name for the internal action must be informed.");
return false;
}
Modified: trunk/src/jason/jeditplugin/NewProjectGUI.java
===================================================================
--- trunk/src/jason/jeditplugin/NewProjectGUI.java 2008-12-14 13:13:07 UTC (rev 1424)
+++ trunk/src/jason/jeditplugin/NewProjectGUI.java 2008-12-26 19:59:05 UTC (rev 1425)
@@ -48,7 +48,7 @@
// Fields
projName = new JTextField(10);
- createField("Project name", projName, "The project name");
+ createField("Project name", projName, "Enter he project name here");
// projEnv = new JTextField(20);
// createField("Environment class", projEnv, "The java class that
@@ -85,7 +85,7 @@
pFields.add(jasonHomePanel);
projFinalDir = new JLabel();
- createField("Directory", projFinalDir, "The directory that will be created for the project.");
+ createField("Directory", projFinalDir, "This is the directory that will be created for the new project");
// doc listener for Final proj dir
DocumentListener docLis = new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2009-01-06 14:56:41
|
Revision: 1427
http://jason.svn.sourceforge.net/jason/?rev=1427&view=rev
Author: jomifred
Date: 2009-01-06 14:56:38 +0000 (Tue, 06 Jan 2009)
Log Message:
-----------
add demo related to java objects as terms
Modified Paths:
--------------
trunk/applications/jason-eclipse-plugin/build.xml
Added Paths:
-----------
trunk/demos/java-object-terms/
trunk/demos/java-object-terms/ObjectTerm.mas2j
trunk/demos/java-object-terms/date/
trunk/demos/java-object-terms/date/add_days.java
trunk/demos/java-object-terms/date/today.java
trunk/demos/java-object-terms/sample.asl
Modified: trunk/applications/jason-eclipse-plugin/build.xml
===================================================================
--- trunk/applications/jason-eclipse-plugin/build.xml 2009-01-06 14:19:25 UTC (rev 1426)
+++ trunk/applications/jason-eclipse-plugin/build.xml 2009-01-06 14:56:38 UTC (rev 1427)
@@ -12,7 +12,7 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="2" />
+ <property name="release" value="2.0" />
<property name="distDir" value="${basedir}/dist" />
<property name="distDirPlugins" value="${distDir}/plugins" />
Added: trunk/demos/java-object-terms/ObjectTerm.mas2j
===================================================================
--- trunk/demos/java-object-terms/ObjectTerm.mas2j (rev 0)
+++ trunk/demos/java-object-terms/ObjectTerm.mas2j 2009-01-06 14:56:38 UTC (rev 1427)
@@ -0,0 +1,15 @@
+/*
+ Jason Project
+
+ Shows how to create variable terms that encapsulates Java Objects.
+ See sample.asl for more details.
+
+ -- created on February 21, 2008
+*/
+
+MAS java_object_term {
+
+ agents:
+ sample;
+
+}
\ No newline at end of file
Added: trunk/demos/java-object-terms/date/add_days.java
===================================================================
--- trunk/demos/java-object-terms/date/add_days.java (rev 0)
+++ trunk/demos/java-object-terms/date/add_days.java 2009-01-06 14:56:38 UTC (rev 1427)
@@ -0,0 +1,34 @@
+// Internal action code for project ObjectTerm
+
+package date;
+
+import jason.asSemantics.*;
+import jason.asSyntax.*;
+
+import java.util.Calendar;
+import java.util.logging.Logger;
+
+public class add_days extends DefaultInternalAction {
+
+ private Logger logger = Logger.getLogger("ObjectTerm."+add_days.class.getName());
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ // get the object wrapped by args[0]
+ Calendar c = (Calendar) ((ObjectTerm)args[0]).getObject();
+
+ // clone (so to not change the original object)
+ c = (Calendar)c.clone();
+
+ // do the changes
+ c.add(Calendar.DAY_OF_YEAR, (int)((NumberTerm)args[1]).solve());
+
+ // unify the result
+ return un.unifies(args[2], new ObjectTermImpl(c));
+ } catch (Exception e) {
+ logger.warning("Error in internal action 'date.add_days'! "+e);
+ }
+ return false;
+ }
+}
Added: trunk/demos/java-object-terms/date/today.java
===================================================================
--- trunk/demos/java-object-terms/date/today.java (rev 0)
+++ trunk/demos/java-object-terms/date/today.java 2009-01-06 14:56:38 UTC (rev 1427)
@@ -0,0 +1,38 @@
+// Internal action code for project ObjectTerm
+
+package date;
+
+import jason.asSemantics.*;
+import jason.asSyntax.*;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.logging.Logger;
+
+public class today extends DefaultInternalAction {
+
+ private Logger logger = Logger.getLogger("ObjectTerm."+today.class.getName());
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ // create the ObjectTerm (the argument is any java object)
+ Term t = new ObjectTermImpl(new NiceToStringForCalendar());
+
+ // unifies the new term with the arguments of the internal action
+ return un.unifies(args[0], t);
+ } catch (Exception e) {
+ logger.warning("Error in internal action 'date.today'! "+e);
+ }
+ return false;
+ }
+
+ // a class to printout dates
+ class NiceToStringForCalendar extends GregorianCalendar {
+ @Override
+ public String toString() {
+ return (get(Calendar.MONTH)+1) + "/" + get(Calendar.DAY_OF_MONTH) + "/" + get(Calendar.YEAR);
+ }
+ }
+
+}
Added: trunk/demos/java-object-terms/sample.asl
===================================================================
--- trunk/demos/java-object-terms/sample.asl (rev 0)
+++ trunk/demos/java-object-terms/sample.asl 2009-01-06 14:56:38 UTC (rev 1427)
@@ -0,0 +1,17 @@
+// Agent sample in project ObjectTerm
+
+/* Initial goals */
+
+!start.
+
+/* Plans */
+
++!start : true
+ <- date.today(T); // Create a term T that is a java Calendar object
+ // note that all operation on T should be done by
+ // internal actions
+ .print("Today=", T);
+ date.add_days(T,20,T2); // change the java object
+ .print("more 20 days=",T2);
+ +test(T). // to see the date in BB (and mind inspector)
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2009-01-15 16:39:12
|
Revision: 1429
http://jason.svn.sourceforge.net/jason/?rev=1429&view=rev
Author: jomifred
Date: 2009-01-15 16:39:02 +0000 (Thu, 15 Jan 2009)
Log Message:
-----------
update faq with new version of example using-only-jason-BDI
Modified Paths:
--------------
trunk/applications/jason-eclipse-plugin/build.xml
trunk/build.xml
trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java
trunk/doc/faq/faq.tex
Modified: trunk/applications/jason-eclipse-plugin/build.xml
===================================================================
--- trunk/applications/jason-eclipse-plugin/build.xml 2009-01-06 16:33:24 UTC (rev 1428)
+++ trunk/applications/jason-eclipse-plugin/build.xml 2009-01-15 16:39:02 UTC (rev 1429)
@@ -12,7 +12,7 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="2.0" />
+ <property name="release" value="2" />
<property name="distDir" value="${basedir}/dist" />
<property name="distDirPlugins" value="${distDir}/plugins" />
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2009-01-06 16:33:24 UTC (rev 1428)
+++ trunk/build.xml 2009-01-15 16:39:02 UTC (rev 1429)
@@ -15,7 +15,7 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="2.0" />
+ <property name="release" value="2" />
<property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
<property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
Modified: trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java
===================================================================
--- trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java 2009-01-06 16:33:24 UTC (rev 1428)
+++ trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java 2009-01-15 16:39:02 UTC (rev 1429)
@@ -87,8 +87,8 @@
@Override
public void sleep() {
try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {}
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {}
}
// Not used methods
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2009-01-06 16:33:24 UTC (rev 1428)
+++ trunk/doc/faq/faq.tex 2009-01-15 16:39:02 UTC (rev 1429)
@@ -579,7 +579,7 @@
\end{verbatim}
The following class implements the required architecture (the complete
-code is available with the examples in the \jason distribution). This
+code is available in the `demos' directory in the \jason distribution). This
code simply adds \code{x(10)} into the agent's belief base through
perception and get the output action, in this case \code{do(50)}.
@@ -597,10 +597,8 @@
// Semantics is implemented)
Agent ag = new Agent();
- setTS(ag.initAg(this,
- new DefaultBeliefBase(),
- "demo.asl", // source code
- new Settings()));
+ new TransitionSystem(ag, new Circumstance(), new Settings(), this);
+ ag.initAg("demo.asl"); // demo.asl is the file containing the code of the agent
}
public String getAgName() {
@@ -608,7 +606,7 @@
}
public void run() {
- while (true) {
+ while (isRunning()) {
// calls the Jason engine to perform one reasoning cycle
getTS().reasoningCycle();
}
@@ -629,6 +627,27 @@
action.setResult(true);
feedback.add(action);
}
+
+ public boolean canSleep() {
+ return true;
+ }
+
+ public boolean isRunning() {
+ return true;
+ }
+
+ public void sleep() {
+ try { Thread.sleep(1000); } catch (InterruptedException e) {}
+ }
+
+ public void sendMsg(jason.asSemantics.Message m) throws Exception {
+ }
+
+ public void broadcast(jason.asSemantics.Message m) throws Exception {
+ }
+
+ public void checkMail() {
+ }
}
\end{verbatim}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2009-01-23 07:41:10
|
Revision: 1430
http://jason.svn.sourceforge.net/jason/?rev=1430&view=rev
Author: jomifred
Date: 2009-01-23 07:41:05 +0000 (Fri, 23 Jan 2009)
Log Message:
-----------
add comments in RunCentMAS
Modified Paths:
--------------
trunk/release-notes.txt
trunk/src/jason/infra/centralised/RunCentralisedMAS.java
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2009-01-15 16:39:02 UTC (rev 1429)
+++ trunk/release-notes.txt 2009-01-23 07:41:05 UTC (rev 1430)
@@ -1,6 +1,8 @@
---------------------------
-version 1.2.0
+version 1.2
the 5th Anniversary Release
+
+revision 1428 on SVN
---------------------------
New features
Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java
===================================================================
--- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2009-01-15 16:39:02 UTC (rev 1429)
+++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2009-01-23 07:41:05 UTC (rev 1430)
@@ -418,6 +418,7 @@
}
}
+ /** creates on thread per agent */
private void createAgsThreads() {
for (CentralisedAgArch ag : ags.values()) {
ag.setControlInfraTier(control);
@@ -432,10 +433,14 @@
private BlockingQueue<Runnable> myAgTasks;
private BlockingQueue<Runnable> mySleepAgs;
+ /** creates a pool of threads shared by all agents */
private void createThreadPool() {
- myAgTasks = new LinkedBlockingQueue<Runnable>();
+ myAgTasks = new LinkedBlockingQueue<Runnable>();
mySleepAgs = new LinkedBlockingQueue<Runnable>();
+ // create a thread that
+ // 1. creates the pool
+ // 2. feeds the pool with agent reasoning cycles
new Thread("feed-pool") {
public void run() {
// initially, add all agents in the tasks
@@ -459,10 +464,16 @@
if (poolSize > maxthreads) {
poolSize = maxthreads;
}
+
+ // create the pool
ExecutorService executor = Executors.newFixedThreadPool(poolSize);
+
+ // include tasks in the pool
while (runner != null) {
try {
executor.execute(myAgTasks.take());
+ // note that the agent, when finished the cycle,
+ // add themselves in the myAgTasks queue
} catch (InterruptedException e) { }
}
executor.shutdownNow();
@@ -486,6 +497,7 @@
}.start();
}
+ /** an agent architecture for the infra based on thread pool */
private final class CentralisedAgArchForPool extends CentralisedAgArch {
boolean inSleep;
@@ -497,9 +509,8 @@
@Override
public void wake() {
- if (mySleepAgs.remove(this)) {
+ if (mySleepAgs.remove(this))
myAgTasks.offer(this);
- }
}
@Override
@@ -507,13 +518,14 @@
if (isRunning()) {
inSleep = false;
userAgArch.getTS().reasoningCycle();
- if (!inSleep) myAgTasks.offer(this);
+ if (!inSleep)
+ myAgTasks.offer(this);
}
}
}
protected void stopAgs() {
- // run the agents
+ // stop the agents
for (CentralisedAgArch ag : ags.values()) {
ag.stopAg();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2009-02-08 18:03:49
|
Revision: 1432
http://jason.svn.sourceforge.net/jason/?rev=1432&view=rev
Author: jomifred
Date: 2009-02-08 18:03:39 +0000 (Sun, 08 Feb 2009)
Log Message:
-----------
update rel notes
Modified Paths:
--------------
trunk/build.xml
trunk/release-notes.txt
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2009-02-08 17:58:02 UTC (rev 1431)
+++ trunk/build.xml 2009-02-08 18:03:39 UTC (rev 1432)
@@ -15,7 +15,7 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="2" />
+ <property name="release" value="2.1" />
<property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
<property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2009-02-08 17:58:02 UTC (rev 1431)
+++ trunk/release-notes.txt 2009-02-08 18:03:39 UTC (rev 1432)
@@ -1,4 +1,13 @@
---------------------------
+version 1.2.1
+---------------------------
+
+Bugs fixed
+- arithmetic expressions are considered as Literal, causing
+ failures in unification
+
+
+---------------------------
version 1.2
the 5th Anniversary Release
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2009-02-09 10:31:52
|
Revision: 1433
http://jason.svn.sourceforge.net/jason/?rev=1433&view=rev
Author: jomifred
Date: 2009-02-09 10:31:47 +0000 (Mon, 09 Feb 2009)
Log Message:
-----------
improve getting started exercise and comment solutions
Modified Paths:
--------------
trunk/applications/jason-moise/build.xml
trunk/applications/jason-moise/lib/moise.jar
trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java
trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl
trunk/src/jason/asSyntax/Literal.java
Added Paths:
-----------
trunk/doc/mini-tutorial/src/getting-started/exercise-answers.txt
Modified: trunk/applications/jason-moise/build.xml
===================================================================
--- trunk/applications/jason-moise/build.xml 2009-02-08 18:03:39 UTC (rev 1432)
+++ trunk/applications/jason-moise/build.xml 2009-02-09 10:31:47 UTC (rev 1433)
@@ -8,8 +8,8 @@
<property environment="env"/>
<property name="version" value="1"/>
- <property name="release" value="1.2"/>
- <property name="moiseDir" value="${env.HOME}/Moise/svn-moise" />
+ <property name="release" value="2"/>
+ <property name="moiseDir" value="${env.HOME}/svn-moise" />
<property name="distDir" value="${env.HOME}/tmp/jmoise-${version}.${release}" />
<property name="distFile" value="${env.HOME}/jason-moise-${version}.${release}" />
<property name="doc-src-dir" value="${env.HOME}/programming/Moise-doc" />
@@ -90,6 +90,7 @@
<fileset dir="${basedir}" includes="doc/api/**/*" />
<fileset dir="${basedir}" includes="lib/**/*" />
<fileset dir="${basedir}" includes="example/writePaper/**/*" />
+ <fileset dir="${basedir}" includes="example/moise-tutorial/**/*" />
<fileset dir="${basedir}" includes="example/auction/**/*" excludes="**/nbproject/**,**/profile-build.xml"/>
<fileset dir="${basedir}" includes="src/**/*" />
</copy>
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java 2009-02-08 18:03:39 UTC (rev 1432)
+++ trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java 2009-02-09 10:31:47 UTC (rev 1433)
@@ -21,12 +21,19 @@
private int vcx = 0; // the vacuum cleaner location
private int vcy = 0;
- private boolean running = true;
-
+ /** general delegations */
private HouseGUI gui = new HouseGUI();
+ private Logger logger = Logger.getLogger("env."+VCWorld.class.getName());
+ private Random r = new Random();
- private Logger logger = Logger.getLogger("env."+VCWorld.class.getName());
-
+ /** constant terms used for perception */
+ private static final Literal lPos1 = ASSyntax.createLiteral("pos", ASSyntax.createNumber(1));
+ private static final Literal lPos2 = ASSyntax.createLiteral("pos", ASSyntax.createNumber(2));
+ private static final Literal lPos3 = ASSyntax.createLiteral("pos", ASSyntax.createNumber(3));
+ private static final Literal lPos4 = ASSyntax.createLiteral("pos", ASSyntax.createNumber(4));
+ private static final Literal lDirty = ASSyntax.createLiteral("dirty");
+ private static final Literal lClean = ASSyntax.createLiteral("clean");
+
public VCWorld() {
createPercept();
gui.paint();
@@ -35,7 +42,7 @@
new Thread() {
public void run() {
try {
- while (running) {
+ while (isRunning()) {
// add ramdom dirty
if (r.nextInt(100) < 20) {
dirty[r.nextInt(2)][r.nextInt(2)] = true;
@@ -49,27 +56,25 @@
}.start();
}
- Random r = new Random();
-
/** create the agents perceptions based on the world model */
private void createPercept() {
// remove previous perception
clearPercepts();
if (vcx == 0 && vcy == 0) {
- addPercept(Literal.parseLiteral("pos(1)"));
+ addPercept(lPos1);
} else if (vcx == 1 && vcy == 0) {
- addPercept(Literal.parseLiteral("pos(2)"));
+ addPercept(lPos2);
} else if (vcx == 0 && vcy == 1) {
- addPercept(Literal.parseLiteral("pos(3)"));
+ addPercept(lPos3);
} else if (vcx == 1 && vcy == 1) {
- addPercept(Literal.parseLiteral("pos(4)"));
+ addPercept(lPos4);
}
if (dirty[vcx][vcy]) {
- addPercept(Literal.parseLiteral("dirty"));
+ addPercept(lDirty);
} else {
- addPercept(Literal.parseLiteral("clean"));
+ addPercept(lClean);
}
}
@@ -115,7 +120,6 @@
@Override
public void stop() {
- running = false;
super.stop();
gui.setVisible(false);
}
Modified: trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl 2009-02-08 18:03:39 UTC (rev 1432)
+++ trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl 2009-02-09 10:31:47 UTC (rev 1433)
@@ -15,4 +15,5 @@
// TODO: the code of the agent
-+dirty <- suck.
+
+
Added: trunk/doc/mini-tutorial/src/getting-started/exercise-answers.txt
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/exercise-answers.txt (rev 0)
+++ trunk/doc/mini-tutorial/src/getting-started/exercise-answers.txt 2009-02-09 10:31:47 UTC (rev 1433)
@@ -0,0 +1,104 @@
+There are several solutions for the vacuum cleaner. Here we present and
+comment some of them. We start from a very reactive solution and finish
+by a goal-oriented version.
+
+
+
+1. First solution
+
+----------------------------------------
++dirty <- suck.
+
++pos(1) <- right.
++pos(2) <- down.
++pos(3) <- up.
++pos(4) <- left.
+----------------------------------------
+
+* comments
+- reactive agent
+- selection of plans do not use context (beliefs),
+ but only events
+
+* problems
+- may leave dirty behind, you will get messages like
+ [VCWorld] suck in a clean location!
+- reason: the selection of the intention to move ("+pos(...)" plans) are
+ selected before the plan to clean the location
+
+
+2. Second solution
+
+----------------------------------------
++pos(1) : clean <- right.
++pos(2) : clean <- down.
++pos(3) : clean <- up.
++pos(4) : clean <- left.
+
++pos(1) : dirty <- suck; right.
++pos(2) : dirty <- suck; down.
++pos(3) : dirty <- suck; up.
++pos(4) : dirty <- suck; left.
+----------------------------------------
+
+* comments
+- reactive agent
+- selection of plans based on context (perceptual beliefs)
+- solve the problem of first solution
+
+* problems
+- the moving strategy is code in two sets of plans, so to change
+ the strategy we need to recode twice.
+
+
+3. Third solution
+
+----------------------------------------
++pos(_) : clean <- !move.
++pos(_) : dirty <- suck; !move.
+
++!move : pos(1) <- right.
++!move : pos(2) <- down.
++!move : pos(3) <- up.
++!move : pos(4) <- left.
+----------------------------------------
+
+* comments
+- the moving strategy is re-factored in a goal (the goal !move)
+- this agent is still a reactive one (it reacts to the perception of its
+ location), but the reaction creates a new goal (to move)
+- the change the moving strategy we only need to change the
+ way the goal "move" is achieved
+
+* problem
+- suppose that the actions may fail, in this case, to perform 'up', for
+ example, may leave the agent in the same place, so no new location is
+ perceived and the agent will stop moving.
+ (it is an hypothetical case since the environment was not code to
+ simulate action failures)
+
+
+4. Fourth solution
+
+----------------------------------------
+!clean. // initial goal
+
++!clean : clean <- !move; !!clean.
++!clean : dirty <- suck; !move; !!clean.
+-!clean <- !!clean.
+
++!move : pos(1) <- right.
++!move : pos(2) <- down.
++!move : pos(3) <- up.
++!move : pos(4) <- left.
+----------------------------------------
+
+* comments
+- this agent is not reactive anymore, it has a persistent goal (!clean).
+- this goal is implemented by a kind of 'loop', all plans to achieve
+ 'clean' finish by adding 'clean' as a new goal.
+- if something fails to achieve 'clean', the failure handling plan
+ (-!clean) reintroduces the goal again.
+- !! is used instead of ! to avoid big stacks of sub-goals, see
+ http://jason.sourceforge.net/faq/faq.html#SECTION00075000000000000000
+- this agent is thus more 'robust' against action failures
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2009-02-08 18:03:39 UTC (rev 1432)
+++ trunk/src/jason/asSyntax/Literal.java 2009-02-09 10:31:47 UTC (rev 1433)
@@ -37,14 +37,17 @@
import java.util.logging.Logger;
/**
- This class represents an abstract literal (an Atom, Structure, Predicate, etc), is is mainly
+ This class represents an abstract literal (an Atom, Structure, Predicate, etc), it is mainly
the interface of a literal.
- To create a Literal, one of the following classes may be used:
- Atom -- the most simple literal, is composed by a functor (no term, no annots);
- Structure -- has functor and terms;
- Pred -- has functor, terms, and annotations;
- LiteralImpl -- Pred + negation. This latter class supports all the operations of
+ To create a new Literal, one of the following concrete classes may be used:
+ <ul>
+ <li> Atom -- the most simple literal, is composed by only a functor (no term, no annots);
+ <li> Structure -- has functor and terms;
+ <li> Pred -- has functor, terms, and annotations;
+ <li> LiteralImpl -- Pred + negation.
+ </ul>
+ The latter class supports all the operations of
the Literal interface.
<p>There are useful static methods in class {@link ASSyntax} to create Literals.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2009-02-10 12:40:22
|
Revision: 1435
http://jason.svn.sourceforge.net/jason/?rev=1435&view=rev
Author: jomifred
Date: 2009-02-10 12:40:18 +0000 (Tue, 10 Feb 2009)
Log Message:
-----------
fix some typos in domestic-robot example (thanks to J?\195?\131?\194?\184rgen)
Modified Paths:
--------------
trunk/doc/mini-tutorial/src/getting-started/getting-started.tex
trunk/examples/domestic-robot/HouseEnv.java
trunk/examples/domestic-robot/HouseModel.java
trunk/examples/domestic-robot/HouseView.java
trunk/examples/domestic-robot/supermarket.asl
Modified: trunk/doc/mini-tutorial/src/getting-started/getting-started.tex
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/getting-started.tex 2009-02-09 13:46:21 UTC (rev 1434)
+++ trunk/doc/mini-tutorial/src/getting-started/getting-started.tex 2009-02-10 12:40:18 UTC (rev 1435)
@@ -66,7 +66,7 @@
\Jason comes with many examples and demos. The examples are
multi-agent system applications for simple scenarios. The demos are
meant simply to show how to use some useful features of \Jason. You
-can find a brief description of examles and demos at
+can find a brief description of examples and demos at
\url{http://jason.sf.net}.
We will now run the classic \emph{Cleaning Robots} example:
Modified: trunk/examples/domestic-robot/HouseEnv.java
===================================================================
--- trunk/examples/domestic-robot/HouseEnv.java 2009-02-09 13:46:21 UTC (rev 1434)
+++ trunk/examples/domestic-robot/HouseEnv.java 2009-02-10 12:40:18 UTC (rev 1435)
@@ -6,17 +6,17 @@
public class HouseEnv extends Environment {
// common literals
- public static final Literal of = Literal.parseLiteral("open(fridge)");
+ public static final Literal of = Literal.parseLiteral("open(fridge)");
public static final Literal clf = Literal.parseLiteral("close(fridge)");
- public static final Literal gb = Literal.parseLiteral("get(beer)");
- public static final Literal hb = Literal.parseLiteral("hand_in(beer)");
- public static final Literal sb = Literal.parseLiteral("sip(beer)");
- public static final Literal hob = Literal.parseLiteral("has(owner,beer)");
+ public static final Literal gb = Literal.parseLiteral("get(beer)");
+ public static final Literal hb = Literal.parseLiteral("hand_in(beer)");
+ public static final Literal sb = Literal.parseLiteral("sip(beer)");
+ public static final Literal hob = Literal.parseLiteral("has(owner,beer)");
- public static final Literal af = Literal.parseLiteral("at(robot,fridge)");
- public static final Literal ao = Literal.parseLiteral("at(robot,owner)");
-
- static Logger logger = Logger.getLogger(HouseEnv.class.getName());
+ public static final Literal af = Literal.parseLiteral("at(robot,fridge)");
+ public static final Literal ao = Literal.parseLiteral("at(robot,owner)");
+
+ static Logger logger = Logger.getLogger(HouseEnv.class.getName());
HouseModel model; // the model of the grid
@@ -31,7 +31,7 @@
updatePercepts();
}
-
+
/** creates the agents percepts based on the HouseModel */
void updatePercepts() {
// clear the percepts of the agents
@@ -49,7 +49,7 @@
addPercept("robot", ao);
}
- // add beer "status" to perception
+ // add beer "status" the percepts
if (model.fridgeOpen) {
addPercept("robot", Literal.parseLiteral("stock(beer,"+model.availableBeers+")"));
}
@@ -61,56 +61,56 @@
@Override
- public boolean executeAction(String ag, Structure action) {
- System.out.println("["+ag+"] doing: "+action);
+ public boolean executeAction(String ag, Structure action) {
+ System.out.println("["+ag+"] doing: "+action);
boolean result = false;
- if (action.equals(of)) { // of = open(fridge)
+ if (action.equals(of)) { // of = open(fridge)
result = model.openFridge();
} else if (action.equals(clf)) { // clf = close(fridge)
result = model.closeFridge();
- } else if (action.getFunctor().equals("move_towards")) {
- String l = action.getTerm(0).toString();
+ } else if (action.getFunctor().equals("move_towards")) {
+ String l = action.getTerm(0).toString();
Location dest = null;
- if (l.equals("fridge")) {
- dest = model.lFridge;
- } else if (l.equals("owner")) {
+ if (l.equals("fridge")) {
+ dest = model.lFridge;
+ } else if (l.equals("owner")) {
dest = model.lOwner;
- }
+ }
- try {
- result = model.moveTowards(dest);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- } else if (action.equals(gb)) {
+ try {
+ result = model.moveTowards(dest);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ } else if (action.equals(gb)) {
result = model.getBeer();
- } else if (action.equals(hb)) {
+ } else if (action.equals(hb)) {
result = model.handInBeer();
- } else if (action.equals(sb)) {
+ } else if (action.equals(sb)) {
result = model.sipBeer();
- } else if (action.getFunctor().equals("deliver")) {
- // wait 4 seconds to finish "deliver"
- try {
- Thread.sleep(4000);
+ } else if (action.getFunctor().equals("deliver")) {
+ // wait 4 seconds to finish "deliver"
+ try {
+ Thread.sleep(4000);
result = model.addBeer( (int)((NumberTerm)action.getTerm(1)).solve());
} catch (Exception e) {
logger.info("Failed to execute action deliver!"+e);
}
- } else {
- logger.info("Failed to execute action "+action);
+ } else {
+ logger.info("Failed to execute action "+action);
}
if (result) {
updatePercepts();
try { Thread.sleep(100); } catch (Exception e) {}
}
- return result;
- }
+ return result;
+ }
}
Modified: trunk/examples/domestic-robot/HouseModel.java
===================================================================
--- trunk/examples/domestic-robot/HouseModel.java 2009-02-09 13:46:21 UTC (rev 1434)
+++ trunk/examples/domestic-robot/HouseModel.java 2009-02-10 12:40:18 UTC (rev 1435)
@@ -13,8 +13,8 @@
boolean fridgeOpen = false; // whether the fridge is open
boolean carryingBeer = false; // whether the robot is carrying beer
- int sipCount = 0; // how many sip the owner did
- int availableBeers = 2; // how many beers are available
+ int sipCount = 0; // how many sip the owner did
+ int availableBeers = 2; // how many beers are available
Location lFridge = new Location(0,0);
Location lOwner = new Location(GSize-1,GSize-1);
@@ -47,7 +47,7 @@
return true;
} else {
return false;
- }
+ }
}
boolean moveTowards(Location dest) {
@@ -57,10 +57,10 @@
if (r1.y < dest.y) r1.y++;
else if (r1.y > dest.y) r1.y--;
setAgPos(0, r1); // move the robot in the grid
-
- // repaint the fridge and owner locations
- view.update(lFridge.x,lFridge.y);
- view.update(lOwner.x,lOwner.y);
+
+ // repaint the fridge and owner locations
+ view.update(lFridge.x,lFridge.y);
+ view.update(lOwner.x,lOwner.y);
return true;
}
@@ -68,7 +68,7 @@
if (fridgeOpen && availableBeers > 0 && !carryingBeer) {
availableBeers--;
carryingBeer = true;
- view.update(lFridge.x,lFridge.y);
+ view.update(lFridge.x,lFridge.y);
return true;
} else {
return false;
@@ -77,7 +77,7 @@
boolean addBeer(int n) {
availableBeers += n;
- view.update(lFridge.x,lFridge.y);
+ view.update(lFridge.x,lFridge.y);
return true;
}
@@ -85,7 +85,7 @@
if (carryingBeer) {
sipCount = 10;
carryingBeer = false;
- view.update(lOwner.x,lOwner.y);
+ view.update(lOwner.x,lOwner.y);
return true;
} else {
return false;
@@ -95,7 +95,7 @@
boolean sipBeer() {
if (sipCount > 0) {
sipCount--;
- view.update(lOwner.x,lOwner.y);
+ view.update(lOwner.x,lOwner.y);
return true;
} else {
return false;
Modified: trunk/examples/domestic-robot/HouseView.java
===================================================================
--- trunk/examples/domestic-robot/HouseView.java 2009-02-09 13:46:21 UTC (rev 1434)
+++ trunk/examples/domestic-robot/HouseView.java 2009-02-10 12:40:18 UTC (rev 1435)
@@ -8,11 +8,11 @@
/** class that implements the View of Domestic Robot application */
public class HouseView extends GridWorldView {
- HouseModel hmodel;
-
+ HouseModel hmodel;
+
public HouseView(HouseModel model) {
super(model, "Domestic Robot", 700);
- hmodel = model;
+ hmodel = model;
defaultFont = new Font("Arial", Font.BOLD, 16); // change default font
setVisible(true);
repaint();
@@ -21,39 +21,39 @@
/** draw application objects */
@Override
public void draw(Graphics g, int x, int y, int object) {
- Location lRobot = hmodel.getAgPos(0);
- super.drawAgent(g, x, y, Color.lightGray, -1);
+ Location lRobot = hmodel.getAgPos(0);
+ super.drawAgent(g, x, y, Color.lightGray, -1);
switch (object) {
case HouseModel.FRIDGE:
- if (lRobot.equals(hmodel.lFridge)) {
- super.drawAgent(g, x, y, Color.yellow, -1);
- }
- g.setColor(Color.black);
- drawString(g, x, y, defaultFont, "Fridge ("+hmodel.availableBeers+")");
- break;
+ if (lRobot.equals(hmodel.lFridge)) {
+ super.drawAgent(g, x, y, Color.yellow, -1);
+ }
+ g.setColor(Color.black);
+ drawString(g, x, y, defaultFont, "Fridge ("+hmodel.availableBeers+")");
+ break;
case HouseModel.OWNER:
- if (lRobot.equals(hmodel.lOwner)) {
- super.drawAgent(g, x, y, Color.yellow, -1);
- }
- String o = "Owner";
- if (hmodel.sipCount > 0) {
- o += " ("+hmodel.sipCount+")";
- }
- g.setColor(Color.black);
- drawString(g, x, y, defaultFont, o);
- break;
+ if (lRobot.equals(hmodel.lOwner)) {
+ super.drawAgent(g, x, y, Color.yellow, -1);
+ }
+ String o = "Owner";
+ if (hmodel.sipCount > 0) {
+ o += " ("+hmodel.sipCount+")";
+ }
+ g.setColor(Color.black);
+ drawString(g, x, y, defaultFont, o);
+ break;
}
}
@Override
public void drawAgent(Graphics g, int x, int y, Color c, int id) {
- Location lRobot = hmodel.getAgPos(0);
+ Location lRobot = hmodel.getAgPos(0);
if (!lRobot.equals(hmodel.lOwner) && !lRobot.equals(hmodel.lFridge)) {
c = Color.yellow;
if (hmodel.carryingBeer) c = Color.orange;
- super.drawAgent(g, x, y, c, -1);
- g.setColor(Color.black);
- super.drawString(g, x, y, defaultFont, "Robot");
- }
+ super.drawAgent(g, x, y, c, -1);
+ g.setColor(Color.black);
+ super.drawString(g, x, y, defaultFont, "Robot");
+ }
}
}
Modified: trunk/examples/domestic-robot/supermarket.asl
===================================================================
--- trunk/examples/domestic-robot/supermarket.asl 2009-02-09 13:46:21 UTC (rev 1434)
+++ trunk/examples/domestic-robot/supermarket.asl 2009-02-10 12:40:18 UTC (rev 1435)
@@ -1,6 +1,6 @@
last_order_id(1). // initial belief
-// plan to achieve the the goal "order" for agent Ag
+// plan to achieve the goal "order" for agent Ag
+!order(Product,Qtd)[source(Ag)] : true
<- ?last_order_id(N);
OrderId = N + 1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2009-02-11 21:21:45
|
Revision: 1437
http://jason.svn.sourceforge.net/jason/?rev=1437&view=rev
Author: jomifred
Date: 2009-02-11 21:21:39 +0000 (Wed, 11 Feb 2009)
Log Message:
-----------
fix a small problem in the VC example
Modified Paths:
--------------
trunk/demos/communication/bob.asl
trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java
trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl
trunk/examples/domestic-robot/robot.asl
Modified: trunk/demos/communication/bob.asl
===================================================================
--- trunk/demos/communication/bob.asl 2009-02-11 10:05:46 UTC (rev 1436)
+++ trunk/demos/communication/bob.asl 2009-02-11 21:21:39 UTC (rev 1437)
@@ -15,7 +15,7 @@
.println("Sending assynchronous ask ");
.send(maria, askOne, vl(_)); // assync ask has no fourth argument
- // the answer is received as an event +vl(X)
+ // the answer is received as an event +vl(X)
.println("Sending ask for something Maria does not know, but can handle by +? ");
.send(maria, askOne, t2(_), Ans2);
@@ -37,10 +37,10 @@
.send(maria, askOne, fullname, FN);
.println("Full name is ",FN);
- // Send to maria a plan to achieve the goal hello
- .plan_label(Plan,hp); // get a plans based on a plan's label
- .println("Sending tell how: ",Plan);
- .send(maria,tellHow,Plan);
+ // Send to maria a plan to achieve the goal hello
+ .plan_label(Plan,hp); // get a plans based on a plan's label
+ .println("Sending tell how: ",Plan);
+ .send(maria,tellHow,Plan);
.println("Asking Maria to achieve 'hello'");
.send(maria,achieve, hello(bob));
@@ -49,8 +49,8 @@
.println("Asking Maria to unachieve 'hello'");
.send(maria,unachieve, hello(bob));
- // send untell how to maria
- .send(maria,untellHow,hp).
+ // send untell how to maria
+ .send(maria,untellHow,hp).
+vl(X)[source(A)]
Modified: trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java 2009-02-11 10:05:46 UTC (rev 1436)
+++ trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/VCWorld.java 2009-02-11 21:21:39 UTC (rev 1437)
@@ -61,6 +61,12 @@
// remove previous perception
clearPercepts();
+ if (dirty[vcx][vcy]) {
+ addPercept(lDirty);
+ } else {
+ addPercept(lClean);
+ }
+
if (vcx == 0 && vcy == 0) {
addPercept(lPos1);
} else if (vcx == 1 && vcy == 0) {
@@ -70,19 +76,15 @@
} else if (vcx == 1 && vcy == 1) {
addPercept(lPos4);
}
-
- if (dirty[vcx][vcy]) {
- addPercept(lDirty);
- } else {
- addPercept(lClean);
- }
}
@Override
public boolean executeAction(String ag, Structure action) {
- try { Thread.sleep(500);} catch (Exception e) {} //show down the execution
+ logger.info("doing "+action);
+ try { Thread.sleep(500);} catch (Exception e) {} // slow down the execution
+
// Change the world model based on action
if (action.getFunctor().equals("suck")) {
if (dirty[vcx][vcy]) {
Modified: trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl 2009-02-11 10:05:46 UTC (rev 1436)
+++ trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl 2009-02-11 21:21:39 UTC (rev 1437)
@@ -15,4 +15,3 @@
// TODO: the code of the agent
-
Modified: trunk/examples/domestic-robot/robot.asl
===================================================================
--- trunk/examples/domestic-robot/robot.asl 2009-02-11 10:05:46 UTC (rev 1436)
+++ trunk/examples/domestic-robot/robot.asl 2009-02-11 21:21:39 UTC (rev 1437)
@@ -1,6 +1,6 @@
/* Initial beliefs and rules */
-// initially, I believe that there are some beer in the fridge
+// initially, I believe that there is some beer in the fridge
available(beer,fridge).
// my owner should not consume more than 10 beers a day :-)
@@ -24,7 +24,7 @@
!at(robot,owner);
hand_in(beer);
?has(owner,beer);
- // remember that one beer is consumed
+ // remember that another beer has been consumed
.date(YY,MM,DD); .time(HH,NN,SS);
+consumed(YY,MM,DD,HH,NN,SS,beer).
@@ -50,7 +50,7 @@
<- move_towards(P);
!at(robot,P).
-// when the supermarket finished the order, try the 'has' goal again
+// when the supermarket makes a delivery, try the 'has' goal again
+delivered(beer,_Qtd,_OrderId)[source(supermarket)]
: true
<- +available(beer,fridge);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2009-02-13 13:07:53
|
Revision: 1442
http://jason.svn.sourceforge.net/jason/?rev=1442&view=rev
Author: jomifred
Date: 2009-02-13 13:07:48 +0000 (Fri, 13 Feb 2009)
Log Message:
-----------
allows the agent's name in .create_agent to be a string
Modified Paths:
--------------
trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl
trunk/src/jason/stdlib/create_agent.java
Modified: trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl
===================================================================
--- trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl 2009-02-13 11:29:23 UTC (rev 1441)
+++ trunk/doc/mini-tutorial/src/getting-started/VacuumCleaning-1/vc.asl 2009-02-13 13:07:48 UTC (rev 1442)
@@ -1,7 +1,7 @@
/*
-Very simple vaccum cleaner agent in a world that has only four locations.
+Very simple vacuum cleaner agent in a world that has only four locations.
Perceptions:
. dirty: the current location has dirty
@@ -15,5 +15,3 @@
*/
// TODO: the code of the agent
-
-
Modified: trunk/src/jason/stdlib/create_agent.java
===================================================================
--- trunk/src/jason/stdlib/create_agent.java 2009-02-13 11:29:23 UTC (rev 1441)
+++ trunk/src/jason/stdlib/create_agent.java 2009-02-13 13:07:48 UTC (rev 1442)
@@ -97,7 +97,12 @@
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
checkArguments(args);
- Term name = args[0];
+ String name;
+ if (args[0].isString())
+ name = ((StringTerm)args[0]).getString();
+ else
+ name = args[0].toString();
+
StringTerm source = (StringTerm)args[1];
File fSource = new File(source.getString());
@@ -126,7 +131,7 @@
}
RuntimeServicesInfraTier rs = ts.getUserAgArch().getArchInfraTier().getRuntimeServices();
- return rs.createAgent(name.toString(), fSource.getAbsolutePath(), agClass, agArchClass, bbPars, ts.getSettings());
+ return rs.createAgent(name, fSource.getAbsolutePath(), agClass, agArchClass, bbPars, ts.getSettings());
}
private Structure testString(Term t) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|