Interface IBrainUpdater
An interface used to run bot brains.
Namespace: Microsoft.XboxStudios.BotBrain.Composition
Assembly: BotBrain.Abstractions.dll
Syntax
public interface IBrainUpdater
  Properties
View SourceBots
Gets the collection of bots to update.
Declaration
IReadOnlyCollection<IAutomatedBot> Bots { get; }
  Property Value
| Type | Description | 
|---|---|
| IReadOnlyCollection<IAutomatedBot> | 
Brain
Gets the default brain to use.
Declaration
IBotBrain? Brain { get; }
  Property Value
| Type | Description | 
|---|---|
| IBotBrain | 
Brains
Gets the collection of bot brains to update.
Declaration
IReadOnlyCollection<IBotBrain> Brains { get; }
  Property Value
| Type | Description | 
|---|---|
| IReadOnlyCollection<IBotBrain> | 
TickFrequency
Gets or sets the update frequency.
Declaration
TimeSpan TickFrequency { get; set; }
  Property Value
| Type | Description | 
|---|---|
| TimeSpan | 
Methods
View SourceAddBotAsync(string, IBotBrain?, string?, int, CancellationToken)
Adds a bot to the brain.
Declaration
Task<IAutomatedBot?> AddBotAsync(string deviceName, IBotBrain? brain = null, string? botName = null, int playerIndex = 0, CancellationToken token = default)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | deviceName | The device name or connection string.  | 
      
| IBotBrain | brain | The brain to use.  | 
      
| string | botName | The bot's name.  | 
      
| int | playerIndex | The bot's player index.  | 
      
| CancellationToken | token | The cancellation token.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<IAutomatedBot> | The bot.  | 
      
AddBotAsync(string, object, IBotBrain?, string?, int, CancellationToken)
Adds a bot to the brain.
Declaration
Task<IAutomatedBot> AddBotAsync(string deviceName, object state, IBotBrain? brain = null, string? botName = null, int playerIndex = 0, CancellationToken token = default)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | deviceName | The device name.  | 
      
| object | state | The game state.  | 
      
| IBotBrain | brain | The brain to use.  | 
      
| string | botName | The bot's name.  | 
      
| int | playerIndex | The bot's player index.  | 
      
| CancellationToken | token | The cancellation token.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<IAutomatedBot> | The bot.  | 
      
AddBrain(IBotBrain?)
Adds a brain instance.
Declaration
bool AddBrain(IBotBrain? brain)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IBotBrain | brain | The brain.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | True if the brain was added successfully.  | 
      
AddBrain(string)
Loads a brain file and adds the instance.
Declaration
bool AddBrain(string name)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | name | The name of the brain.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | True if the brain was loaded and added.  | 
      
ClearBrains()
Removes all brain instances.
Declaration
void ClearBrains()
  RemoveBotAsync(IAutomatedBot, IBotBrain?)
Removes a bot from the brain.
Declaration
Task RemoveBotAsync(IAutomatedBot bot, IBotBrain? brain = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IAutomatedBot | bot | The bot.  | 
      
| IBotBrain | brain | The brain to use.  | 
      
Returns
| Type | Description | 
|---|---|
| Task | A task.  | 
      
RemoveBrain(IBotBrain)
Removes a brain.
Declaration
void RemoveBrain(IBotBrain brain)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IBotBrain | brain | The brain.  | 
      
Run(CancellationToken)
Runs each brain.
Declaration
Task Run(CancellationToken token = default)
  Parameters
| Type | Name | Description | 
|---|---|---|
| CancellationToken | token | The cancellation token.  | 
      
Returns
| Type | Description | 
|---|---|
| Task | A task which completes when the brains are stopped.  | 
      
RunOnce()
Runs each brain once, if it is not currently updating.
Declaration
void RunOnce()
  Remarks
This completes as soon as the brains are started.
SetBrain(IBotBrain)
Removes all brain instances, and then adds the given brain instance.
Declaration
bool SetBrain(IBotBrain brain)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IBotBrain | brain | The brain.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | True if the brain was added successfully.  | 
      
SetBrain(string)
Removes all brain instances, and then loads a brain file and adds the instance.
Declaration
bool SetBrain(string name)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | name | The name of the brain.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | True if the brain was loaded and added.  |