浏览代码

add manager to hallway

/develop/centralizedcritic/counterfact
Ruo-Ping Dong 4 年前
当前提交
ab88f919
共有 3 个文件被更改,包括 56 次插入1 次删除
  1. 15
      Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayCollabAgent.cs
  2. 31
      Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayTeamManager.cs
  3. 11
      Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayTeamManager.cs.meta

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


public bool isSpotter = true;
int m_Message = 0;
public override void Initialize()
{
m_HallwaySettings = FindObjectOfType<HallwaySettings>();
m_AgentRb = GetComponent<Rigidbody>();
m_GroundRenderer = ground.GetComponent<Renderer>();
m_GroundMaterial = m_GroundRenderer.material;
if (isSpotter)
{
var teamManager = new HallwayTeamManager();
SetTeamManager(teamManager);
teammate.SetTeamManager(teamManager);
}
}
public override void OnEpisodeBegin()
{
m_Message = -1;

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


using System.Collections.Generic;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Extensions.Teams;
using Unity.MLAgents.Actuators;
using Unity.MLAgents.Sensors;
public class HallwayTeamManager : BaseTeamManager
{
List<Agent> m_AgentList = new List<Agent> { };
public override void RegisterAgent(Agent agent)
{
m_AgentList.Add(agent);
Debug.Log($"Total # of agents registered for team manager {GetId()}: {m_AgentList.Count}");
}
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();
}
public override void AddTeamReward(float reward)
{
}
}

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


fileFormatVersion: 2
guid: 8b67166b7adef46febf8b570f92c400d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存