Class ConsiderationBase<TState, TBot, TAction>
An abstract base class implementing IConsideration<TState, TBot, TAction> given parameters for curve type and maximum value. The recommended action's urgency will be penalized based on:
- How close the resulting value is to the maximum, using the specified curve for normalization, and
- The significance of this consideration.
Inheritance
Inherited Members
Namespace: Microsoft.XboxStudios.BotBrain.Considerations
Assembly: BotBrain.Core.dll
Syntax
[UsesParameter(new string[] { "Significance" })]
public abstract class ConsiderationBase<TState, TBot, TAction> : ConsiderationBase, IConsideration<TState, TBot, TAction>, IConsideration, IEquatable<IConsideration> where TBot : IAutomatedBot<TAction>
Type Parameters
Name | Description |
---|---|
TState | A title-specific state object. |
TBot | A title-specific bot object that implements IAutomatedBot<TAction>. |
TAction | The title-specific bot action that implements IEquatable<T>. |
Constructors
View SourceConsiderationBase(string?, ILogger<ConsiderationBase<TState, TBot, TAction>>?)
Initializes a new instance of the ConsiderationBase<TState, TBot, TAction> class.
Declaration
protected ConsiderationBase(string? name = null, ILogger<ConsiderationBase<TState, TBot, TAction>>? logger = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | The consideration name. |
ILogger<ConsiderationBase<TState, TBot, TAction>> | logger | The logger. |
Properties
View SourceBrain
Gets or sets the brain using this consideration.
Declaration
public IBotBrain<TState, TBot, TAction>? Brain { get; set; }
Property Value
Type | Description |
---|---|
IBotBrain<TState, TBot, TAction> |
Methods
View SourceEvaluate(TState, TBot, IReadOnlyCollection<IUrge<TState, TBot, TAction>>, in UrgeResult<TState, TBot, TAction>, out ConsiderationResult)
Evaluates the consideration given an urge result.
Declaration
public double? Evaluate(TState state, TBot bot, IReadOnlyCollection<IUrge<TState, TBot, TAction>> urges, in UrgeResult<TState, TBot, TAction> urgeResult, out ConsiderationResult considerationResult)
Parameters
Type | Name | Description |
---|---|---|
TState | state | The state. |
TBot | bot | The bot. |
IReadOnlyCollection<IUrge<TState, TBot, TAction>> | urges | The urges which were active given this state. |
UrgeResult<TState, TBot, TAction> | urgeResult | The urge result to evaluate. |
ConsiderationResult | considerationResult | Outputs the intermediate values used during evaluation. |
Returns
Type | Description |
---|---|
double? | A score for the urge result, between 0 and 1, or null. |
EvaluateImpl(TState, TBot, IReadOnlyCollection<IUrge<TState, TBot, TAction>>, in UrgeResult<TState, TBot, TAction>)
Evaluates the consideration given an urge result.
Declaration
protected abstract ConsiderationResult EvaluateImpl(TState state, TBot bot, IReadOnlyCollection<IUrge<TState, TBot, TAction>> urges, in UrgeResult<TState, TBot, TAction> urgeResult)
Parameters
Type | Name | Description |
---|---|---|
TState | state | The state. |
TBot | bot | The bot. |
IReadOnlyCollection<IUrge<TState, TBot, TAction>> | urges | The urges which were active given this state. |
UrgeResult<TState, TBot, TAction> | urgeResult | The urge result to evaluate. |
Returns
Type | Description |
---|---|
ConsiderationResult | A value and maximum value, representing a score for the urge result. The urgency will be penalized as the value approaches the maximum. |
GetCurve(TState, TBot, UrgeResult<TState, TBot, TAction>, out Curve)
Gets the curve parameters.
Declaration
protected virtual bool GetCurve(TState state, TBot bot, UrgeResult<TState, TBot, TAction> urgeResult, out Curve curve)
Parameters
Type | Name | Description |
---|---|---|
TState | state | The state. |
TBot | bot | The bot. |
UrgeResult<TState, TBot, TAction> | urgeResult | The urge result to evaluate. |
Curve | curve | Used to return the curve value. |
Returns
Type | Description |
---|---|
bool | True if the parameters were valid. |
GetParameterNames(string, TState, IUrge<TState, TBot, TAction>)
Gets the parameter names to check when looking up the given parameter.
Declaration
protected virtual IEnumerable<string> GetParameterNames(string parameterName, TState state, IUrge<TState, TBot, TAction> urge)
Parameters
Type | Name | Description |
---|---|---|
string | parameterName | The parameter name (case-insensitive). |
TState | state | The state. |
IUrge<TState, TBot, TAction> | urge | The urge. |
Returns
Type | Description |
---|---|
IEnumerable<string> | An enumeration of parameter names. |
GetSignificance(TState, TBot, in UrgeResult<TState, TBot, TAction>, out double)
Gets the significance parameter.
Declaration
protected virtual bool GetSignificance(TState state, TBot bot, in UrgeResult<TState, TBot, TAction> urgeResult, out double significance)
Parameters
Type | Name | Description |
---|---|---|
TState | state | The state. |
TBot | bot | The bot. |
UrgeResult<TState, TBot, TAction> | urgeResult | The urge result to evaluate. |
double | significance | Used to return the significance value. |
Returns
Type | Description |
---|---|
bool | True if the parameter was valid. |