浏览代码

baseline with teammanager as ID

/develop/teammanager
Ruo-Ping Dong 4 年前
当前提交
53f6ce08
共有 5 个文件被更改,包括 1040 次插入1040 次删除
  1. 998
      Project/Assets/ML-Agents/Examples/PushBlock/Scenes/2ZombieVs3AgentsPushBlock.unity
  2. 69
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/ZombiePushBlockDeathEnvController.cs
  3. 5
      com.unity.ml-agents.extensions/Runtime/Teams/BaseTeamManager.cs
  4. 1001
      Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/ZombiePushBlockDeathCollabArea.prefab
  5. 7
      Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/ZombiePushBlockDeathCollabArea.prefab.meta

998
Project/Assets/ML-Agents/Examples/PushBlock/Scenes/2ZombieVs3AgentsPushBlock.unity
文件差异内容过多而无法显示
查看文件

69
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/ZombiePushBlockDeathEnvController.cs


using System.Collections;
using System.Collections.Generic;
using Unity.MLAgents;
using Unity.MLAgents.Extensions.Teams;
using UnityEngine;
public class ZombiePushBlockDeathEnvController : MonoBehaviour

public bool UseRandomAgentPosition = true;
public bool UseRandomBlockRotation = true;
public bool UseRandomBlockPosition = true;
public bool UseTeamManager = true;
// public bool UseTeamReward = true;
// public bool DiscountTeamReward = true;
private int m_NumberOfRemainingBlocks;
private PushBlockTeamManager m_TeamManager;
private BaseTeamManager m_TeamManager;
void Start()
{

item.Rb = item.T.GetComponent<Rigidbody>();
}
// Initialize TeamManager
m_TeamManager = new PushBlockTeamManager();
if (UseTeamManager)
{
m_TeamManager = new BaseTeamManager();
}
foreach (var item in AgentsList)
{
item.StartingPos = item.Agent.transform.position;

// Add to team manager
item.Agent.SetTeamManager(m_TeamManager);
if (UseTeamManager)
{
item.Agent.SetTeamManager(m_TeamManager);
}
}
foreach (var item in ZombiesList)
{

void FixedUpdate()
{
m_ResetTimer += 1;
if (m_ResetTimer > MaxEnvironmentSteps)
if (m_ResetTimer >= MaxEnvironmentSteps)
//Kill/disable an agent
// Kill/disable an agent
print($"zombie {t.name} ate {col.collider.name}");
//Disable killed Agent
// Disable killed Agent
foreach (var item in AgentsList)
{
if (item.Col == col.collider)

}
}
//End Episode
// Disable killed Zombie
foreach (var item in ZombiesList)
{
if (item.Agent.transform == t)

/// </summary>
public void ScoredAGoal(Collider col, float score)
{
// //Decrement the counter
// m_NumberOfRemainingBlocks--;
//
// //Are we done?
// bool done = m_NumberOfRemainingBlocks == 0;
//
// //Disable the block
// col.gameObject.SetActive(false);
//Give Agent Rewards
// Give Agent Rewards
print($"{item.Agent.name} scored");
item.Agent.AddReward(score);
}
}

// if (done)
// {
//Reset assets
// }
}
public void ZombieTouchedBlock()

{
item.Agent.AddReward(-1);
if (item.Agent.gameObject.activeInHierarchy)
{
item.Agent.AddReward(-1);
}
}
Quaternion GetRandomRot()

{
m_ResetTimer = 0;
//Random platform rot
// Random platform rot
//End Episode
// End Episode
foreach (var item in AgentsList)
{
if (!item.Agent)

item.Agent.EndEpisode();
item.Agent.gameObject.SetActive(false);
//Reset Agents
// Reset Agents
foreach (var item in AgentsList)
{
var pos = UseRandomAgentPosition ? GetRandomSpawnPos() : item.StartingPos;

item.Agent.gameObject.SetActive(true);
}
//Reset Blocks
// Reset Blocks
foreach (var item in BlocksList)
{
var pos = UseRandomBlockPosition ? GetRandomSpawnPos() : item.StartingPos;

item.Rb.angularVelocity = Vector3.zero;
item.T.gameObject.SetActive(true);
}
//End Episode
// Reset Zombies
foreach (var item in ZombiesList)
{
if (!item.Agent)

item.Agent.SetRandomWalkSpeed();
item.Agent.gameObject.SetActive(true);
}
//Reset counter
m_NumberOfRemainingBlocks = BlocksList.Count;
// m_NumberOfRemainingBlocks = 2;
}
}

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


agent.SendDoneToTrainer();
}
public virtual void AddTeamReward(float reward)
{
}
public string GetId()
{
return m_Id;

1001
Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/ZombiePushBlockDeathCollabArea.prefab
文件差异内容过多而无法显示
查看文件

7
Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/ZombiePushBlockDeathCollabArea.prefab.meta


fileFormatVersion: 2
guid: 4d2fab054b6624d9799358c88e5cd48d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存