浏览代码

Upgrade to newest group manager

/develop/superpush/int
Ervin Teng 4 年前
当前提交
3c78e47d
共有 5 个文件被更改,包括 7 次插入13 次删除
  1. 4
      Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayCollabAgent.cs
  2. 11
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushBlockEnvController.cs
  3. 2
      com.unity.ml-agents/Runtime/SimpleMultiAgentGroup.cs
  4. 3
      com.unity.ml-agents.extensions/Runtime/MultiAgent.meta

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


using UnityEngine;
using Unity.MLAgents.Extensions.MultiAgent;
using Unity.MLAgents;
using Unity.MLAgents.Actuators;
using Unity.MLAgents.Sensors;

base.Initialize();
if (isSpotter)
{
var teamManager = new BaseMultiAgentGroup();
var teamManager = new SimpleMultiAgentGroup();
teamManager.RegisterAgent(this);
teamManager.RegisterAgent(teammate);
}

11
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushBlockEnvController.cs


using System.Collections;
using System.Collections.Generic;
using Unity.MLAgents.Extensions.MultiAgent;
using Unity.MLAgents;
using UnityEngine;
public class PushBlockEnvController : MonoBehaviour

private int m_NumberOfRemainingBlocks;
private BaseMultiAgentGroup m_AgentGroup;
private SimpleMultiAgentGroup m_AgentGroup;
private int m_ResetTimer;

item.Rb = item.T.GetComponent<Rigidbody>();
}
// Initialize TeamManager
m_AgentGroup = new BaseMultiAgentGroup();
m_AgentGroup = new SimpleMultiAgentGroup();
foreach (var item in AgentsList)
{
item.StartingPos = item.Agent.transform.position;

col.gameObject.SetActive(false);
//Give Agent Rewards
foreach (var item in AgentsList)
{
item.Agent.AddReward(score);
}
m_AgentGroup.AddGroupReward(score);
// Swap ground material for a bit to indicate we scored.
StartCoroutine(GoalScoredSwapGroundMaterial(m_PushBlockSettings.goalScoredMaterial, 0.5f));

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


/// <summary>
/// A basic class implementation of MultiAgentGroup.
/// </summary>
internal class SimpleMultiAgentGroup : IMultiAgentGroup, IDisposable
public class SimpleMultiAgentGroup : IMultiAgentGroup, IDisposable
{
readonly int m_Id = MultiAgentGroupIdCounter.GetGroupId();
HashSet<Agent> m_Agents = new HashSet<Agent>();

3
com.unity.ml-agents.extensions/Runtime/MultiAgent.meta


fileFormatVersion: 2
guid: 77124df6c18c4f669052016b3116147e
timeCreated: 1610064454
正在加载...
取消
保存