Show / Hide Table of Contents

Class BrainManager<TState, TBot, TAction>

A helper class for updating a set of bot brains on a regular interval.

Inheritance
object
BrainManager<TState, TBot, TAction>
OvermindManager
Inherited Members
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
public class BrainManager<TState, TBot, TAction> where TState : notnull where TBot : IAutomatedBot<TAction>
Type Parameters
Name Description
TState

The game state type.

TBot

The bot type.

TAction

The action type.

Properties

View Source

Brains

Gets the set of bot brains.

Declaration
public ConcurrentSet<IBotBrain<TState, TBot, TAction>> Brains { get; }
Property Value
Type Description
ConcurrentSet<IBotBrain<TState, TBot, TAction>>
View Source

Tick

Gets or sets the update frequency.

Declaration
public TimeSpan Tick { get; set; }
Property Value
Type Description
TimeSpan

Methods

View Source

ExecuteUpdate(TState)

Executes all the bot brains' update call.

Declaration
protected virtual Task ExecuteUpdate(TState state)
Parameters
Type Name Description
TState state

The state to pass to the update.

Returns
Type Description
Task

A task that completes when all the updates complete.

View Source

GameLoop(IReadOnlyCollection<TState>, CancellationToken)

Executes an operation to regularly update the bot brains with the given game states.

Declaration
public virtual void GameLoop(IReadOnlyCollection<TState> states, CancellationToken token)
Parameters
Type Name Description
IReadOnlyCollection<TState> states

The game states.

CancellationToken token

The cancellation token used to stop the operation.

View Source

GameLoopAsync(IReadOnlyCollection<TState>, CancellationToken)

Starts a task to regularly update the bot brains with the given game states.

Declaration
public virtual Task GameLoopAsync(IReadOnlyCollection<TState> states, CancellationToken token)
Parameters
Type Name Description
IReadOnlyCollection<TState> states

The game states.

CancellationToken token

The cancellation token used to stop the operation.

Returns
Type Description
Task

A task that completes when the token is canceled.

View Source

GameLoopAsync(Func<Task>, CancellationToken)

Starts a task to regularly update the bot brains with the given game states.

Declaration
protected Task GameLoopAsync(Func<Task> action, CancellationToken token)
Parameters
Type Name Description
Func<Task> action

The action performed on every loop.

CancellationToken token

The cancellation token.

Returns
Type Description
Task

A task that completes when the token is canceled.

View Source

Update(IEnumerable<TState>)

Updates the collection of bot brains with the given game states.

Declaration
public void Update(IEnumerable<TState> states)
Parameters
Type Name Description
IEnumerable<TState> states

The game states.

  • View Source
In this article
Back to top Generated by DocFX