浏览代码

update pushblock actions

/develop/zombie-exp
Andrew Cohen 4 年前
当前提交
f4086dc2
共有 2 个文件被更改,包括 298 次插入44 次删除
  1. 281
      Project/Assets/ML-Agents/Examples/PushBlock/Scenes/2ZombieVs3AgentsPushBlock.unity
  2. 61
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentCollab.cs

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

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


var dirToGo = Vector3.zero;
var rotateDir = Vector3.zero;
var action = act[0];
var forwardAxis = act[0];
var rightAxis = act[1];
var rotateAxis = act[2];
switch (action)
switch (forwardAxis)
{
case 1:
dirToGo = transform.forward * 1f;

break;
case 3:
rotateDir = transform.up * 1f;
}
switch (rightAxis)
{
case 1:
dirToGo = transform.right * 1f;
break;
case 2:
dirToGo = transform.right * -1f;
case 4:
}
switch (rotateAxis)
{
case 1:
case 5:
dirToGo = transform.right * -0.75f;
break;
case 6:
dirToGo = transform.right * 0.75f;
case 2:
rotateDir = transform.up * 1f;
transform.Rotate(rotateDir, Time.fixedDeltaTime * 200f);
m_AgentRb.AddForce(dirToGo * m_PushBlockSettings.agentRunSpeed,
ForceMode.VelocityChange);

public override void Heuristic(in ActionBuffers actionsOut)
{
var discreteActionsOut = actionsOut.DiscreteActions;
discreteActionsOut[0] = 0;
if (Input.GetKey(KeyCode.D))
discreteActionsOut.Clear();
//forward
if (Input.GetKey(KeyCode.W))
{
discreteActionsOut[0] = 1;
}
if (Input.GetKey(KeyCode.S))
{
discreteActionsOut[0] = 2;
}
//rotate
if (Input.GetKey(KeyCode.A))
discreteActionsOut[0] = 3;
discreteActionsOut[2] = 1;
else if (Input.GetKey(KeyCode.W))
if (Input.GetKey(KeyCode.D))
discreteActionsOut[0] = 1;
discreteActionsOut[2] = 2;
else if (Input.GetKey(KeyCode.A))
//right
if (Input.GetKey(KeyCode.E))
discreteActionsOut[0] = 4;
discreteActionsOut[1] = 1;
else if (Input.GetKey(KeyCode.S))
if (Input.GetKey(KeyCode.Q))
discreteActionsOut[0] = 2;
discreteActionsOut[1] = 2;
}
}

正在加载...
取消
保存