浏览代码

fix BananaIL scene (#2512)

* add reset parameters to scene

* default values for BananaAgent reset parameters
/hotfix-v0.9.2a
GitHub 5 年前
当前提交
afbf46bd
共有 2 个文件被更改,包括 14 次插入9 次删除
  1. 6
      UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Scenes/BananaIL.unity
  2. 17
      UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Scripts/BananaAgent.cs

6
UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Scenes/BananaIL.unity


timeScale: 1
targetFrameRate: 60
resetParameters:
resetParameters: []
resetParameters:
- key: laser_length
value: 1
- key: agent_scale
value: 1
agents: []
listArea: []
totalScore: 0

17
UnitySDK/Assets/ML-Agents/Examples/BananaCollectors/Scripts/BananaAgent.cs


public bool contribute;
private RayPerception3D rayPer;
public bool useVectorObs;
public override void InitializeAgent()
{

var rightAxis = (int)act[1];
var rotateAxis = (int)act[2];
var shootAxis = (int)act[3];
switch (forwardAxis)
{
case 1:

dirToGo = -transform.forward;
break;
}
switch (rightAxis)
{
case 1:

break;
case 2:
rotateDir = transform.up;
break;
break;
}
switch (shootAxis)
{

public void SetLaserLengths()
{
laser_length = myAcademy.resetParameters["laser_length"];
laser_length = myAcademy.resetParameters.TryGetValue("laser_length", out laser_length) ? laser_length: 1.0f;
var agent_scale = myAcademy.resetParameters["agent_scale"];
gameObject.transform.localScale = new Vector3(agent_scale, agent_scale, agent_scale);
float agentScale;
agentScale = myAcademy.resetParameters.TryGetValue("agent_scale", out agentScale) ? agentScale : 1.0f;
gameObject.transform.localScale = new Vector3(agentScale, agentScale, agentScale);
public void SetResetParameters()
{
SetLaserLengths();

正在加载...
取消
保存