All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jason.stdlib.abolish Maven / Gradle / Ivy

Go to download

Jason is a fully-fledged interpreter for an extended version of AgentSpeak, a BDI agent-oriented logic programming language.

The newest version!
package jason.stdlib;

import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;

/**
  

Internal action: .abolish.

Description: removes all beliefs that match the argument. As for the "-" operator, an event will be generated for each deletion. Different from the "-" operator, which consider "self" as the default source, .abolish will ignore the source if not informed.

Parameters:

  • + pattern (literal or variable): the "pattern" for what should be removed.

Examples:

  • .abolish(b(_)): remove all b/1 beliefs, regardless of the argument value and the source of the belief.
  • .abolish(c(_,t)): remove all c/2 beliefs where the second argument is 2.
  • .abolish(c(_,_)[source(ag1)]): remove all c/2 beliefs that have ag1 as source.
  • .abolish(_[source(ag1)]): remove any beliefs that have ag1 as source.
@see jason.stdlib.asserta @see jason.stdlib.assertz */ public class abolish extends DefaultInternalAction { @Override public int getMinArgs() { return 1; } @Override public int getMaxArgs() { return 1; } @Override protected void checkArguments(Term[] args) throws JasonException { super.checkArguments(args); // check number of arguments if (!args[0].isLiteral() & !args[0].isVar()) throw JasonException.createWrongArgument(this,"first argument must be a literal or variable."); } @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { checkArguments(args); ts.getAg().abolish((Literal)args[0], un); return true; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy