Class BrainManager<TState, TBot, TAction>
A helper class for updating a set of bot brains on a regular interval.
Inherited Members
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 SourceBrains
Gets the set of bot brains.
Declaration
public ConcurrentSet<IBotBrain<TState, TBot, TAction>> Brains { get; }
Property Value
| Type | Description |
|---|---|
| ConcurrentSet<IBotBrain<TState, TBot, TAction>> |
Tick
Gets or sets the update frequency.
Declaration
public TimeSpan Tick { get; set; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Methods
View SourceExecuteUpdate(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. |
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. |
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. |
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. |
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. |