浏览代码

rename some vars

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

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


TennisArea m_Area;
float m_InvertMult;
FloatPropertiesChannel m_ResetParams;
Vector3 down = new Vector3(0f, -100f, 0f);
Vector3 m_Down = new Vector3(0f, -100f, 0f);
Vector3 zAxis = new Vector3(0f, 0f, 1f);
const float k_Angle = 90f;
const float k_MaxAngle = 145f;

// calculate angle between m_InvertMult * 55 and m_InvertMult * 125
var angle = 35f * rotate + m_InvertMult * k_Angle;
// maps inverse agents rotation into -35 to -145
// maps agents rotation into m_InvertMult * 55 and m_InvertMult * 125
var rotateZ = angle - (gameObject.transform.rotation.eulerAngles.z - (1f - m_InvertMult) * 180f);
Quaternion deltaRotation = Quaternion.Euler(zAxis * rotateZ);
m_AgentRb.MoveRotation(m_AgentRb.rotation * deltaRotation);

void FixedUpdate()
{
m_AgentRb.AddForce(down);
m_AgentRb.AddForce(m_Down);
}
public override void OnEpisodeBegin()

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


public GameObject agentB;
Rigidbody m_BallRb;
HitWall m_BallScript;
Vector3 down = new Vector3(0f, -45f, 0f);
Vector3 m_Down = new Vector3(0f, -45f, 0f);
// Use this for initialization
void Start()

void FixedUpdate()
{
m_BallRb.AddForce(down);
m_BallRb.AddForce(m_Down);
var rgV = m_BallRb.velocity;
m_BallRb.velocity = new Vector3(Mathf.Clamp(rgV.x, -40f, 40f), Mathf.Min(rgV.y, 35f), rgV.z);
}
正在加载...
取消
保存