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
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // 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:
 // http://www.inf.ufrgs.br/~bordini
 // http://www.das.ufsc.br/~jomi
 //
 //----------------------------------------------------------------------------
 
 
 package jason.stdlib;
 

Internal action: .remove_plan.

Description: removes plans from the agent's plan library.

Parameters:

  • + label(s) (structure or list of structures): the label of the plan to be removed. If this parameter is a list of labels, all plans of this list are removed.
  • + source (atom [optional]): the source of the plan to be removed. The default value is self.

Examples:

  • .remove_plan(l1): removes the plan identified by label l1[source(self)].
  • .remove_plan(l1,bob): removes the plan identified by label l1[source(bob)]. Note that a plan with a source like that was probably added to the plan library by a tellHow message.
  • .remove_plan([l1,l2,l3]): removes the plans identified by labels l1[source(self)], l2[source(self)], and l3[source(self)].
  • .remove_plan([l1,l2,l3],bob): removes the plans identified by labels l1[source(bob)], l2[source(bob)], and l3[source(bob)].
  • .relevant_plans({ +!g }, _, L); .remove_plan(LL): removes all plans with trigger event +!g.

 
 public class remove_plan extends DefaultInternalAction {
 
     @Override public int getMinArgs() { return 1; }
     @Override public int getMaxArgs() { return 2; }
 
     @Override
     public Object execute(TransitionSystem tsUnifier unTerm[] argsthrows Exception {
         checkArguments(args);
         Term label = args[0];
 
         Term source = .;
     	if (args.length > 1) {
             source = (Atom)args[1];
     	}
     	
     	if (label.isList()) { // arg[0] is a list
     	    boolean r = true;
             ListTerm lt = (ListTerm)args[0];
             for (Term tlt) {
                 r = r && ts.getAg().getPL().remove((Atom)tsource);
             }
             return r;
    	} else { // args[0] is a plan label
            return ts.getAg().getPL().remove((Atom)labelsource);
    	}
    }
New to GrepCode? Check out our FAQ X