Table of Contents

Class Goal<TBeliefSet>

Namespace
Aplib.Core.Desire.Goals
Assembly
Aplib.Core.dll

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

metadata IMetadata
tactic ITactic<TBeliefSet>
predicate Predicate<TBeliefSet>

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 IMetadata

Metadata 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

tactic ITactic<TBeliefSet>
predicate Predicate<TBeliefSet>

Goal(ITactic<TBeliefSet>, Predicate<TBeliefSet>, Predicate<TBeliefSet>)

public Goal(ITactic<TBeliefSet> tactic, Predicate<TBeliefSet> predicate, Predicate<TBeliefSet> failGuard)

Parameters

tactic ITactic<TBeliefSet>
predicate Predicate<TBeliefSet>
failGuard Predicate<TBeliefSet>

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

IMetadata

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

CompletionStatus
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:

PredicateFail guardResult
truefalseSuccess
truetrueSuccess
falsetrueFailure
falsefalseUnfinished
Use Status to get the updated value.
public virtual void UpdateStatus(TBeliefSet beliefSet)

Parameters

beliefSet TBeliefSet

The belief set of the agent.

See Also

GoalStructure<TBeliefSet>