Class SampledMemoryBelief<TReference, TObservation>
The SampledMemoryBelief<TReference, TObservation> class represents the agent's belief of a single object, but with additional "memory" of previous observations. These observations are sampled at a fixed rate. Some object reference is used to generate/update an observation (i.e., some piece of information on the game state as perceived by an agent). This belief also stores a limited amount of previous observation samples in memory. Optionally, the belief can always store the most recent observation, regardless of the sample rate.
public class SampledMemoryBelief<TReference, TObservation> : MemoryBelief<TReference, TObservation>, IBelief where TReference : class
Type Parameters
TReference
The type of the reference used to generate/update the observation. This must be a reference type, be aware that this is not enforced by C# if
TReference
is an interface.TObservation
The type of the observation the belief represents.
- Inheritance
-
Belief<TReference, TObservation>MemoryBelief<TReference, TObservation>SampledMemoryBelief<TReference, TObservation>
- Implements
- Inherited Members
Remarks
It supports implicit conversion to TObservation
.
Constructors
SampledMemoryBelief(Metadata, TReference, Func<TReference, TObservation>, int, UpdateMode, int)
Initializes a new instance of the SampledMemoryBelief<TReference, TObservation> class with an object reference, a function to generate/update the observation using the object reference, and a condition on when the observation should be updated. This belief also stores a limited amount of previous observation samples in memory. Optionally, the belief can always store the most recent observation, regardless of the sample rate.
public SampledMemoryBelief(Metadata metadata, TReference reference, Func<TReference, TObservation> getObservationFromReference, int sampleInterval, UpdateMode updateMode, int framesToRemember)
Parameters
metadata
MetadataMetadata about this goal, used to quickly display the goal in several contexts.
reference
TReferenceThe reference used to generate/update the observation. This must be a reference type.
getObservationFromReference
Func<TReference, TObservation>A function that takes a reference and generates/updates an observation.
sampleInterval
intThe sample interval of the memory. One observation memory (i.e., snapshot) is stored every
sampleInterval
-th cycle.updateMode
UpdateModeSpecifies how this sampled memory belief should be updated.
framesToRemember
intThe number of frames to remember back.
Exceptions
- ArgumentException
Thrown when
reference
is not a reference type.
SampledMemoryBelief(Metadata, TReference, Func<TReference, TObservation>, int, UpdateMode, int, Predicate<TReference>)
Initializes a new instance of the SampledMemoryBelief<TReference, TObservation> class with an object reference, a function to generate/update the observation using the object reference, and a condition on when the observation should be updated. This belief also stores a limited amount of previous observation samples in memory. Optionally, the belief can always store the most recent observation, regardless of the sample rate.
public SampledMemoryBelief(Metadata metadata, TReference reference, Func<TReference, TObservation> getObservationFromReference, int sampleInterval, UpdateMode updateMode, int framesToRemember, Predicate<TReference> shouldUpdate)
Parameters
metadata
MetadataMetadata about this goal, used to quickly display the goal in several contexts.
reference
TReferenceThe reference used to generate/update the observation. This must be a reference type.
getObservationFromReference
Func<TReference, TObservation>A function that takes a reference and generates/updates an observation.
sampleInterval
intThe sample interval of the memory. One observation memory (i.e., snapshot) is stored every
sampleInterval
-th cycle.updateMode
UpdateModeSpecifies how this sampled memory belief should be updated.
framesToRemember
intThe number of frames to remember back.
shouldUpdate
Predicate<TReference>A condition on when the observation should be updated. Takes the object reference of the belief as a parameter for the predicate.
Exceptions
- ArgumentException
Thrown when
reference
is not a reference type.
SampledMemoryBelief(TReference, Func<TReference, TObservation>, int, UpdateMode, int)
Initializes a new instance of the SampledMemoryBelief<TReference, TObservation> class with an object reference, a function to generate/update the observation using the object reference, and a condition on when the observation should be updated. This belief also stores a limited amount of previous observation samples in memory. Optionally, the belief can always store the most recent observation, regardless of the sample rate.
public SampledMemoryBelief(TReference reference, Func<TReference, TObservation> getObservationFromReference, int sampleInterval, UpdateMode updateMode, int framesToRemember)
Parameters
reference
TReferenceThe reference used to generate/update the observation. This must be a reference type.
getObservationFromReference
Func<TReference, TObservation>A function that takes a reference and generates/updates an observation.
sampleInterval
intThe sample interval of the memory. One observation memory (i.e., snapshot) is stored every
sampleInterval
-th cycle.updateMode
UpdateModeSpecifies how this sampled memory belief should be updated.
framesToRemember
intThe number of frames to remember back.
Exceptions
- ArgumentException
Thrown when
reference
is not a reference type.
SampledMemoryBelief(TReference, Func<TReference, TObservation>, int, UpdateMode, int, Predicate<TReference>)
Initializes a new instance of the SampledMemoryBelief<TReference, TObservation> class with an object reference, a function to generate/update the observation using the object reference, and a condition on when the observation should be updated. This belief also stores a limited amount of previous observation samples in memory. Optionally, the belief can always store the most recent observation, regardless of the sample rate.
public SampledMemoryBelief(TReference reference, Func<TReference, TObservation> getObservationFromReference, int sampleInterval, UpdateMode updateMode, int framesToRemember, Predicate<TReference> shouldUpdate)
Parameters
reference
TReferenceThe reference used to generate/update the observation. This must be a reference type.
getObservationFromReference
Func<TReference, TObservation>A function that takes a reference and generates/updates an observation.
sampleInterval
intThe sample interval of the memory. One observation memory (i.e., snapshot) is stored every
sampleInterval
-th cycle.updateMode
UpdateModeSpecifies how this sampled memory belief should be updated.
framesToRemember
intThe number of frames to remember back.
shouldUpdate
Predicate<TReference>A condition on when the observation should be updated. Takes the object reference of the belief as a parameter for the predicate.
Exceptions
- ArgumentException
Thrown when
reference
is not a reference type.
Methods
UpdateBelief()
Generates/updates the observation if applicable.
Also stores the previous observation in memory every sampleInterval
-th cycle.
public override void UpdateBelief()