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

jason.stdlib.relevant_plans 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.

There is a newer version: 2.3
Show newest version
package jason.stdlib;

import jason.JasonException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.Option;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Plan;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
import jason.asSyntax.parser.ParseException;

import java.util.List;

/**
  

Internal action: .relevant_plans.

Description: gets all relevant plans for some triggering event. This internal action is used, for example, to answer "askHow" messages.

Parameters:

  • + trigger (trigger): the triggering event, enclosed by { and }.
  • - plans (list of plan terms): the list of plan terms corresponding to the code of the relevant plans.
  • - labels (list, optional): the list of labels of the plans.

Example:

  • .relevant_plans({+!go(X,Y)},LP): unifies LP with a list of all plans in the agent's plan library that are relevant for the triggering event +!go(X,Y).
  • .relevant_plans({+!go(X,Y)},LP, LL): same as above but also unifies LL with a list of labels of plans in LP.
  • .relevant_plans({+!_},_,LL): gets the labels of all achievement goals.
@see jason.stdlib.add_plan @see jason.stdlib.plan_label @see jason.stdlib.remove_plan */ public class relevant_plans extends DefaultInternalAction { @Override public int getMinArgs() { return 2; } @Override public int getMaxArgs() { return 3; } @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { checkArguments(args); Trigger te = null; try { te = Trigger.tryToGetTrigger(args[0]); } catch (ParseException e) {} if (te == null) throw JasonException.createWrongArgument(this,"first argument '"+args[0]+"' must follow the syntax of a trigger."); ListTerm labels = new ListTermImpl(); ListTerm lt = new ListTermImpl(); ListTerm last = lt; List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy