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:
Common interface for all kinds of Jason Belief bases, even those customised by the user.
 public interface BeliefBase extends Iterable<Literal>, Cloneable {
     public static final Term ASelf    = new Atom("self");
     public static final Term APercept = new Atom("percept");

represents the structure 'source(percept)'
     public static final Term TPercept = Pred.createSource();

represents the structure 'source(self)'
     public static final Term TSelf    = Pred.createSource();
Called before the MAS execution with the agent that uses this BB and the args informed in .mas2j project.
Example in .mas2j:
agent BeliefBaseClass(1,bla);
the init args will be ["1", "bla"].
     public void init(Agent agString[] args);
Called just before the end of MAS execution
     public void stop();
removes all beliefs from BB
     public void clear();
Adds a belief in the end of the BB, returns true if succeed. The annots of l may be changed to reflect what was changed in the BB, for example, if l is p[a,b] in a BB with p[a], l will be changed to p[b] to produce the event +p[b], since only the annotation b is changed in the BB.
     public boolean add(Literal l);

Adds a belief in the BB at index position, returns true if succeed
     public boolean add(int indexLiteral l);

Returns an iterator for all beliefs.
     public Iterator<Literaliterator();


use iterator() instead of getAll
     public Iterator<LiteralgetAll();
Returns an iterator for all literals in BB that match the functor/arity of the parameter.
     public Iterator<LiteralgetCandidateBeliefs(PredicateIndicator pi);

Returns an iterator for all literals relevant for l's predicate indicator, if l is a var, returns all beliefs.
The unifier u may contain values for variables in l. Example, if BB={a(10),a(20),a(2,1),b(f)}, then getCandidateBeliefs(a(5), {}) = {{a(10),a(20)}.
if BB={a(10),a(20)}, then getCandidateBeliefs(X) = {{a(10),a(20)}. The getCandidateBeliefs(a(X), {X -> 5}) should also return {{a(10),a(20)}.
    public Iterator<LiteralgetCandidateBeliefs(Literal lUnifier u);

use getCandidateBeliefs(l,null) instead
    public Iterator<LiteralgetRelevant(Literal l);

Returns the literal l as it is in BB, this method does not consider annotations in the search.
Example, if BB={a(10)[a,b]}, contains(a(10)[d]) returns a(10)[a,b].
    public Literal contains(Literal l);
Returns the number of beliefs in BB
    public int size();

Returns all beliefs that have "percept" as source
    public Iterator<LiteralgetPercepts();

Removes a literal from BB, returns true if succeed
    public boolean remove(Literal l);

Removes all believes with some functor/arity
    public boolean abolish(PredicateIndicator pi);

Gets the BB as XML
    public Element getAsDOM(Document document);
    public BeliefBase clone();
New to GrepCode? Check out our FAQ X