浏览代码

Freeze agent, don't kill it

/develop/zombieteammanager/disableagent
Ervin Teng 4 年前
当前提交
b8b5b4d8
共有 2 个文件被更改,包括 23 次插入14 次删除
  1. 9
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentCollab.cs
  2. 28
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/ZombiePushBlockDeathEnvController.cs

9
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentCollab.cs


// Rigidbody m_BlockRb; //cached on initialization
Rigidbody m_AgentRb; //cached on initialization
public bool frozen = false;
public bool useVectorObs = true;
void Awake()
{

public override void OnActionReceived(ActionBuffers actionBuffers)
{
// Move the agent using the action.
MoveAgent(actionBuffers.DiscreteActions);
if (!frozen)
{
// Move the agent using the action.
MoveAgent(actionBuffers.DiscreteActions);
}
// Penalty given each step to encourage agent to finish task quickly.
AddReward(-1f / MaxStep);

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


{
return;
}
item.Agent.EndEpisode();
}
//Disable killed Agent

{
item.Col.gameObject.SetActive(false);
break;
// Disable collider
item.Agent.frozen = true;
item.Rb.constraints |= RigidbodyConstraints.FreezePositionY;
item.Col.enabled = false;
//End Episode
foreach (var item in ZombiesList)
{
if (item.Agent.transform == t)
{
item.Agent.gameObject.SetActive(false);
break;
}
}
// //End Episode
// foreach (var item in ZombiesList)
// {
// if (item.Agent.transform == t)
// {
// item.Agent.gameObject.SetActive(false);
// break;
// }
// }
}

item.Agent.transform.SetPositionAndRotation(pos, rot);
item.Rb.velocity = Vector3.zero;
item.Rb.angularVelocity = Vector3.zero;
item.Col.enabled = true;
item.Agent.frozen = false;
item.Rb.constraints &= ~RigidbodyConstraints.FreezePositionY;
}
//Reset Blocks

正在加载...
取消
保存