Show / Hide Table of Contents

Class UrgeBase<TState, TBot, TAction>

A base class for an urge.

Inheritance
object
UrgeBase<TState, TBot, TAction>
OvermindUrgeBase
LaunchGame
SimpleUrge
TestUrgeBase
FakeUrge
UrgeList<TState, TBot, TAction>
Implements
IUrge<TState, TBot, TAction>
IUrge
IEquatable<IUrge>
Inherited Members
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
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 Source

UrgeBase(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 Source

NoUrgeName

The name for the lack of an urge.

Declaration
protected const string NoUrgeName = "None"
Field Value
Type Description
string

Properties

View Source

IsExclusive

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
View Source

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>>
View Source

Name

Gets or sets the name of the urge.

Declaration
[DataMember]
public string Name { get; set; }
Property Value
Type Description
string
View Source

Type

Gets the type name of the urge.

Declaration
[DataMember]
public string Type { get; }
Property Value
Type Description
string

Methods

View Source

Equals(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.

View Source

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
object.Equals(object)
View Source

GetHashCode()

Serves as the default hash function.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for the current object.

Overrides
object.GetHashCode()
View Source

GetParameterNames(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.

View Source

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, , or implement IConvertible.

View Source

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, , or implement IConvertible.

View Source

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.

View Source

ToString()

Returns the string representation of the urge.

Declaration
public override string ToString()
Returns
Type Description
string

The string representation of the urge.

Overrides
object.ToString()
View Source

TryGetParameter<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, , or implement IConvertible.

View Source

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, , or implement IConvertible.

Implements

IUrge<TState, TBot, TAction>
IUrge
IEquatable<T>
  • View Source
In this article
Back to top Generated by DocFX