浏览代码

small cleanup

/develop/centralizedcritic/counterfact
Ruo-Ping Dong 3 年前
当前提交
a52e89bc
共有 5 个文件被更改,包括 8 次插入15 次删除
  1. 6
      Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayCollabAgent.cs
  2. 5
      Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayTeamManager.cs
  3. 3
      com.unity.ml-agents.extensions/Runtime/Teams/BaseTeamManager.cs
  4. 2
      com.unity.ml-agents/Runtime/Agent.cs
  5. 7
      ml-agents/mlagents/trainers/agent_processor.py

6
Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayCollabAgent.cs


public bool isSpotter = true;
int m_Message = 0;
m_HallwaySettings = FindObjectOfType<HallwaySettings>();
m_AgentRb = GetComponent<Rigidbody>();
m_GroundRenderer = ground.GetComponent<Renderer>();
m_GroundMaterial = m_GroundRenderer.material;
base.Initialize();
if (isSpotter)
{
var teamManager = new HallwayTeamManager();

5
Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayTeamManager.cs


using System.Collections.Generic;
using UnityEngine;
using Unity.MLAgents.Actuators;
using Unity.MLAgents.Sensors;
public class HallwayTeamManager : BaseTeamManager

public override void OnAgentDone(Agent agent, Agent.DoneReason doneReason, List<ISensor> sensors)
{
// Possible implementation - save reference to Agent's IPolicy so that we can repeatedly
// call IPolicy.RequestDecision on behalf of the Agent after it's dead
// If so, we'll need dummy sensor impls with the same shape as the originals.
agent.SendDoneToTrainer();
}

3
com.unity.ml-agents.extensions/Runtime/Teams/BaseTeamManager.cs


{
public class BaseTeamManager : ITeamManager
{
string m_Id = System.Guid.NewGuid().ToString();
readonly string m_Id = System.Guid.NewGuid().ToString();
public virtual void RegisterAgent(Agent agent)
{
throw new System.NotImplementedException();

2
com.unity.ml-agents/Runtime/Agent.cs


{
SendDoneToTrainer();
}
ResetSensors();
// We also have to write any to any DemonstationStores so that they get the "done" flag.
foreach (var demoWriter in DemonstrationWriters)

{
// We request a decision so Python knows the Agent is done immediately
m_Brain?.RequestDecision(m_Info, sensors);
ResetSensors();
}
/// <summary>

7
ml-agents/mlagents/trainers/agent_processor.py


self.experience_buffers: Dict[str, List[AgentExperience]] = defaultdict(list)
self.last_experience: Dict[str, AgentExperience] = {}
self.last_step_result: Dict[str, Tuple[DecisionStep, int]] = {}
# current_group_obs is used to collect the last seen obs of all the agents, and assemble the next_collab_obs.
# current_group_obs is used to collect the last seen obs of all the agents in the same group,
# and assemble the next_collab_obs.
self.current_group_obs: Dict[str, Dict[str, List[np.ndarray]]] = defaultdict(
lambda: defaultdict(list)
)

next_obs = step.obs
next_collab_obs = []
for _id, _exp in self.current_group_obs[step.team_manager_id].items():
if _id == global_id:
continue
else:
if _id != global_id:
next_collab_obs.append(_exp)
trajectory = Trajectory(

正在加载...
取消
保存