浏览代码

Merge branch 'soccer-2v1' into asymm-envs

/asymm-envs
Andrew Cohen 5 年前
当前提交
29c23484
共有 3 个文件被更改,包括 23 次插入13 次删除
  1. 4
      Project/Assets/ML-Agents/Examples/Tennis/Prefabs/TennisArea.prefab
  2. 22
      Project/Assets/ML-Agents/Examples/Tennis/Scripts/HitWall.cs
  3. 10
      Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs

4
Project/Assets/ML-Agents/Examples/Tennis/Prefabs/TennisArea.prefab


m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 9
vectorObservationSize: 10
numStackedVectorObservations: 3
vectorActionSize: 03000000
vectorActionDescriptions: []

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 9
vectorObservationSize: 10
numStackedVectorObservations: 3
vectorActionSize: 03000000
vectorActionDescriptions: []

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


FloorAHit,
FloorBHit
}
FloorHit m_LastFloorHit;
[HideInInspector]
public FloorHit LastFloorHit;
TennisArea m_Area;
TennisAgent m_AgentA;

public void ResetPoint()
{
m_LastFloorHit = FloorHit.Service;
LastFloorHit = FloorHit.Service;
m_LastAgentHit = -1;
}

if (collision.gameObject.name == "wallA")
{
// Agent A hits into wall or agent B hit a winner
if (m_LastAgentHit == 0 || m_LastFloorHit == FloorHit.FloorAHit)
if (m_LastAgentHit == 0 || LastFloorHit == FloorHit.FloorAHit)
{
AgentBWins();
}

else if (collision.gameObject.name == "wallB")
{
// Agent B hits into wall or agent A hit a winner
if (m_LastAgentHit == 1 || m_LastFloorHit == FloorHit.FloorBHit)
if (m_LastAgentHit == 1 || LastFloorHit == FloorHit.FloorBHit)
{
AgentAWins();
}

else if (collision.gameObject.name == "floorA")
{
// Agent A hits into floor, double bounce or service
if (m_LastAgentHit == 0 || m_LastFloorHit == FloorHit.FloorAHit || m_LastFloorHit == FloorHit.Service)
if (m_LastAgentHit == 0 || LastFloorHit == FloorHit.FloorAHit || LastFloorHit == FloorHit.Service)
m_LastFloorHit = FloorHit.FloorAHit;
LastFloorHit = FloorHit.FloorAHit;
if (m_LastAgentHit == 1 || m_LastFloorHit == FloorHit.FloorBHit || m_LastFloorHit == FloorHit.Service)
if (m_LastAgentHit == 1 || LastFloorHit == FloorHit.FloorBHit || LastFloorHit == FloorHit.Service)
m_LastFloorHit = FloorHit.FloorBHit;
LastFloorHit = FloorHit.FloorBHit;
}
}
}

{
m_LastAgentHit = 0;
m_LastFloorHit = FloorHit.FloorHitUnset;
LastFloorHit = FloorHit.FloorHitUnset;
}
}
else if (collision.gameObject.name == "AgentB")

else
{
m_LastAgentHit = 1;
m_LastFloorHit = FloorHit.FloorHitUnset;
LastFloorHit = FloorHit.FloorHitUnset;
}
}
}

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


Text m_TextComponent;
Rigidbody m_AgentRb;
Rigidbody m_BallRb;
HitWall m_BallScript;
TennisArea m_Area;
float m_InvertMult;
FloatPropertiesChannel m_ResetParams;

{
m_AgentRb = GetComponent<Rigidbody>();
m_BallRb = ball.GetComponent<Rigidbody>();
m_BallScript = ball.GetComponent<HitWall>();
m_Area = myArea.GetComponent<TennisArea>();
var canvas = GameObject.Find(k_CanvasName);
GameObject scoreBoard;

sensor.AddObservation(m_BallRb.velocity.y);
sensor.AddObservation(m_InvertMult * gameObject.transform.rotation.z);
if (m_BallScript.LastFloorHit == HitWall.FloorHit.FloorHitUnset)
{
sensor.AddObservation(1.0f);
}
else
{
sensor.AddObservation(0.0f);
}
}
public override void OnActionReceived(float[] vectorAction)

正在加载...
取消
保存