Tracking depth
Some tracking operations may cost a lot of CPU time. Such operation could be overwhelming for most regular cases. DAI allows you to filter such operation by using of Brain.TrackingDepth
property.
Each AI instance has a personal property so you can track only certain instance you need at the moment avoiding unnecessary garbage in logs or damage to the performance by tracking entire pool of AIs.
In your Doloro.AI.Action
derived scripts or tools handling AI instances just use a following construction to around unnecessary calls:
Brain ai;
...
int _TD_ = (int)ai.TrackingDepth;
if(_TD_ > 0)
{
// Do shallow debug \ tracking operations.
if(_TD_ > 1)
{
// Do high performance operations.
}
}
Shell interaction
Editor-only assemblies can access debug environment and add custom handler and\or data. You can set custom properties separately to each DAIDebugger.PipelineItemDebugShell
instance using its API. That allows to collect and store data for continue analysis or debug.
Following example shows the way to sign up on Doloro.AI.Action
execution callback and make changes according to script.
public InEditorClass()
{
// Subscriping on shell execution envent.
DAIDebugger.PipelineItemDebugShell.Executed +=
PipelineItemDebugShell_onExecuted;
}
~InEditorClass()
{
// Releasing editor from the event.
DAIDebugger.PipelineItemDebugShell.Executed -=
PipelineItemDebugShell_onExecuted;
}
/// <summary>
/// Counts time of calls for the handler for each
`Action` instance for all `Brain`s.
/// </summary>
/// <param name="shell">Executed shell to update.</param>
private void PipelineItemDebugShell_onExecuted(DAIDebugger.PipelineItemDebugShell shell)
{
// Validating parameter with name `PLUG_IN_COUNTER` on the shell instance.
if (!(shell.GetParameter("PLUG_IN_COUNTER") is int counter))
{
// Parameter has not found or has invalid type.
counter = 0;
// Applying parameter by default.
shell.SetParameter(PLUG_IN_COUNTER, counter);
}
// Incrementing parameter.
shell.SetParameter(PLUG_IN_COUNTER, counter + 1);
}