浏览代码

randomize ball/agent spawn

/asymm-envs
Andrew Cohen 5 年前
当前提交
b80d6228
共有 2 个文件被更改,包括 5 次插入3 次删除
  1. 6
      Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
  2. 2
      Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs

6
Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs


var moveY = Mathf.Clamp(vectorAction[1], -1f, 1f);
var rotate = Mathf.Clamp(vectorAction[2], -1f, 1f) * m_InvertMult;
if (moveY > 0.0 && transform.position.y - transform.parent.transform.position.y < -1.5f)
if (moveY > 0.0 && transform.position.y - transform.parent.transform.position.y < 1f)
{
m_AgentRb.velocity = new Vector3(m_AgentRb.velocity.x, moveY * 20f, 0f);
}

{
m_Area.MatchReset();
}
transform.position = new Vector3(-m_InvertMult * 14f, 1f, -1.8f) + transform.parent.transform.position;
var agentOutX = Random.Range(12f, 16f);
var agentOutY = Random.Range(-1.5f, 1f);
transform.position = new Vector3(-m_InvertMult * agentOutX, agentOutY, -1.8f) + transform.parent.transform.position;
m_AgentRb.velocity = new Vector3(0f, 0f, 0f);
SetResetParameters();
}

2
Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs


public void MatchReset()
{
var ballOut = 14f;
var ballOut = Random.Range(10f, 18f);
var flip = Random.Range(0, 2);
if (flip == 0)
{

正在加载...
取消
保存