Class OvermindUpdater
The overmind bot brain updater.
Inherited Members
Namespace: Microsoft.XboxStudios.BotBrain.Overmind
Assembly: BotBrain.Overmind.dll
Syntax
public class OvermindUpdater : BrainUpdaterBase<OvermindState, OvermindBot, OvermindAction>, IOvermindUpdater, IBrainUpdater
Constructors
View SourceOvermindUpdater(IDeviceProvider, IBrainHelper, IOvermindSerializer, IServiceProvider, OvermindManager?, ILogger<OvermindUpdater>?)
Initializes a new instance of the OvermindUpdater class.
Declaration
public OvermindUpdater(IDeviceProvider deviceProvider, IBrainHelper brainHelper, IOvermindSerializer serializer, IServiceProvider services, OvermindManager? brainManager = null, ILogger<OvermindUpdater>? logger = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IDeviceProvider | deviceProvider | The device provider. |
| IBrainHelper | brainHelper | The brain helper to use to run title-specific bots within overmind. |
| IOvermindSerializer | serializer | The brain serializer. |
| IServiceProvider | services | The service provider used for construction. |
| OvermindManager | brainManager | The brain manager. |
| ILogger<OvermindUpdater> | logger | The logger to use. |
Properties
View SourceMaxTickFrequency
Gets or sets the maximum overmind tick frequency, when only one bot is running. When more than one bot is running, this value will be divided by the number of bots.
Declaration
public TimeSpan MaxTickFrequency { get; set; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
Serializer
Gets the overmind serializer.
Declaration
protected IOvermindSerializer Serializer { get; }
Property Value
| Type | Description |
|---|---|
| IOvermindSerializer |
Settings
Gets the overmind settings.
Declaration
public OvermindSettings Settings { get; }
Property Value
| Type | Description |
|---|---|
| OvermindSettings |
State
Gets the overmind state.
Declaration
public OvermindState State { get; }
Property Value
| Type | Description |
|---|---|
| OvermindState |
States
Gets the game state objects associated with running bots.
Declaration
public override IReadOnlyCollection<OvermindState> States { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyCollection<OvermindState> |
Overrides
SubBrainHelper
Gets the brain helper to use to run title-specific bots within overmind.
Declaration
protected IBrainHelper SubBrainHelper { get; }
Property Value
| Type | Description |
|---|---|
| IBrainHelper |
Methods
View SourceAddBotAsync(string, IBotBrain?, string?, int, CancellationToken)
Adds a bot to the brain.
Declaration
public override 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. |
Overrides
View SourceAddBrain(IBotBrain?)
Adds a brain instance.
Declaration
public override bool AddBrain(IBotBrain? brain)
Parameters
| Type | Name | Description |
|---|---|---|
| IBotBrain | brain | The brain. |
Returns
| Type | Description |
|---|---|
| bool | True if the brain was added successfully. |
Overrides
CreateBotAsync(string, OvermindState, string, int)
Creates a bot.
Declaration
protected override Task<OvermindBot> CreateBotAsync(string deviceName, OvermindState state, string botName, int playerIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | deviceName | The device name. |
| OvermindState | state | The game state. |
| string | botName | The bot's name. |
| int | playerIndex | The bot's player index. |
Returns
| Type | Description |
|---|---|
| Task<OvermindBot> | The bot. |
Overrides
View SourceCreateState()
Used to populate the title-specific overmind state.
Declaration
protected virtual OvermindState CreateState()
Returns
| Type | Description |
|---|---|
| OvermindState | An overmind state object. |
CreateState<TState>(params object[]?)
Used to create a title-specific overmind state.
Declaration
protected TState CreateState<TState>(params object[]? parameters) where TState : OvermindState
Parameters
| Type | Name | Description |
|---|---|---|
| object[] | parameters | The parameters, if any. If null, the sub-brain helper is passed. |
Returns
| Type | Description |
|---|---|
| TState | A state object. |
Type Parameters
| Name | Description |
|---|---|
| TState | The state type |
FlagUnfinishedScenarios()
Flags the unfinished scenarios as failed.
Declaration
public void FlagUnfinishedScenarios()
OnEventReceived(object?, OvermindEventArgs)
Called when the overmind state receives an event.
Declaration
protected virtual void OnEventReceived(object? sender, OvermindEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | The event publisher. |
| OvermindEventArgs | e | The event. |
OnSubbotEventReceived(object?, OvermindBotEventArgs)
Called when the overmind state receives a sub-bot event.
Declaration
protected virtual void OnSubbotEventReceived(object? sender, OvermindBotEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | The event publisher. |
| OvermindBotEventArgs | e | The event. |
RecalculateTickRate()
Re-calculates the current overmind tick rate.
Declaration
protected virtual void RecalculateTickRate()
RemoveBotAsync(IAutomatedBot, IBotBrain?)
Removes a bot from the brain.
Declaration
public override 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. |
Overrides
ResetState(Action<OvermindEventArgs>?)
Resets the overmind state including returning scenarios with their initial settings.
Declaration
public void ResetState(Action<OvermindEventArgs>? eventSubscriber = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<OvermindEventArgs> | eventSubscriber | An optional subscriber for overmind events. |