Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // Copyright (C) 2003  Rafael H. Bordini, Jomi F. Hubner, et al.
  // This library is free software; you can redistribute it and/or
  // modify it under the terms of the GNU Lesser General Public
  // License as published by the Free Software Foundation; either
  // version 2.1 of the License, or (at your option) any later version.
  // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // Lesser General Public License for more details.
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 // To contact the authors:
 package jason.stdlib;

Internal action: .fail_goal(G).

Description: aborts goals G in the agent circumstance as if a plan for such goal had failed. Assuming that one of the plans requiring G was G0 <- !G; ..., an event -!G0 is generated. In case G was triggered by !!G (and therefore not a subgoal, as happens also when an "achieve" performative is used), the generated event is -!G. A literal G is a goal if there is a triggering event +!G in any plan within any intention; also note that intentions can be suspended hence appearing in sets E, PA, or PI of the agent's circumstance as well.


  • .fail_goal(go(1,3)): aborts any attempt to achieve goals such as !go(1,3) as if a plan for it had failed. Assuming that it is a subgoal in the plan get_gold(X,Y) <- go(X,Y); pick., the generated event is -!get_gold(1,3).
(Note: this internal action was introduced in a DALT 2006 paper, where it was called .dropGoal(G,false).)

 public class fail_goal extends succeed_goal {
     public Object execute(TransitionSystem tsUnifier unTerm[] argsthrows Exception {
         drop(ts, (Literal)args[0], un);
         return true;
     /* returns: >0 the intention was changed
      *           1 = intention must continue running
      *           2 = fail event was generated and added in C.E
      *           3 = simply removed without event
     public int dropIntention(Intention iTrigger gTransitionSystem tsUnifier unthrows JasonException {
         if (i != null) {
         	if (i.dropGoal(gun)) {
         	    // notify listener
                 if (ts.hasGoalListener())
                     for (GoalListener glts.getGoalListeners())
                 // generate failure event
	            Event failEvent = null;
	            if (!i.isFinished()) {
	                failEvent = ts.findEventForFailure(ii.peek().getTrigger());
	            } else { // it was an intention with g as the only IM (that was dropped), normally when !! is used
	                failEvent = ts.findEventForFailure(ig); // find fail event for the goal just dropped	            	
	            if (failEvent != null) {
	                ts.getLogger().fine("'.fail_goal("+g+")' is generating a goal deletion event: " + failEvent.getTrigger());
	                return 2;
	            } else { // i is finished or without failure plan
	                ts.getLogger().fine("'.fail_goal("+g+")' is removing the intention without event:\n" + i);
	                return 3;
        return 0;        
    void dropInEvent(TransitionSystem tsEvent eIntention ithrows Exception {
New to GrepCode? Check out our FAQ X