Class Goal<TBeliefSet>
A goal effectively combines a heuristic function with a tactic, and aims to meet the heuristic function by applying the tactic. Goals are combined in a GoalStructure<TBeliefSet>, and are used to prepare tests or do the testing.
public class Goal<TBeliefSet> : IGoal<TBeliefSet>, ICompletable, ILoggable, IDocumented where TBeliefSet : IBeliefSet
Type Parameters
TBeliefSet
The belief set of the agent.
- Inheritance
-
Goal<TBeliefSet>
- Implements
-
IGoal<TBeliefSet>
- Inherited Members
- Extension Methods
Constructors
Goal(IMetadata, ITactic<TBeliefSet>, Predicate<TBeliefSet>)
public Goal(IMetadata metadata, ITactic<TBeliefSet> tactic, Predicate<TBeliefSet> predicate)
Parameters
Goal(IMetadata, ITactic<TBeliefSet>, Predicate<TBeliefSet>, Predicate<TBeliefSet>)
Initializes a new goal from a given tactic and a success predicate, and an optional fail-guard.
public Goal(IMetadata metadata, ITactic<TBeliefSet> tactic, Predicate<TBeliefSet> predicate, Predicate<TBeliefSet> failGuard)
Parameters
metadata
IMetadataMetadata about this goal, used to quickly display the goal in several contexts. If omitted, default metadata will be generated.
tactic
ITactic<TBeliefSet>The tactic used to approach this goal.
predicate
Predicate<TBeliefSet>A predicate that determines when the goal has succeeded.
failGuard
Predicate<TBeliefSet>A predicate that determines when the goal has failed. If the fail-guard is true, but the success predicate is also satisfied, the success predicate takes precedence. If omitted, the goal will never fail.
Goal(ITactic<TBeliefSet>, Predicate<TBeliefSet>)
public Goal(ITactic<TBeliefSet> tactic, Predicate<TBeliefSet> predicate)
Parameters
Goal(ITactic<TBeliefSet>, Predicate<TBeliefSet>, Predicate<TBeliefSet>)
public Goal(ITactic<TBeliefSet> tactic, Predicate<TBeliefSet> predicate, Predicate<TBeliefSet> failGuard)
Parameters
Fields
_failGuard
An (optional) fail-guard for the goal's completion status. The fail-guard predicate is a condition that, when true, indicates that the goal has failed.
protected readonly Predicate<TBeliefSet> _failGuard
Field Value
- Predicate<TBeliefSet>
_predicate
A predicate that determines whether the goal has succeeded. Intuitively, the predicate is the goal itself.
protected readonly Predicate<TBeliefSet> _predicate
Field Value
- Predicate<TBeliefSet>
Properties
Metadata
Gets the metadata of the instance. This metadata may be useful for debugging or logging.
public IMetadata Metadata { get; }
Property Value
Status
Gets the completion status of the goal. This value may need to be updated first using the UpdateStatus(TBeliefSet) method.
public CompletionStatus Status { get; protected set; }
Property Value
- See Also
Tactic
The Tactic<TBeliefSet> used to achieve this Goal<TBeliefSet>. It is executed once in every iteration of the BDI cycle while this goal is the active goal of the agent.
public ITactic<TBeliefSet> Tactic { get; }
Property Value
- ITactic<TBeliefSet>
Methods
GetLogChildren()
Gets the children of the loggable object.
public IEnumerable<ILoggable> GetLogChildren()
Returns
- IEnumerable<ILoggable>
The children of the loggable object.
UpdateStatus(TBeliefSet)
Checks whether the goal has been achieved and stores the result in Status.
If the predicate of the goal is satisfied, the goal is considered to have succeeded. If the fail-guard is satisfied, the goal is considered to have failed. If both are satisfied, the success predicate takes precedence. If neither are satisfied, the goal is considered unfinished. The table below summarizes the possible outcomes:
Predicate | Fail guard | Result |
---|---|---|
true | false | Success |
true | true | Success |
false | true | Failure |
false | false | Unfinished |
public virtual void UpdateStatus(TBeliefSet beliefSet)
Parameters
beliefSet
TBeliefSetThe belief set of the agent.