浏览代码

clean up the code in Ball3DDecision

/develop-generalizationTraining-TrainerController
Vincent Gao 6 年前
当前提交
4a23c5cf
共有 2 个文件被更改,包括 13 次插入22 次删除
  1. 29
      unity-environment/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DDecision.cs
  2. 6
      unity-environment/Assets/ML-Agents/Scripts/Agent.cs

29
unity-environment/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DDecision.cs


public class Ball3DDecision : MonoBehaviour, Decision
{
public float rotationSpeed = 2f;
List<float> ret = new List<float>();
if (state[2] < 0 || state[5] < 0)
{
ret.Add(state[5]);
}
else
{
ret.Add(state[5]);
}
if (state[3] < 0 || state[7] < 0)
{
ret.Add(-state[7]);
}
else
{
ret.Add(-state[7]);
}
return ret.ToArray();
List<float> act = new List<float>();
//state[5] is the velocity of the ball in the x orientation. We use this number to control the Platform's z axis rotation speed,
//so that the Platform is tilted in the x orientation correspondingly.
act.Add(state[5] * rotationSpeed);
//state[7] is the velocity of the ball in the z orientation. We use this number to control the Platform's x axis rotation speed,
//so that the Platform is tilted in the z orientation correspondingly.
act.Add(-state[7] * rotationSpeed);
return act.ToArray();
//If the vector action space type is discrete, then we don't do anything.
else
{
return new float[1]{ 1f };

6
unity-environment/Assets/ML-Agents/Scripts/Agent.cs


///</summary>
private float reward;
/// Whether or not the agent requests an action
/// Whether or not the agent requests an action.
/// Whether or not the agent requests a decision
/// Whether or not the agent requests a decision.
private bool requestDecision;
/// <summary>

private int id;
/// <summary>
/// Unity method called when the agent is instantiated or set to active.
/// Unity method called when the agent is instantiated or set to active.
/// </summary>
private void OnEnable()
{

正在加载...
取消
保存