浏览代码

Add group to zombie

/develop/collab-envs-exp-ervin
Ervin Teng 4 年前
当前提交
65b43197
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 12
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/ZombiePushBlockDeathEnvController.cs

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


public bool UseRandomBlockPosition = true;
PushBlockSettings m_PushBlockSettings;
private SimpleMultiAgentGroup m_AgentGroup;
private int m_NumberOfRemainingBlocks;
void Start()

// Starting material
m_GroundMaterial = m_GroundRenderer.material;
m_PushBlockSettings = FindObjectOfType<PushBlockSettings>();
m_AgentGroup = new SimpleMultiAgentGroup();
foreach (var item in BlocksList)
{
item.StartingPos = item.T.transform.position;

item.Rb = item.Agent.GetComponent<Rigidbody>();
item.Col = item.Agent.GetComponent<Collider>();
// Add to team manager
// item.Agent.SetTeamManager(m_TeamManager);
m_AgentGroup.RegisterAgent(item.Agent);
}
foreach (var item in ZombiesList)
{

//Give Agent Rewards
foreach (var item in AgentsList)
{
m_AgentGroup.AddGroupReward(score);
item.Agent.AddReward(score);
}
}

public void ZombieTouchedBlock()
{
//Give Agent Rewards
foreach (var item in AgentsList)
{
item.Agent.AddReward(-1);
}
m_AgentGroup.AddGroupReward(-1);
// Swap ground material for a bit to indicate we scored.
StartCoroutine(GoalScoredSwapGroundMaterial(m_PushBlockSettings.failMaterial, 0.5f));
ResetScene();

正在加载...
取消
保存