From: <jom...@us...> - 2008-09-12 16:45:25
|
Revision: 1368 http://jason.svn.sourceforge.net/jason/?rev=1368&view=rev Author: jomifred Date: 2008-09-12 16:45:23 +0000 (Fri, 12 Sep 2008) Log Message: ----------- add an initAg method in Agent class so that the class remains compatible with previous releases Modified Paths: -------------- trunk/applications/jason-team/src/team-os.xml trunk/src/jason/asSemantics/Agent.java Modified: trunk/applications/jason-team/src/team-os.xml =================================================================== --- trunk/applications/jason-team/src/team-os.xml 2008-09-12 15:04:23 UTC (rev 1367) +++ trunk/applications/jason-team/src/team-os.xml 2008-09-12 16:45:23 UTC (rev 1368) @@ -105,8 +105,7 @@ <goal id="herd_cows" > <plan operator="parallel"> <goal id="recruit" ds="recruit more herdboys depending on the size of the cows cluster" type="maintenance"/> - <goal id="release_boys" ds="if the group has - too much boys, release some" type="maintenance"/> + <goal id="release_boys" ds="if the group has too much boys, release some" type="maintenance"/> <goal id="define_formation" ds="compute the ideal location of each member of the group and share this information with them" type="maintenance"/> <goal id="be_in_formation" ds="go to the place allocated to the agent in the formation" type="maintenance"/> <goal id="share_seen_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/> Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2008-09-12 15:04:23 UTC (rev 1367) +++ trunk/src/jason/asSemantics/Agent.java 2008-09-12 16:45:23 UTC (rev 1368) @@ -42,6 +42,7 @@ import jason.bb.DefaultBeliefBase; import jason.functions.Count; import jason.functions.RuleToFunction; +import jason.runtime.Settings; import java.io.File; import java.io.FileInputStream; @@ -103,7 +104,7 @@ } /** parse and load the agent code, asSrc may be null */ - public TransitionSystem initAg(String asSrc) throws JasonException { + public void initAg(String asSrc) throws JasonException { // set the agent try { initDefaultFunctions(); @@ -139,14 +140,38 @@ } else { 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); + } + } + + /** @deprecated Prefer the initAg method with only the source code of the agent as parameter. + * + * A call of this method like + * <pre> + * TransitionSystem ts = ag.initAg(arch, bb, asSrc, stts) + * </pre> + * can be replaced by + * <pre> + * new TransitionSystem(ag, new Circumstance(), stts, arch); + * ag.setBB(bb); // only if you use a custom BB + * ag.initAg(asSrc); + * TransitionSystem ts = ag.getTS(); + * </pre> + */ + public TransitionSystem initAg(AgArch arch, BeliefBase bb, String asSrc, Settings stts) throws JasonException { + try { + if (bb != null) setBB(bb); + new TransitionSystem(this, new Circumstance(), stts, arch); + initAg(asSrc); return ts; } catch (Exception e) { logger.log(Level.SEVERE, "Error creating the agent class!", e); throw new JasonException("Error creating the agent class! - " + e); } } - + public void stopAg() { bb.stop(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |