浏览代码

fixed opponent setting

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

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


m_Area = areaObject.GetComponent<TennisArea>();
m_AgentA = m_Area.agentA.GetComponent<TennisAgent>();
m_AgentB = m_Area.agentB.GetComponent<TennisAgent>();
m_AgentA.OpponentRb = m_AgentB.GetComponent<Rigidbody>();
m_AgentB.OpponentRb = m_AgentA.GetComponent<Rigidbody>();
}
public void ResetPoint()

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


{
[Header("Specific to Tennis")]
public GameObject ball;
public GameObject opponent;
[HideInInspector]
public Rigidbody OpponentRb;
Rigidbody m_OpponentRb;
HitWall m_BallScript;
TennisArea m_Area;
float m_InvertMult;

m_Existential = 1f / MaxStep;
m_AgentRb = GetComponent<Rigidbody>();
m_BallRb = ball.GetComponent<Rigidbody>();
m_OpponentRb = opponent.GetComponent<Rigidbody>();
m_BallScript = ball.GetComponent<HitWall>();
m_Area = myArea.GetComponent<TennisArea>();
var canvas = GameObject.Find(k_CanvasName);

//sensor.AddObservation(m_InvertMult * (opponent.transform.position.x - myArea.transform.position.x) / -25f);
//sensor.AddObservation((opponent.transform.position.y - myArea.transform.position.y) / -7f);
//sensor.AddObservation(m_InvertMult * m_OpponentRb.velocity.x / 20f);
//sensor.AddObservation(m_OpponentRb.velocity.y / 20f);
//sensor.AddObservation(m_InvertMult * OpponentRb.velocity.x / 20f);
//sensor.AddObservation(OpponentRb.velocity.y / 20f);
sensor.AddObservation(m_InvertMult * (transform.position.x - myArea.transform.position.x));
sensor.AddObservation(transform.position.y - myArea.transform.position.y);

sensor.AddObservation(m_InvertMult * m_BallRb.velocity.x);
sensor.AddObservation(m_BallRb.velocity.y);
sensor.AddObservation(m_InvertMult * (opponent.transform.position.x - myArea.transform.position.x));
sensor.AddObservation(opponent.transform.position.y - myArea.transform.position.y);
sensor.AddObservation(m_InvertMult * m_OpponentRb.velocity.x);
sensor.AddObservation(m_OpponentRb.velocity.y);
sensor.AddObservation(m_InvertMult * (OpponentRb.position.x - myArea.transform.position.x));
sensor.AddObservation(OpponentRb.position.y - myArea.transform.position.y);
sensor.AddObservation(m_InvertMult * OpponentRb.velocity.x);
sensor.AddObservation(OpponentRb.velocity.y);
sensor.AddObservation(m_InvertMult * gameObject.transform.rotation.z);
//sensor.AddObservation((m_InvertMult * (gameObject.transform.rotation.eulerAngles.z - (1f - m_InvertMult) * 180f) - 35f) / 125f);

正在加载...
取消
保存