Class UrgeList<TState, TBot, TAction>
A wrapper class for a list of urges, which can be used as a single urge.
Inherited Members
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 SourceUrgeList(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 SourceExclusiveUrges
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>> |
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>> |
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 SourceAddUrge(IUrge)
Adds an urge to the list.
Declaration
public void AddUrge(IUrge urge)
Parameters
| Type | Name | Description |
|---|---|---|
| IUrge | urge | The urge. |
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
View SourceExclusiveUrgesFor(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. |
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. |
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. |
RemoveUrge(IUrge)
Removes an urge from the list.
Declaration
public void RemoveUrge(IUrge urge)
Parameters
| Type | Name | Description |
|---|---|---|
| IUrge | urge | The urge. |
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
View SourceRunUrge(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. |
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. |