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: .current_intention.

Description: returns a description of the current intention. It is useful for plans that need to inspect the current intention. The description of the intention has the following form:

intention(id,stack of intended means)

where each intended means has the form:

im(plan label,plan body term, unification function (a list of maps))

For example:

im(l__6[source(self)],{ .current_intention(I); .print(end) }, [map(I, ....)]),
im(l__5[source(self)],{ .fail }, []),
im(l__4[source(self)],{ !g5(X); .print(endg4) }, [map(X, test)]),


  • - intention (structure): the variable that unifies with the intention description.


  • .current_intention(X): X unifies with the description of the current intention (i.e. the intention that executed this internal action).


  • In case this internal action is used in the body of a plan, the intention that are executing the plan is used.
  • In case this internal action is used in the context of a plan, the intention that produced the event is used.

 public class current_intention extends DefaultInternalAction {
     @Override public int getMinArgs() { return 1; }
     @Override public int getMaxArgs() { return 1; }
    public Object execute(TransitionSystem tsUnifier unTerm[] argsthrows Exception {
        // try to get the intention from the "body"
        Intention i = ts.getC().getSelectedIntention();
        if (i == null) {
            // try to get the intention from the event
            Event evt = ts.getC().getSelectedEvent();
            if (evt != null)
                i = evt.getIntention();
        if (i != null)
            return un.unifies(i.getAsTerm(), args[0]);
            return false;            
New to GrepCode? Check out our FAQ X