Show / Hide Table of Contents

Class BrainUpdaterBase<TState, TBot, TAction>

Used to run bot brains.

Inheritance
object
BrainUpdaterBase<TState, TBot, TAction>
OvermindUpdater
TestBrainUpdater
TestBrainUpdater
Implements
IBrainUpdater
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.Composition
Assembly: BotBrain.Core.dll
Syntax
public abstract class BrainUpdaterBase<TState, TBot, TAction> : IBrainUpdater where TState : notnull where TBot : IAutomatedBot<TAction>
Type Parameters
Name Description
TState

The game state type.

TBot

The bot type.

TAction

The action type.

Constructors

View Source

BrainUpdaterBase(IBrainSerializer, BrainManager<TState, TBot, TAction>?, ILogger<BrainUpdaterBase<TState, TBot, TAction>>?)

Initializes a new instance of the BrainUpdaterBase<TState, TBot, TAction> class.

Declaration
protected BrainUpdaterBase(IBrainSerializer serializer, BrainManager<TState, TBot, TAction>? brainManager = null, ILogger<BrainUpdaterBase<TState, TBot, TAction>>? logger = null)
Parameters
Type Name Description
IBrainSerializer serializer

The brain serializer.

BrainManager<TState, TBot, TAction> brainManager

The brain manager.

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

The logger to use.

Properties

View Source

Bots

Gets the collection of bots to update.

Declaration
public IReadOnlyCollection<TBot> Bots { get; }
Property Value
Type Description
IReadOnlyCollection<TBot>
View Source

Brain

Gets the default brain to use.

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

BrainManager

Gets the object used to manage and update the brain.

Declaration
protected BrainManager<TState, TBot, TAction> BrainManager { get; }
Property Value
Type Description
BrainManager<TState, TBot, TAction>
View Source

Brains

Gets the collection of bot brains to update.

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

Logger

Gets the logger to use.

Declaration
public ILogger<BrainUpdaterBase<TState, TBot, TAction>> Logger { get; }
Property Value
Type Description
ILogger<BrainUpdaterBase<TState, TBot, TAction>>
View Source

Serializer

Gets the brain serializer.

Declaration
protected IBrainSerializer Serializer { get; }
Property Value
Type Description
IBrainSerializer
View Source

States

Gets the game state objects associated with running bots.

Declaration
public abstract IReadOnlyCollection<TState> States { get; }
Property Value
Type Description
IReadOnlyCollection<TState>
View Source

TickFrequency

Gets or sets the update frequency.

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

Methods

View Source

AddBotAsync(string, IBotBrain?, string?, int, CancellationToken)

Adds a bot to the brain.

Declaration
public abstract 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.

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.

View Source

AddBotAsync(string, object, IBotBrain?, string?, int, CancellationToken)

Adds a bot to the brain.

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

View Source

AddBotAsync(string, TState, IBotBrain?, string?, int, CancellationToken)

Adds a bot to the brain.

Declaration
public virtual Task<TBot> AddBotAsync(string deviceName, TState state, IBotBrain? brain = null, string? botName = null, int playerIndex = 0, CancellationToken token = default)
Parameters
Type Name Description
string deviceName

The device name.

TState 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<TBot>

The bot.

View Source

AddBrain(IBotBrain?)

Adds a brain instance.

Declaration
public virtual bool AddBrain(IBotBrain? brain)
Parameters
Type Name Description
IBotBrain brain

The brain.

Returns
Type Description
bool

True if the brain was added successfully.

View Source

AddBrain(string)

Loads a brain file and adds the instance.

Declaration
public virtual 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.

View Source

ClearBrains()

Removes all brain instances.

Declaration
public void ClearBrains()
View Source

CreateBotAsync(string, TState, string, int)

Creates a bot.

Declaration
protected abstract Task<TBot> CreateBotAsync(string deviceName, TState state, string botName, int playerIndex)
Parameters
Type Name Description
string deviceName

The device name.

TState state

The game state.

string botName

The bot's name.

int playerIndex

The bot's player index.

Returns
Type Description
Task<TBot>

The bot.

View Source

RemoveBotAsync(IAutomatedBot, IBotBrain?)

Removes a bot from the brain.

Declaration
public virtual 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.

View Source

RemoveBrain(IBotBrain)

Removes a brain.

Declaration
public void RemoveBrain(IBotBrain brain)
Parameters
Type Name Description
IBotBrain brain

The brain.

View Source

Run(CancellationToken)

Runs each brain.

Declaration
public Task Run(CancellationToken token)
Parameters
Type Name Description
CancellationToken token

The cancellation token.

Returns
Type Description
Task

A task which completes when the brains are stopped.

View Source

RunOnce()

Runs each brain once, if it is not currently updating.

Declaration
public void RunOnce()
Remarks

This completes as soon as the brains are started.

View Source

SetBrain(IBotBrain)

Removes all brain instances, and then adds the given brain instance.

Declaration
public virtual bool SetBrain(IBotBrain brain)
Parameters
Type Name Description
IBotBrain brain

The brain.

Returns
Type Description
bool

True if the brain was added successfully.

View Source

SetBrain(string)

Removes all brain instances, and then loads a brain file and adds the instance.

Declaration
public virtual 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.

Implements

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