浏览代码

remove GroupMaxStep

/develop/superpush/int
Ruo-Ping Dong 3 年前
当前提交
424473a8
共有 2 个文件被更改,包括 9 次插入65 次删除
  1. 71
      com.unity.ml-agents.extensions/Runtime/MultiAgent/BaseMultiAgentGroup.cs
  2. 3
      com.unity.ml-agents/Runtime/Academy.cs

71
com.unity.ml-agents.extensions/Runtime/MultiAgent/BaseMultiAgentGroup.cs


List<Agent> m_Agents = new List<Agent> { };
public BaseMultiAgentGroup()
{
Academy.Instance.PostAgentAct += _GroupStep;
}
Academy.Instance.PostAgentAct -= _GroupStep;
while (m_Agents.Count > 0)
{
UnregisterAgent(m_Agents[0]);

void _GroupStep()
{
m_StepCount += 1;
if ((m_StepCount >= m_GroupMaxStep) && (m_GroupMaxStep > 0))
{
foreach (var agent in m_Agents)
{
if (agent.enabled)
{
agent.EpisodeInterrupted();
}
}
Reset();
}
}
/// <summary>
/// Register the agent to the MultiAgentGroup.
/// Registered agents will be able to receive group rewards from the MultiAgentGroup

{
foreach (var agent in m_Agents)
{
if (agent.enabled)
{
agent.AddGroupReward(reward);
}
agent.AddGroupReward(reward);
}
}

{
foreach (var agent in m_Agents)
{
if (agent.enabled)
{
agent.SetGroupReward(reward);
}
agent.SetGroupReward(reward);
}
}

/// <returns>
/// Current step count.
/// </returns>
public int StepCount
public void EndGroupEpisode()
get { return m_StepCount; }
}
public int GroupMaxStep
{
get { return m_GroupMaxStep; }
}
public void SetGroupMaxStep(int maxStep)
{
m_GroupMaxStep = maxStep;
foreach (var agent in m_Agents)
{
agent.EndEpisode();
}
public void EndGroupEpisode()
public void GroupEpisodeInterrupted()
if (agent.enabled)
{
agent.EndEpisode();
}
agent.EpisodeInterrupted();
Reset();
}
public virtual void OnGroupEpisodeBegin()
{
}
void Reset()
{
m_StepCount = 0;
OnGroupEpisodeBegin();
}
}
}

3
com.unity.ml-agents/Runtime/Academy.cs


// This will mark the Agent as Done if it has reached its maxSteps.
internal event Action AgentIncrementStep;
internal event Action PostAgentAct;
/// <summary>
/// Signals to all of the <see cref="Agent"/>s that their step is about to begin.

{
AgentAct?.Invoke();
}
PostAgentAct?.Invoke();
}
}

正在加载...
取消
保存