Class RepeatGoalStructure<TBeliefSet>
- Namespace
- Aplib.Core.Desire.GoalStructures
- Assembly
- Aplib.Core.dll
Represents a goal structure that will complete if any of its children complete. This structure will repeatedly execute the goal it was created with until the goal is finished, or the maximum number of retries is reached.
public class RepeatGoalStructure<TBeliefSet> : GoalStructure<TBeliefSet>, IGoalStructure<TBeliefSet>, ICompletable, ILoggable, IDocumented where TBeliefSet : IBeliefSet
Type Parameters
TBeliefSetThe belief set of the agent.
- Inheritance
-
GoalStructure<TBeliefSet>RepeatGoalStructure<TBeliefSet>
- Implements
-
IGoalStructure<TBeliefSet>
- Inherited Members
- Extension Methods
Constructors
RepeatGoalStructure(IGoalStructure<TBeliefSet>)
public RepeatGoalStructure(IGoalStructure<TBeliefSet> goalStructure)
Parameters
goalStructureIGoalStructure<TBeliefSet>
RepeatGoalStructure(IGoalStructure<TBeliefSet>, int)
public RepeatGoalStructure(IGoalStructure<TBeliefSet> goalStructure, int maxRetries)
Parameters
goalStructureIGoalStructure<TBeliefSet>maxRetriesint
RepeatGoalStructure(IMetadata, IGoalStructure<TBeliefSet>)
public RepeatGoalStructure(IMetadata metadata, IGoalStructure<TBeliefSet> goalStructure)
Parameters
metadataIMetadatagoalStructureIGoalStructure<TBeliefSet>
RepeatGoalStructure(IMetadata, IGoalStructure<TBeliefSet>, int)
public RepeatGoalStructure(IMetadata metadata, IGoalStructure<TBeliefSet> goalStructure, int maxRetries)
Parameters
metadataIMetadatagoalStructureIGoalStructure<TBeliefSet>maxRetriesint
RepeatGoalStructure(IMetadata, IGoalStructure<TBeliefSet>, int?)
Initializes a new instance of the RepeatGoalStructure<TBeliefSet> class.
protected RepeatGoalStructure(IMetadata metadata, IGoalStructure<TBeliefSet> goalStructure, int? maxRetries)
Parameters
metadataIMetadataMetadata about this goal, used to quickly display the goal in several contexts.
goalStructureIGoalStructure<TBeliefSet>The GoalStructure to repeat.
maxRetriesint?The maximum number of times to retry the goal after it has failed. If omitted, the goal will be retried indefinitely.
Exceptions
- ArgumentOutOfRangeException
If
maxRetriesis less than zero.
Fields
_maxRetries
The maximum number of times to retry the goal after it has failed.
If this is null, the goal will be retried indefinitely.
protected readonly int? _maxRetries
Field Value
- int?
_retryCount
The number of times the goal has been retried so far.
protected int _retryCount
Field Value
Methods
GetCurrentGoal(TBeliefSet)
Gets the current goal using the given IBeliefSet.
public override IGoal<TBeliefSet> GetCurrentGoal(TBeliefSet beliefSet)
Parameters
beliefSetTBeliefSetThe belief set of the agent.
Returns
- IGoal<TBeliefSet>
The current goal to be fulfilled.
GetLogChildren()
Gets the children of the loggable object.
public override IEnumerable<ILoggable> GetLogChildren()
Returns
- IEnumerable<ILoggable>
The children of the loggable object.
UpdateStatus(TBeliefSet)
Updates the status of the RepeatGoalStructure<TBeliefSet>. The goal structure status is set to:
- SuccessWhen the underlying goal structure is successful.
- Failure If the underlying goal structure fails when the maximum number of retries has been reached. But never if no maximum number of retries has been specified.
- Unfinished When the underlying goal structure is unfinished. The underlying goal structure will be retried when it fails.
public override void UpdateStatus(TBeliefSet beliefSet)
Parameters
beliefSetTBeliefSetThe belief set of the agent.