浏览代码

[AddVectorObs] Made it possible to call AddVectorObs with non floats (#398)

* [AddVectorObs] Made it possible to call AddVectorObs with int, Vector2, Vector3, List<float> and float[].

* [Comments] Made the comment clearer after overloading

* [Fix] Use AddRange instead of Add when adding lists or floatarrays
/develop-generalizationTraining-TrainerController
GitHub 7 年前
当前提交
cc0b046d
共有 1 个文件被更改,包括 32 次插入3 次删除
  1. 35
      unity-environment/Assets/ML-Agents/Scripts/Agent.cs

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


}
/// <summary>
/// Adds a vector observation.
/// Note that the number of vector observation to add
/// Appends float values to the vector observation.
/// Note that the total number of vector observation added
/// <param name="observation">The float value to add to
/// <param name="observation">The value to add to
internal void AddVectorObs(int observation)
{
_info.vectorObservation.Add((float)observation);
}
internal void AddVectorObs(Vector3 observation)
{
_info.vectorObservation.Add(observation.x);
_info.vectorObservation.Add(observation.y);
_info.vectorObservation.Add(observation.z);
}
internal void AddVectorObs(Vector2 observation)
{
_info.vectorObservation.Add(observation.x);
_info.vectorObservation.Add(observation.y);
}
internal void AddVectorObs(float[] observation)
{
_info.vectorObservation.AddRange(observation);
}
internal void AddVectorObs(List<float> observation)
{
_info.vectorObservation.AddRange(observation);
}
/// <summary>
/// Sets the text observation.
/// </summary>
/// <param name="s">The string the text observation must be set to.</param>
internal void SetTextObs(object s)
{
_info.textObservation = s.ToString();

正在加载...
取消
保存