浏览代码

remove GroupMaxStep

/MLA-1734-demo-provider
Ruo-Ping Dong 4 年前
当前提交
7196d44b
共有 2 个文件被更改,包括 9 次插入59 次删除
  1. 65
      com.unity.ml-agents.extensions/Runtime/MultiAgent/BaseMultiAgentGroup.cs
  2. 3
      com.unity.ml-agents/Runtime/Academy.cs

65
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;
}
}
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();
}
}

{
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();
}
void Reset()
{
m_StepCount = 0;
}
}
}

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();
}
}

正在加载...
取消
保存