|
|
|
|
|
|
|
|
|
|
namespace Unity.MLAgents.Extensions.MultiAgent |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// A base class implementation of MultiAgentGroup.
|
|
|
|
/// </summary>
|
|
|
|
public class BaseMultiAgentGroup : IMultiAgentGroup, IDisposable |
|
|
|
{ |
|
|
|
int m_StepCount; |
|
|
|
|
|
|
|
|
|
|
public BaseMultiAgentGroup() |
|
|
|
{ |
|
|
|
Academy.Instance.PostAgentAct += _ManagerStep; |
|
|
|
Academy.Instance.PostAgentAct += _GroupStep; |
|
|
|
Academy.Instance.PostAgentAct -= _ManagerStep; |
|
|
|
Academy.Instance.PostAgentAct -= _GroupStep; |
|
|
|
while (m_Agents.Count > 0) |
|
|
|
{ |
|
|
|
UnregisterAgent(m_Agents[0]); |
|
|
|
|
|
|
void _ManagerStep() |
|
|
|
void _GroupStep() |
|
|
|
{ |
|
|
|
m_StepCount += 1; |
|
|
|
if ((m_StepCount >= m_GroupMaxStep) && (m_GroupMaxStep > 0)) |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get the ID of the MultiAgentGroup.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>
|
|
|
|
/// MultiAgentGroup ID.
|
|
|
|
/// </returns>
|
|
|
|
public int GetId() |
|
|
|
{ |
|
|
|
return m_Id; |
|
|
|