Package FAtiMA.Core.conditions
Class Condition
- java.lang.Object
-
- FAtiMA.Core.conditions.Condition
-
- All Implemented Interfaces:
IGroundable,java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
MoodCondition,PredicateCondition,PropertyCondition
public abstract class Condition extends java.lang.Object implements IGroundable, java.lang.Cloneable, java.io.Serializable
Abstract condition test, used to represent preconditions, success conditions, etc. Conditions can be either Predicate conditions or Property conditions. Provides methods to search the value of such conditions in the KnowledgeBase.- Author:
- Joao Dias
- See Also:
PredicateCondition,PropertyCondition,KnowledgeBase, Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCondition()protectedCondition(Condition c)Creates a new Condition - not used directly because its an abstract classCondition(Name name)Creates a new Condition - not used directly because its an abstract classCondition(Name name, Symbol ToM)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.util.ArrayList<SubstitutionSet>CheckActivation(AgentModel am, java.util.ArrayList<Condition> preconditions)Checks if a list of conditions (usually preconditions) to see if all of them are verified.abstract booleanCheckCondition(AgentModel am)Checks if the condition is verified in the agent's memory (KB + AM)abstract java.lang.Objectclone()Clones this Condition, returning an equal copy.NamegetName()SymbolgetToM()java.util.ArrayList<SubstitutionSet>GetValidBindings(AgentModel am)This method finds all the possible sets of Substitutions that applied to the condition will make it valid (true) according to the agent's memory (KB + AM)abstract NameGetValue()Gets the condition's value - the object compared against the condition's nameprotected abstract java.util.ArrayList<Substitution>GetValueBindings(AgentModel am)Find a set of Substitutions for the second part of the condition, which will make it become true.booleanhasChangedVerifiability()booleanisGrounded()Indicates if the Predicate is grounded (no unbound variables in it's WFN) Example: Stronger(Luke,John) is grounded while Stronger(John,[X]) is not.booleanisVerifiable()voidMakeGround(Substitution subst)Applies a set of substitutions to the object, grounding it.voidMakeGround(java.util.ArrayList<Substitution> bindings)Applies a set of substitutions to the object, grounding it.voidReplaceUnboundVariables(int variableID)Replaces all unbound variables in the object by applying a numeric identifier to each one.protected voidsetName(Name name)protected voidsetToM(Symbol ToM)voidsetVerifiable(boolean verifiableStatus)
-
-
-
Constructor Detail
-
Condition
protected Condition(Condition c)
Creates a new Condition - not used directly because its an abstract class
-
Condition
protected Condition()
-
Condition
public Condition(Name name)
Creates a new Condition - not used directly because its an abstract class- Parameters:
name- - the condition's name
-
-
Method Detail
-
getName
public Name getName()
-
getToM
public Symbol getToM()
-
isVerifiable
public boolean isVerifiable()
-
setName
protected void setName(Name name)
-
setToM
protected void setToM(Symbol ToM)
-
CheckActivation
public static java.util.ArrayList<SubstitutionSet> CheckActivation(AgentModel am, java.util.ArrayList<Condition> preconditions)
Checks if a list of conditions (usually preconditions) to see if all of them are verified. The method returns a list of possible SubstitutionSets. Each of the returned SustitutionSet applied to the entire set of conditions will make them all true. As example, if we have the generic goal of bullying someone Bully([Victim]), and we have a precondition list consisting of seing someone weaker than us, So if we see John (a weak victim) and Frances (another weak victim) we can activate the preconditions and subsequently the specific goal Bully(John) and Bully(Frances), by applying the substitutionset {[Victim]/John} and the substitutionset {[Victim]/Frances}- Parameters:
preconditions- - the list of preconditions that we want to test for activation- Returns:
- a list of SubstitutionSets that if applied to all the preconditions will make them true, returns null if no such SubstitutionSet exists
- See Also:
SubstitutionSet
-
setVerifiable
public void setVerifiable(boolean verifiableStatus)
-
hasChangedVerifiability
public boolean hasChangedVerifiability()
-
clone
public abstract java.lang.Object clone()
Clones this Condition, returning an equal copy. If this clone is changed afterwards, the original object remains the same.- Overrides:
clonein classjava.lang.Object- Returns:
- The Conditions's copy.
-
CheckCondition
public abstract boolean CheckCondition(AgentModel am)
Checks if the condition is verified in the agent's memory (KB + AM)- Returns:
- true if the condition is verified, false otherwise
- See Also:
KnowledgeBase
-
GetValidBindings
public java.util.ArrayList<SubstitutionSet> GetValidBindings(AgentModel am)
This method finds all the possible sets of Substitutions that applied to the condition will make it valid (true) according to the agent's memory (KB + AM)- Returns:
- A list with all SubstitutionsSets that make the condition valid, if there are no such substitutions, the method returns null
- See Also:
KnowledgeBase
-
GetValue
public abstract Name GetValue()
Gets the condition's value - the object compared against the condition's name- Returns:
- the condition's value
-
GetValueBindings
protected abstract java.util.ArrayList<Substitution> GetValueBindings(AgentModel am)
Find a set of Substitutions for the second part of the condition, which will make it become true. With this method it is possible to test conditions that have unbound variables in the second part such as: "Owner(Ball) = [x]" this condition will be true if there is anyone in the world that owns a Ball. If John owns the ball, the method returns [x]/John- Returns:
- returns all set of Substitutions that make the condition valid.
-
ReplaceUnboundVariables
public void ReplaceUnboundVariables(int variableID)
Replaces all unbound variables in the object by applying a numeric identifier to each one. For example, the variable [x] becomes [x4] if the received ID is 4. Attention, this method modifies the original object.- Specified by:
ReplaceUnboundVariablesin interfaceIGroundable- Parameters:
variableID- - the identifier to be applied
-
MakeGround
public void MakeGround(java.util.ArrayList<Substitution> bindings)
Applies a set of substitutions to the object, grounding it. Example: Applying the substitution "[X]/John" in the name "Weak([X])" returns "Weak(John)". Attention, this method modifies the original object.- Specified by:
MakeGroundin interfaceIGroundable- Parameters:
bindings- - A list of substitutions of the type "[Variable]/value"- See Also:
Substitution
-
MakeGround
public void MakeGround(Substitution subst)
Applies a set of substitutions to the object, grounding it. Example: Applying the substitution "[X]/John" in the name "Weak([X])" returns "Weak(John)". Attention, this method modifies the original object.- Specified by:
MakeGroundin interfaceIGroundable- Parameters:
subst- - a substitution of the type "[Variable]/value"- See Also:
Substitution
-
isGrounded
public boolean isGrounded()
Indicates if the Predicate is grounded (no unbound variables in it's WFN) Example: Stronger(Luke,John) is grounded while Stronger(John,[X]) is not.- Specified by:
isGroundedin interfaceIGroundable- Returns:
- true if the Predicate is grounded, false otherwise
-
-