From: <jom...@us...> - 2015-11-02 11:10:36
|
Revision: 1851 http://sourceforge.net/p/jason/svn/1851 Author: jomifred Date: 2015-11-02 11:10:34 +0000 (Mon, 02 Nov 2015) Log Message: ----------- add constants in settings Modified Paths: -------------- trunk/doc/mini-tutorial/src/hello-bdi/index.html trunk/doc/mini-tutorial/src/hello-bdi/index.org trunk/src/jason/architecture/MindInspectorAgArch.java trunk/src/jason/architecture/MindInspectorWeb.java trunk/src/jason/asSemantics/Agent.java trunk/src/jason/infra/centralised/CentralisedAgArch.java trunk/src/jason/mas2j/AgentParameters.java trunk/src/jason/runtime/Settings.java trunk/src/jason/stdlib/create_agent.java Modified: trunk/doc/mini-tutorial/src/hello-bdi/index.html =================================================================== (Binary files differ) Modified: trunk/doc/mini-tutorial/src/hello-bdi/index.org =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/index.org 2015-10-28 11:07:45 UTC (rev 1850) +++ trunk/doc/mini-tutorial/src/hello-bdi/index.org 2015-11-02 11:10:34 UTC (rev 1851) @@ -94,7 +94,7 @@ The /tell/ message that Alice sent to Bob is automatically interpreted by Jason. The default interpretation, since it is a "tell" message, is to include the content of the message (=happy(bob)=) in the Bob's belief base. When that belief is added in the belief base, the event =+happy(bob)= is included in the queue of events. Bob then reacts to this event creating an intention. You can access the [[http://localhost:3272][Jason Mind Inspector]] to see the Bob's mental state (or use the Debug button in the MAS Console): -#+ATTR_HTML: width=500 style="center;margin:0px 20px 20px 20px;" +#+ATTR_HTML: :width 500 [[./screens/mind-1.png]] As we can see, the belief is not exactly =happy(bob)= but =happy(bob)[source(alice)]=. The part enclosed by =[= and =]= are annotations. All beliefs in Jason have annotations for their sources. This information can be used, for instance, if an agent needs to consider only those beliefs that come from trustable sources: @@ -183,7 +183,7 @@ It is important to notice how many intentions Bob has: -#+ATTR_HTML: width=500 style="center;margin:0px 20px 20px 20px;" +#+ATTR_HTML: :width 500 [[./screens/mind-2.png]] Bob is concurrently executing three intentions: one for each Modified: trunk/src/jason/architecture/MindInspectorAgArch.java =================================================================== --- trunk/src/jason/architecture/MindInspectorAgArch.java 2015-10-28 11:07:45 UTC (rev 1850) +++ trunk/src/jason/architecture/MindInspectorAgArch.java 2015-11-02 11:10:34 UTC (rev 1851) @@ -28,6 +28,7 @@ import jason.asSyntax.Structure; import jason.control.ExecutionControlGUI; import jason.jeditplugin.Config; +import jason.runtime.Settings; import jason.util.asl2html; import jason.util.asl2xml; @@ -90,7 +91,7 @@ @Override public void init() { - setupMindInspector(getTS().getSettings().getUserParameter("mindinspector")); + setupMindInspector(getTS().getSettings().getUserParameter(Settings.MIND_INSPECTOR)); } /** Modified: trunk/src/jason/architecture/MindInspectorWeb.java =================================================================== --- trunk/src/jason/architecture/MindInspectorWeb.java 2015-10-28 11:07:45 UTC (rev 1850) +++ trunk/src/jason/architecture/MindInspectorWeb.java 2015-11-02 11:10:34 UTC (rev 1851) @@ -2,6 +2,7 @@ import jason.asSemantics.Agent; import jason.jeditplugin.Config; +import jason.runtime.Settings; import jason.util.asl2html; import jason.util.asl2xml; @@ -139,7 +140,7 @@ AgArch arch = ag.getTS().getUserAgArch(); if (arch != null) { // should add a new conf for mindinspector, otherwise will start a new gui for the agent - arch.getTS().getSettings().addOption("mindinspector","web(cycle,html,no_history)"); + arch.getTS().getSettings().addOption(Settings.MIND_INSPECTOR,"web(cycle,html,no_history)"); MindInspectorAgArch miArch = new MindInspectorAgArch(); arch.insertAgArch(miArch); miArch.init(); Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2015-10-28 11:07:45 UTC (rev 1850) +++ trunk/src/jason/asSemantics/Agent.java 2015-11-02 11:10:34 UTC (rev 1851) @@ -546,7 +546,7 @@ } protected void addInitialBelsFromProjectInBB() { - String sBels = getTS().getSettings().getUserParameter("beliefs"); + String sBels = getTS().getSettings().getUserParameter(Settings.INIT_BELS); if (sBels != null) { try { for (Term t: ASSyntax.parseList("["+sBels+"]")) { @@ -579,7 +579,7 @@ } protected void addInitialGoalsFromProjectInBB() { - String sGoals = getTS().getSettings().getUserParameter("goals"); + String sGoals = getTS().getSettings().getUserParameter(Settings.INIT_GOALS); if (sGoals != null) { try { for (Term t: ASSyntax.parseList("["+sGoals+"]")) { Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2015-10-28 11:07:45 UTC (rev 1850) +++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2015-11-02 11:10:34 UTC (rev 1851) @@ -95,7 +95,7 @@ createCustomArchs(agArchClasses); // mind inspector arch - if (stts.getUserParameter("mindinspector") != null) { + if (stts.getUserParameter(Settings.MIND_INSPECTOR) != null) { insertAgArch(new MindInspectorAgArch()); getFirstAgArch().init(); } Modified: trunk/src/jason/mas2j/AgentParameters.java =================================================================== --- trunk/src/jason/mas2j/AgentParameters.java 2015-10-28 11:07:45 UTC (rev 1850) +++ trunk/src/jason/mas2j/AgentParameters.java 2015-11-02 11:10:34 UTC (rev 1851) @@ -218,7 +218,7 @@ if (forceSync || debug) { stts.setSync(true); } - stts.addOption("project-parameter", this); // place of copy of this object anyway + stts.addOption(Settings.PROJECT_PARAMETER, this); // place of copy of this object anyway return stts; } Modified: trunk/src/jason/runtime/Settings.java =================================================================== --- trunk/src/jason/runtime/Settings.java 2015-10-28 11:07:45 UTC (rev 1850) +++ trunk/src/jason/runtime/Settings.java 2015-11-02 11:10:34 UTC (rev 1851) @@ -56,6 +56,10 @@ private Map<String,Object> userParameters = new HashMap<String,Object>(); + public static final String PROJECT_PARAMETER = "project-parameter"; + public static final String INIT_BELS = "beliefs"; + public static final String INIT_GOALS = "goals"; + public static final String MIND_INSPECTOR = "mindinspector"; public Settings() { } @@ -227,6 +231,7 @@ public Map<String,Object> getUserParameters() { return userParameters; } + public String getUserParameter(String key) { String vl = (String)userParameters.get(key); if (vl != null && vl.startsWith("\"") && vl.endsWith("\"")) { @@ -235,4 +240,9 @@ } return vl; } + + public Object removeUserParameter(String key) { + return userParameters.remove(key); + } + } Modified: trunk/src/jason/stdlib/create_agent.java =================================================================== --- trunk/src/jason/stdlib/create_agent.java 2015-10-28 11:07:45 UTC (rev 1850) +++ trunk/src/jason/stdlib/create_agent.java 2015-11-02 11:10:34 UTC (rev 1851) @@ -34,6 +34,7 @@ import jason.asSyntax.Term; import jason.mas2j.ClassParameters; import jason.runtime.RuntimeServicesInfraTier; +import jason.runtime.Settings; import java.io.File; import java.util.ArrayList; @@ -129,7 +130,7 @@ } } RuntimeServicesInfraTier rs = ts.getUserAgArch().getRuntimeServices(); - name = rs.createAgent(name, source, agClass, agArchClasses, bbPars, ts.getSettings()); + name = rs.createAgent(name, source, agClass, agArchClasses, bbPars, getSettings(ts)); rs.startAgent(name); if (args[0].isVar()) @@ -138,6 +139,14 @@ return true; } + protected Settings getSettings(TransitionSystem ts) { + /*Settings s = ts.getSettings(); + s.removeUserParameter(Settings.INIT_BELS); + s.removeUserParameter(Settings.INIT_GOALS); + return s;*/ + return new Settings(); + } + protected String getName(Term[] args) { String name; if (args[0].isString()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |