Show / Hide Table of Contents

Class UrgeList<TState, TBot, TAction>

A wrapper class for a list of urges, which can be used as a single urge.

Inheritance
object
UrgeBase<TState, TBot, TAction>
UrgeList<TState, TBot, TAction>
BotBrain<TState, TBot, TAction>
Implements
IUrgeList<TState, TBot, TAction>
IUrgeList
IUrge<TState, TBot, TAction>
IUrge
IEquatable<IUrge>
Inherited Members
UrgeBase<TState, TBot, TAction>.NoUrgeName
UrgeBase<TState, TBot, TAction>.Logger
UrgeBase<TState, TBot, TAction>.Name
UrgeBase<TState, TBot, TAction>.Type
UrgeBase<TState, TBot, TAction>.IsExclusive
UrgeBase<TState, TBot, TAction>.ToString()
UrgeBase<TState, TBot, TAction>.Equals(IUrge)
UrgeBase<TState, TBot, TAction>.Equals(object)
UrgeBase<TState, TBot, TAction>.GetHashCode()
UrgeBase<TState, TBot, TAction>.Run(TState, TBot)
UrgeBase<TState, TBot, TAction>.GetParameter<T>(TBot, string)
UrgeBase<TState, TBot, TAction>.GetParameter<T>(TBot, IEnumerable<string>)
UrgeBase<TState, TBot, TAction>.TryGetParameter<T>(TBot, IEnumerable<string>, out T)
UrgeBase<TState, TBot, TAction>.TryGetParameter<T>(TBot, string, out T)
UrgeBase<TState, TBot, TAction>.GetParameterNames(string)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Microsoft.XboxStudios.BotBrain
Assembly: BotBrain.Core.dll
Syntax
[DataContract]
public class UrgeList<TState, TBot, TAction> : UrgeBase<TState, TBot, TAction>, IUrgeList<TState, TBot, TAction>, IUrgeList, 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.

Remarks

When used as a single urge, the exclusive urges are run and the first to return any action is used. Otherwise, the action with the highest urgency is used.

Constructors

View Source

UrgeList(string?, ILogger<UrgeList<TState, TBot, TAction>>?)

A wrapper class for a list of urges, which can be used as a single urge.

Declaration
public UrgeList(string? name = null, ILogger<UrgeList<TState, TBot, TAction>>? logger = null)
Parameters
Type Name Description
string name

The urge name.

ILogger<UrgeList<TState, TBot, TAction>> logger

The logger to use.

Remarks

When used as a single urge, the exclusive urges are run and the first to return any action is used. Otherwise, the action with the highest urgency is used.

Properties

View Source

ExclusiveUrges

Gets an enumerable of urges which are exclusive.

Declaration
protected virtual IEnumerable<IUrge<TState, TBot, TAction>> ExclusiveUrges { get; }
Property Value
Type Description
IEnumerable<IUrge<TState, TBot, TAction>>
View Source

ParallelUrges

Gets an enumerable of urges which are not exclusive, and can be evaluated in parallel.

Declaration
protected virtual IEnumerable<IUrge<TState, TBot, TAction>> ParallelUrges { get; }
Property Value
Type Description
IEnumerable<IUrge<TState, TBot, TAction>>
View Source

Urges

Gets the collection of urges.

Declaration
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public ICollection<IUrge<TState, TBot, TAction>> Urges { get; }
Property Value
Type Description
ICollection<IUrge<TState, TBot, TAction>>

Methods

View Source

AddUrge(IUrge)

Adds an urge to the list.

Declaration
public void AddUrge(IUrge urge)
Parameters
Type Name Description
IUrge urge

The urge.

View Source

Equals(IUrge?)

Determines whether the specified urge list is equal to this one.

Declaration
public override bool Equals(IUrge? other)
Parameters
Type Name Description
IUrge other

The urge list to compare to.

Returns
Type Description
bool

True if the urge lists are equal.

Overrides
UrgeBase<TState, TBot, TAction>.Equals(IUrge)
View Source

ExclusiveUrgesFor(TBot, TState)

Gets the urges which are exclusive for the given bot.

Declaration
protected virtual IEnumerable<IUrge<TState, TBot, TAction>> ExclusiveUrgesFor(TBot bot, TState state)
Parameters
Type Name Description
TBot bot

The bot.

TState state

The game state.

Returns
Type Description
IEnumerable<IUrge<TState, TBot, TAction>>

An enumerable of urges.

View Source

HandleUrgeException(IUrge<TState, TBot, TAction>, TBot, Exception)

Handles an urge exception.

Declaration
protected virtual void HandleUrgeException(IUrge<TState, TBot, TAction> urge, TBot bot, Exception e)
Parameters
Type Name Description
IUrge<TState, TBot, TAction> urge

The urge that threw the exception.

TBot bot

The corresponding bot.

Exception e

The exception.

View Source

ParallelUrgesFor(TBot, TState)

Gets the urges which are not exclusive for the given bot, and can be evaluated in parallel.

Declaration
protected virtual IEnumerable<IUrge<TState, TBot, TAction>> ParallelUrgesFor(TBot bot, TState state)
Parameters
Type Name Description
TBot bot

The bot.

TState state

The game state.

Returns
Type Description
IEnumerable<IUrge<TState, TBot, TAction>>

An enumerable of urges.

View Source

RemoveUrge(IUrge)

Removes an urge from the list.

Declaration
public void RemoveUrge(IUrge urge)
Parameters
Type Name Description
IUrge urge

The urge.

View Source

Run(TState, TBot)

Chooses an action and urgency of that action for the given bot and state.

Declaration
public override 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>>>

A task returning an enumerable of weighted bot actions.

Overrides
UrgeBase<TState, TBot, TAction>.Run(TState, TBot)
View Source

RunUrge(TState, TBot, IUrge<TState, TBot, TAction>)

Gets the weighted bot actions for the given bot, state, and urge.

Declaration
protected virtual Task<IEnumerable<IRecommendedAction<TAction>>> RunUrge(TState state, TBot bot, IUrge<TState, TBot, TAction> urge)
Parameters
Type Name Description
TState state

The game state.

TBot bot

The bot to control.

IUrge<TState, TBot, TAction> urge

The urge.

Returns
Type Description
Task<IEnumerable<IRecommendedAction<TAction>>>

A task returning an enumerable of weighted bot actions.

View Source

RunUrges(TState, TBot)

Gets the urge results for the given bot and state.

Declaration
protected virtual Task<IEnumerable<UrgeResult<TState, TBot, TAction>>> RunUrges(TState state, TBot bot)
Parameters
Type Name Description
TState state

The game state.

TBot bot

The bot to control.

Returns
Type Description
Task<IEnumerable<UrgeResult<TState, TBot, TAction>>>

A task returning an enumerable of urge results.

Implements

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