From: <jom...@us...> - 2008-09-13 19:09:25
|
Revision: 1370 http://jason.svn.sourceforge.net/jason/?rev=1370&view=rev Author: jomifred Date: 2008-09-13 19:09:17 +0000 (Sat, 13 Sep 2008) Log Message: ----------- first implementation of annotation errors see release notes for more info Modified Paths: -------------- trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java trunk/demos/failure/a.asl trunk/release-notes.txt trunk/src/jason/JasonException.java trunk/src/jason/asSemantics/Agent.java trunk/src/jason/asSemantics/IntendedMeans.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/asSyntax/Literal.java trunk/src/jason/asSyntax/Plan.java trunk/src/jason/asSyntax/Rule.java trunk/src/jason/asSyntax/Trigger.java trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc trunk/src/jason/asSyntax/parser/as2j.java trunk/src/jason/asSyntax/patterns/goal/DG.java trunk/src/jason/asSyntax/patterns/goal/EBDG.java trunk/src/jason/asSyntax/patterns/goal/MG.java trunk/src/jason/bb/DefaultBeliefBase.java trunk/src/jason/stdlib/abolish.java trunk/src/templates/ia Modified: trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java =================================================================== --- trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -23,10 +23,10 @@ "+!g3(X) : true <- inig2; !g4(X); endg3. "+ "+!g4(X) : true <- inig4; !g5(X); endg4. "+ "+!g5(_) : true <- .fail. "+ - "-!g3(failure) : true <- infailg3. "+ + "-!g3(failure)[error(ia_failed)] : true <- infailg3. "+ "+!norel <- !j; endnorel. "+ - "-!j <- infailj. " + "-!j[error(no_relevant)] <- infailj. " ); } Modified: trunk/demos/failure/a.asl =================================================================== --- trunk/demos/failure/a.asl 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/demos/failure/a.asl 2008-09-13 19:09:17 UTC (rev 1370) @@ -6,9 +6,10 @@ +!g3(X) : true <- .print(inig3); !g4(X); .print(endg3). +!g4(X) : true <- .print(inig4); !g5(X); .print(endg4). +!g5(_) : true <- .fail. --!g3(failure) : true - <- .current_intention(I); - .print("In failure handling plan, current intention is: ",I); +-!g3(failure)[error(ErrorId), error_msg(Msg), code(CodeBody), code_src(CodeSrc), code_line(CodeLine)] : true // get annotations related to the failure (these annotations are optional) + <- .print("Error ", ErrorId, " '",Msg,"' by ",CodeBody," in ",CodeSrc,":",CodeLine); + .current_intention(I); + .print("current intention is: ",I); I = intention(Id,IntendedMeans); .println; .println("* Intention ",Id, " IM stack:"); Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/release-notes.txt 2008-09-13 19:09:17 UTC (rev 1370) @@ -9,7 +9,26 @@ see/run 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 + 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 + 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 + see demo/failure for an example + see code of JasonException and TS for more information + New internal actions . .term2string: transform term into strings and vice-versa. Modified: trunk/src/jason/JasonException.java =================================================================== --- trunk/src/jason/JasonException.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/JasonException.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -24,18 +24,27 @@ package jason; +import jason.asSyntax.Atom; +import jason.asSyntax.ListTerm; +import jason.asSyntax.ListTermImpl; +import jason.asSyntax.StringTermImpl; +import jason.asSyntax.Structure; +import jason.asSyntax.Term; + public class JasonException extends java.lang.Exception { private static final long serialVersionUID = 1L; + private static final Term defaultError = new Atom("internal_action"); + private Term error = defaultError; + /** * Creates a new instance of <code>JasonException</code> without detail message. */ public JasonException() { } - /** * Constructs an instance of <code>JasonException</code> with the specified detail message. * @param msg the detail message. @@ -44,9 +53,44 @@ super(msg); } + /** + * Constructs an instance of <code>JasonException</code> with the specified detail message + * and error description term. + * + * @param msg the detail message. + * @param error the term that details (in AgentSpeak) the error + */ + public JasonException(String msg, Term error) { + super(msg); + this.error = error; + } + public JasonException(String msg, Exception cause) { super(msg); initCause(cause); } + public JasonException(String msg, Term error, Exception cause) { + super(msg); + initCause(cause); + this.error = error; + } + + public ListTerm getErrorTerms() { + return createBasicErrorAnnots(error, getMessage()); + } + + public static ListTerm createBasicErrorAnnots(String id, String msg) { + return createBasicErrorAnnots(new Atom(id), msg); + } + public static ListTerm createBasicErrorAnnots(Term id, String msg) { + ListTerm failAnnots = new ListTermImpl(); + Structure e = new Structure("error", 1); + e.addTerm(id); + failAnnots.add(e); + Structure m = new Structure("error_msg", 1); + m.addTerm(new StringTermImpl(msg)); + failAnnots.add(m); + return failAnnots; + } } Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSemantics/Agent.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -505,7 +505,7 @@ Trigger te = new Trigger(TEOperator.del, TEType.belief, l); if (ts.getC().hasListener() || pl.hasCandidatePlan(te)) { - l = (Literal)l.clone(); + l = l.copy(); l.clearAnnots(); l.addAnnot(BeliefBase.TPercept); te.setLiteral(l); @@ -529,7 +529,7 @@ // checking all percepts for new beliefs for (Literal lp : percepts) { try { - lp = (Literal) lp.clone(); + lp = lp.copy(); lp.addAnnot(BeliefBase.TPercept); if (getBB().add(lp)) { Trigger te = new Trigger(TEOperator.add, TEType.belief, lp); Modified: trunk/src/jason/asSemantics/IntendedMeans.java =================================================================== --- trunk/src/jason/asSemantics/IntendedMeans.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -48,7 +48,7 @@ private Trigger trigger; // the trigger which created this IM public IntendedMeans(Option opt, Trigger te) { - plan = opt.getPlan().cloneOnlyBody(); + plan = opt.getPlan().copyOnlyBody(); unif = opt.getUnifier(); //(Unifier)opt.getUnifier().clone(); // REMOVED: experimental Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -27,14 +27,16 @@ import jason.RevisionFailedException; import jason.architecture.AgArch; import jason.asSyntax.Atom; -import jason.asSyntax.PlanBody; import jason.asSyntax.DefaultTerm; import jason.asSyntax.InternalActionLiteral; import jason.asSyntax.ListTermImpl; import jason.asSyntax.Literal; import jason.asSyntax.LogicalFormula; +import jason.asSyntax.NumberTermImpl; import jason.asSyntax.Plan; +import jason.asSyntax.PlanBody; import jason.asSyntax.PlanLibrary; +import jason.asSyntax.StringTermImpl; import jason.asSyntax.Structure; import jason.asSyntax.Term; import jason.asSyntax.Trigger; @@ -177,7 +179,7 @@ getC().addIntention(intention); } else { conf.C.SI = intention; - generateGoalDeletion(); + generateGoalDeletion(JasonException.createBasicErrorAnnots("ask_failed", "")); } // the message is not an ask answer @@ -255,8 +257,9 @@ confP.step = State.ProcAct; // default next step if (conf.C.SE.trigger.isGoal()) { // can't carry on, no relevant/applicable plan. - logger.warning("Found a goal for which there is no "+m+" plan:" + conf.C.SE); - generateGoalDeletionFromEvent(); + String msg = "Found a goal for which there is no "+m+" plan:" + conf.C.SE; + if (!generateGoalDeletionFromEvent(JasonException.createBasicErrorAnnots("no_"+m, msg))) + logger.warning(msg); } else { if (conf.C.SE.isInternal()) { // e.g. belief addition as internal event, just go ahead @@ -286,7 +289,7 @@ if (logger.isLoggable(Level.FINE)) logger.fine("Selected option "+confP.C.SO+" for event "+confP.C.SE); } else { logger.fine("** selectOption returned null!"); - generateGoalDeletionFromEvent(); + generateGoalDeletionFromEvent(JasonException.createBasicErrorAnnots("no_option", "selectOption returned null")); // can't carry on, no applicable plan. confP.step = State.ProcAct; } @@ -301,7 +304,7 @@ */ private void applyFindOp() throws JasonException { confP.step = State.AddIM; // default next step - + // get all relevant plans for the selected event //Trigger te = (Trigger) conf.C.SE.trigger.clone(); List<Plan> candidateRPs = conf.ag.pl.getCandidatePlans(conf.C.SE.trigger); @@ -322,10 +325,11 @@ } } } - } - - // problem: no plan - applyRelApplPlRule2("relevant/applicable"); + applyRelApplPlRule2("applicable"); + } else { + // problem: no plan + applyRelApplPlRule2("relevant"); + } } private void applyAddIM() throws JasonException { @@ -361,7 +365,7 @@ updateIntention(); applyClrInt(confP.C.SI); } else { - generateGoalDeletion(); + generateGoalDeletion(JasonException.createBasicErrorAnnots("action_failed", "")); } } else { applyProcAct(); // get next action @@ -426,6 +430,7 @@ case internalAction: boolean ok = false; + List<Term> errorAnnots = null; try { InternalAction ia = ((InternalActionLiteral)bTerm).getIA(ag); Object oresult = ia.execute(this, u, body.getTermsArray()); @@ -439,17 +444,23 @@ ok = true; } } + if (!ok) { // IA returned false + errorAnnots = JasonException.createBasicErrorAnnots("ia_failed", ""); + } } if (ok && !ia.suspendIntention()) updateIntention(); - + } catch (JasonException e) { + errorAnnots = e.getErrorTerms(); + if (!generateGoalDeletion(errorAnnots)) + 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); - ok = false; } if (!ok) - generateGoalDeletion(); + generateGoalDeletion(errorAnnots); break; @@ -459,8 +470,9 @@ im.unif = iu.next(); updateIntention(); } else { - if (logger.isLoggable(Level.FINE)) logger.fine("Constraint "+h+" was not satisfied ("+h.getErrorMsg()+")."); - generateGoalDeletion(); + String msg = "Constraint "+h+" was not satisfied ("+h.getErrorMsg()+")."; + generateGoalDeletion(JasonException.createBasicErrorAnnots(new Atom("constraint_failed"), msg)); + logger.fine(msg); } break; @@ -627,6 +639,7 @@ // 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 ... @@ -641,12 +654,11 @@ // should became // +!s: !z im = i.peek(); - if (im.isFinished() || !im.unif.unifies(topIM.getTrigger().getLiteral(), im.getCurrentStep().getBodyTerm())) + if (im.isFinished() || !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral)) im = i.pop(); // +!c above - while (i.size() > 0 && - !im.unif.unifies(topIM.getTrigger().getLiteral(), im.getTrigger().getLiteral()) && - !im.unif.unifies(topIM.getTrigger().getLiteral(), im.getCurrentStep().getBodyTerm())) { + !im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) && + !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral)) { im = i.pop(); } } @@ -654,16 +666,24 @@ 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 the plan TE and not the IM.trigger because the + // (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) + // they are anonymous) Literal tel = topIM.getPlan().getTrigger().getLiteral(); - tel.apply(topIM.unif); - tel.makeVarsAnnon(topIM.unif); - im.unif.unifies(tel, g); + // 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); } } @@ -764,11 +784,17 @@ /** generate a failure event for the current intention */ private void generateGoalDeletion() throws JasonException { + generateGoalDeletion(null); + } + private boolean generateGoalDeletion(List<Term> failAnnots) throws JasonException { + boolean failEeventGenerated = false; IntendedMeans im = conf.C.SI.peek(); if (im.isGoalAdd()) { Event failEvent = findEventForFailure(conf.C.SI, im.getTrigger()); if (failEvent != null) { + setDefaultFailureAnnots(failEvent, im.getCurrentStep().getBodyTerm(), failAnnots); confP.C.addEvent(failEvent); + 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()); @@ -784,23 +810,26 @@ } else { logger.warning("Could not finish intention: " + conf.C.SI); } + return failEeventGenerated; } // similar to the one above, but for an Event rather than intention - private void generateGoalDeletionFromEvent() throws JasonException { + 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); - return; + return false; } Trigger tevent = ev.trigger; - + boolean failEeventGenerated = false; if (tevent.isAddition() && tevent.isGoal()) { Event failEvent = findEventForFailure(ev.intention, tevent); if (failEvent != null) { - logger.warning("Generating goal deletion " + failEvent.getTrigger() + " from event: " + ev.getTrigger()); + setDefaultFailureAnnots(failEvent, tevent.getLiteral(), failAnnots); confP.C.addEvent(failEvent); + failEeventGenerated = true; + //logger.warning("Generating goal deletion " + failEvent.getTrigger() + " from event: " + ev.getTrigger()); } else { logger.warning("No fail event was generated for " + ev.getTrigger()); } @@ -814,6 +843,7 @@ logger.warning("Requeing external event: " + ev); } else logger.warning("Discarding external event: " + ev); + return failEeventGenerated; } public Event findEventForFailure(Intention i, Trigger tevent) { @@ -828,11 +858,48 @@ } // if some failure handling plan is found if (tevent.isGoal() && getAg().getPL().hasCandidatePlan(failTrigger)) { - return new Event(failTrigger, i); + return new Event(failTrigger.copy(), i); } return null; } + private static void setDefaultFailureAnnots(Event failEvent, Term body, List<Term> failAnnots) { + // add default failure annots + if (failAnnots == null) + failAnnots = JasonException.createBasicErrorAnnots("unknown", ""); + + // add failure annots in the event related to the code source + Literal bodyterm = null; + Term codesrc = null; + Term codeline = null; + if (body != null && body instanceof Literal) { + bodyterm = (Literal)body; + codesrc = new StringTermImpl(bodyterm.getSrc()); + codeline = new NumberTermImpl(bodyterm.getSrcLine()); + } else { + bodyterm = new Atom("no_code"); + codesrc = new Atom("no_code"); + codeline = new Atom("no_code"); + + } + + // code + Structure code = new Structure("code"); + code.addTerm(bodyterm); + failAnnots.add(code); + + // ASL source + Structure src = new Structure("code_src"); + src.addTerm(codesrc); + failAnnots.add(src); + + // line in the source + Structure line = new Structure("code_line"); + line.addTerm(codeline); + failAnnots.add(line); + failEvent.getTrigger().getLiteral().addAnnots(failAnnots); + } + public boolean canSleep() { return !conf.C.hasEvent() && !conf.C.hasIntention() && conf.C.MB.isEmpty() && !conf.C.hasFeedbackAction() && Modified: trunk/src/jason/asSyntax/Literal.java =================================================================== --- trunk/src/jason/asSyntax/Literal.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/Literal.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -163,7 +163,7 @@ while (ruleIt != null && ruleIt.hasNext()) { // unifies the rule head with the result of rule evaluation Unifier ruleUn = ruleIt.next(); // evaluation result - Literal rhead = rule.headClone(); + Literal rhead = rule.headCopy(); rhead.apply(ruleUn); rhead.makeVarsAnnon(ruleUn); Modified: trunk/src/jason/asSyntax/Plan.java =================================================================== --- trunk/src/jason/asSyntax/Plan.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/Plan.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -208,8 +208,13 @@ return p; } + /** @deprecated use copyOnlyBody */ + public Plan cloneOnlyBody() { + return copyOnlyBody(); + } + /** used to create a plan clone in a new IM */ - public Plan cloneOnlyBody() { + public Plan copyOnlyBody() { Plan p = new Plan(); if (label != null) { p.label = label; Modified: trunk/src/jason/asSyntax/Rule.java =================================================================== --- trunk/src/jason/asSyntax/Rule.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/Rule.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -82,6 +82,10 @@ return r; } + public Literal headCopy() { + return (Literal)super.clone(); + } + /** @deprecated use headCopy */ public Literal headClone() { return (Literal)super.clone(); } Modified: trunk/src/jason/asSyntax/Trigger.java =================================================================== --- trunk/src/jason/asSyntax/Trigger.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/Trigger.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -124,11 +124,14 @@ } public Object clone() { - Trigger c = new Trigger(operator, type, (Literal)literal.clone()); + return copy(); + } + + public Trigger copy() { + Trigger c = new Trigger(operator, type, literal.copy()); c.piCache = this.piCache; return c; - } - + } /** return [+|-][!|?] super.getPredicateIndicator */ public PredicateIndicator getPredicateIndicator() { Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc =================================================================== --- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-09-13 19:09:17 UTC (rev 1370) @@ -270,7 +270,7 @@ if (config.getBoolean(Config.WARN_SING_VAR) && !parsedFiles.contains(asSource)) { List<VarTerm> singletonVars = h.getSingletonVars(); if (singletonVars.size() > 0) { - logger.warning(getSourceRef(h)+" warning: the rule with head '"+((Rule)h).headClone()+"' has the following singleton variables: "+singletonVars); + logger.warning(getSourceRef(h)+" warning: the rule with head '"+((Rule)h).headCopy()+"' has the following singleton variables: "+singletonVars); } } } Modified: trunk/src/jason/asSyntax/parser/as2j.java =================================================================== --- trunk/src/jason/asSyntax/parser/as2j.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/parser/as2j.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -289,7 +289,7 @@ if (config.getBoolean(Config.WARN_SING_VAR) && !parsedFiles.contains(asSource)) { List<VarTerm> singletonVars = h.getSingletonVars(); if (singletonVars.size() > 0) { - logger.warning(getSourceRef(h)+" warning: the rule with head '"+((Rule)h).headClone()+"' has the following singleton variables: "+singletonVars); + logger.warning(getSourceRef(h)+" warning: the rule with head '"+((Rule)h).headCopy()+"' has the following singleton variables: "+singletonVars); } } break; Modified: trunk/src/jason/asSyntax/patterns/goal/DG.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/DG.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/patterns/goal/DG.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -32,7 +32,7 @@ // add ?g in the end of all inner plans for (Plan p: innerContent.getPL()) { - PlanBody b = new PlanBodyImpl(BodyType.test, (Literal)goal.clone()); + PlanBody b = new PlanBodyImpl(BodyType.test, goal.copy()); p.getBody().add(b); newAg.getPL().add(p); } Modified: trunk/src/jason/asSyntax/patterns/goal/EBDG.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -56,7 +56,7 @@ PlanBody b1 = new PlanBodyImpl(BodyType.addBel, pi); p.getBody().add(0, b1); // add ?g - PlanBody b2 = new PlanBodyImpl(BodyType.test, (Literal)goal.clone()); + PlanBody b2 = new PlanBodyImpl(BodyType.test, goal.copy()); p.getBody().add(b2); newAg.getPL().add(p); } Modified: trunk/src/jason/asSyntax/patterns/goal/MG.java =================================================================== --- trunk/src/jason/asSyntax/patterns/goal/MG.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/asSyntax/patterns/goal/MG.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -35,7 +35,7 @@ Agent newAg = sd.process(subDir, outerContent, innerContent); if (newAg != null) { // add bel g - Literal ig = (Literal)goal.clone(); + Literal ig = goal.copy(); ig.addAnnot(BeliefBase.TPercept); newAg.addInitialBel(goal); Modified: trunk/src/jason/bb/DefaultBeliefBase.java =================================================================== --- trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -255,7 +255,7 @@ public Object clone() { DefaultBeliefBase bb = new DefaultBeliefBase(); for (Literal b: this) { - bb.add(1,(Literal)b.clone()); + bb.add(1, b.copy()); } return bb; } @@ -308,7 +308,7 @@ protected Object clone() { BelEntry be = new BelEntry(); for (Literal l: list) { - be.add((Literal)l.clone(), false); + be.add(l.copy(), false); } return be; } Modified: trunk/src/jason/stdlib/abolish.java =================================================================== --- trunk/src/jason/stdlib/abolish.java 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/jason/stdlib/abolish.java 2008-09-13 19:09:17 UTC (rev 1370) @@ -27,6 +27,7 @@ import jason.asSemantics.DefaultInternalAction; import jason.asSemantics.TransitionSystem; import jason.asSemantics.Unifier; +import jason.asSyntax.Atom; import jason.asSyntax.Literal; import jason.asSyntax.Term; @@ -55,9 +56,7 @@ ts.getAg().abolish((Literal)args[0], un); return true; } catch (ArrayIndexOutOfBoundsException e) { - throw new JasonException("The internal action 'abolish' has not received the required argument."); - } catch (Exception e) { - throw new JasonException("Error in internal action 'abolish': " + e, e); + throw new JasonException("The internal action 'abolish' has not received the required argument.", new Atom("wrong_arguments")); } } } Modified: trunk/src/templates/ia =================================================================== --- trunk/src/templates/ia 2008-09-12 17:05:14 UTC (rev 1369) +++ trunk/src/templates/ia 2008-09-13 19:09:17 UTC (rev 1370) @@ -2,6 +2,7 @@ package <PCK>; +import jason.*; import jason.asSemantics.*; import jason.asSyntax.*; import java.util.logging.*; @@ -12,12 +13,8 @@ @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { - try { - logger.info("not implemented!"); - return true; - } catch (Exception e) { - logger.warning("Error in internal action '<PCK>.<IA_NAME>'! "+e); - } - return false; + logger.info("executing internal action '<PCK>.<IA_NAME>'"); + throw new JasonException("not implemented!"); + //return true; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |