Class UrgeBase<TState, TBot, TAction>
A base class for an urge.
Inheritance
Inherited Members
Namespace: Microsoft.XboxStudios.BotBrain
Assembly: BotBrain.Core.dll
Syntax
[DataContract]
public abstract class UrgeBase<TState, TBot, TAction> : IUrge<TState, TBot, TAction>, IUrge, IEquatable<IUrge?> where TBot : IAutomatedBot<TAction>
Type Parameters
Name | Description |
---|---|
TState | The game state type. |
TBot | The bot type. |
TAction | The action type. |
Constructors
View SourceUrgeBase(string?, ILogger<UrgeBase<TState, TBot, TAction>>?)
Initializes a new instance of the UrgeBase<TState, TBot, TAction> class.
Declaration
protected UrgeBase(string? name = null, ILogger<UrgeBase<TState, TBot, TAction>>? logger = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | The urge name. |
ILogger<UrgeBase<TState, TBot, TAction>> | logger | The logger to use. |
Fields
View SourceNoUrgeName
The name for the lack of an urge.
Declaration
protected const string NoUrgeName = "None"
Field Value
Type | Description |
---|---|
string |
Properties
View SourceIsExclusive
Gets a value indicating whether or not the urge is exclusive. If it has recommendations, then it will preempt other urges.
Declaration
public virtual bool IsExclusive { get; }
Property Value
Type | Description |
---|---|
bool |
Logger
Gets the logger to use.
Declaration
[IgnoreDataMember]
public ILogger<UrgeBase<TState, TBot, TAction>> Logger { get; }
Property Value
Type | Description |
---|---|
ILogger<UrgeBase<TState, TBot, TAction>> |
Name
Gets or sets the name of the urge.
Declaration
[DataMember]
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Type
Gets the type name of the urge.
Declaration
[DataMember]
public string Type { get; }
Property Value
Type | Description |
---|---|
string |
Methods
View SourceEquals(IUrge?)
Determines whether the specified urge is equal to this one.
Declaration
public virtual bool Equals(IUrge? other)
Parameters
Type | Name | Description |
---|---|---|
IUrge | other | The urge to compare to. |
Returns
Type | Description |
---|---|
bool | True if the urges are equal. |
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
View SourceGetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
View SourceGetParameterNames(string)
Gets the parameter names to check when looking up the given parameter.
Declaration
protected virtual IEnumerable<string> GetParameterNames(string parameterName)
Parameters
Type | Name | Description |
---|---|---|
string | parameterName | The parameter name (case-insensitive). |
Returns
Type | Description |
---|---|
IEnumerable<string> | An enumeration of parameter names. |
GetParameter<T>(TBot, IEnumerable<string>)
Get the value of a parameter for the given bot.
Declaration
protected T GetParameter<T>(TBot bot, IEnumerable<string> parameterNames)
Parameters
Type | Name | Description |
---|---|---|
TBot | bot | The bot. |
IEnumerable<string> | parameterNames | The parameter names (case-insensitive). |
Returns
Type | Description |
---|---|
T | The parameter value, if it was found. |
Type Parameters
Name | Description |
---|---|
T | The expected type of the parameter value, which must be a TimeSpan, |
GetParameter<T>(TBot, string)
Get the value of a parameter for the given bot.
Declaration
protected T GetParameter<T>(TBot bot, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
TBot | bot | The bot. |
string | parameterName | The parameter name (case-insensitive). |
Returns
Type | Description |
---|---|
T | The parameter value, if it was found. |
Type Parameters
Name | Description |
---|---|
T | The expected type of the parameter value, which must be a TimeSpan, |
Run(TState, TBot)
Chooses an action and urgency of that action for the given bot and state.
Declaration
public abstract Task<IEnumerable<IRecommendedAction<TAction>>> Run(TState state, TBot bot)
Parameters
Type | Name | Description |
---|---|---|
TState | state | The game state. |
TBot | bot | The bot to control. |
Returns
Type | Description |
---|---|
Task<IEnumerable<IRecommendedAction<TAction>>> | An enumerable of weighted bot actions. |
ToString()
Returns the string representation of the urge.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string representation of the urge. |
Overrides
View SourceTryGetParameter<T>(TBot, IEnumerable<string>, out T)
Tries to get the value of a parameter for the given bot.
Declaration
protected bool TryGetParameter<T>(TBot bot, IEnumerable<string> parameterNames, out T result)
Parameters
Type | Name | Description |
---|---|---|
TBot | bot | The bot. |
IEnumerable<string> | parameterNames | The parameter names (case-insensitive). |
T | result | The parameter value, if it was found. |
Returns
Type | Description |
---|---|
bool | Whether a parameter value was found. |
Type Parameters
Name | Description |
---|---|
T | The expected type of the parameter value, which must be a TimeSpan, |
TryGetParameter<T>(TBot, string, out T)
Tries to get the value of a parameter for the given bot.
Declaration
protected bool TryGetParameter<T>(TBot bot, string parameterName, out T result)
Parameters
Type | Name | Description |
---|---|---|
TBot | bot | The bot. |
string | parameterName | The parameter name (case-insensitive). |
T | result | The parameter value, if it was found. |
Returns
Type | Description |
---|---|
bool | Whether a parameter value was found. |
Type Parameters
Name | Description |
---|---|
T | The expected type of the parameter value, which must be a TimeSpan, |