浏览代码

make RayPerception.Perceive abstract and override in base classes (#2788)

/develop-gpu-test
GitHub 5 年前
当前提交
757f7153
共有 3 个文件被更改,包括 11 次插入11 次删除
  1. 9
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception.cs
  2. 9
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception2D.cs
  3. 4
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs

9
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception.cs


using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
public abstract class RayPerception : MonoBehaviour

public virtual List<float> Perceive(float rayDistance,
abstract public List<float> Perceive(float rayDistance,
float startOffset, float endOffset)
{
return m_PerceptionBuffer;
}
float startOffset=0.0f, float endOffset=0.0f);
/// <summary>
/// Converts degrees to radians.

9
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception2D.cs


using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
namespace MLAgents

/// <param name="rayDistance">Radius of rays</param>
/// <param name="rayAngles">Angles of rays (starting from (1,0) on unit circle).</param>
/// <param name="detectableObjects">List of tags which correspond to object types agent can see</param>
public List<float> Perceive(float rayDistance,
float[] rayAngles, string[] detectableObjects)
/// <param name="startOffset">Unused</param>
/// <param name="endOffset">Unused</param>
public override List<float> Perceive(float rayDistance,
float[] rayAngles, string[] detectableObjects,
float startOffset=0.0f, float endOffset=0.0f)
{
m_PerceptionBuffer.Clear();
// For each ray sublist stores categorical information on detected object

4
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs


using System;
using System;
using System.Collections.Generic;
using UnityEngine;

/// <param name="endOffset">Ending height offset of ray from center of agent.</param>
public override List<float> Perceive(float rayDistance,
float[] rayAngles, string[] detectableObjects,
float startOffset, float endOffset)
float startOffset=0.0f, float endOffset=0.0f)
{
if (m_SubList == null || m_SubList.Length != detectableObjects.Length + 2)
m_SubList = new float[detectableObjects.Length + 2];

正在加载...
取消
保存