Skip to content

Commit

Permalink
more team -> group
Browse files Browse the repository at this point in the history
  • Loading branch information
dongruoping committed Feb 11, 2021
1 parent 8b9d662 commit 3fb14b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Unity.MLAgents.Extensions.MultiAgent
{
/// <summary>
/// A base class implementation of MultiAgentGroup.
/// </summary>
public class BaseMultiAgentGroup : IMultiAgentGroup, IDisposable
{
int m_StepCount;
Expand All @@ -13,19 +16,19 @@ public class BaseMultiAgentGroup : IMultiAgentGroup, IDisposable

public BaseMultiAgentGroup()
{
Academy.Instance.PostAgentAct += _ManagerStep;
Academy.Instance.PostAgentAct += _GroupStep;
}

public void Dispose()
{
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))
Expand Down Expand Up @@ -68,12 +71,6 @@ public virtual void UnregisterAgent(Agent agent)
}
}

/// <summary>
/// Get the ID of the MultiAgentGroup.
/// </summary>
/// <returns>
/// MultiAgentGroup ID.
/// </returns>
public int GetId()
{
return m_Id;
Expand Down
15 changes: 15 additions & 0 deletions com.unity.ml-agents/Runtime/IMultiAgentGroup.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
namespace Unity.MLAgents
{
/// <summary>
/// MultiAgentGroup interface for grouping agents to support multi-agent training.
/// </summary>
public interface IMultiAgentGroup
{
/// <summary>
/// Get the ID of MultiAgentGroup.
/// </summary>
/// <returns>
/// MultiAgentGroup ID.
/// </returns>
int GetId();

/// <summary>
/// Register agent to the MultiAgentGroup.
/// </summary>
void RegisterAgent(Agent agent);

/// <summary>
/// UnRegister agent from the MultiAgentGroup.
/// </summary>
void UnregisterAgent(Agent agent);
}
}

0 comments on commit 3fb14b9

Please sign in to comment.