Skip to content

Commit

Permalink
Fix API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurimas Petrovas committed Sep 10, 2024
1 parent d67dc94 commit d93a5fc
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 0 deletions.
6 changes: 6 additions & 0 deletions com.unity.ml-agents/Runtime/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ public struct AgentInfo
/// </summary>
public int groupId;

/// <summary>
/// Clear stored actions.
/// </summary>
public void ClearActions()
{
storedActions.Clear();
}

/// <summary>
/// Copy actions.
/// </summary>
public void CopyActions(ActionBuffers actionBuffers)
{
var continuousActions = storedActions.ContinuousActions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,27 @@ public static bool Enabled
set => s_Enabled = value;
}

/// <summary>
/// Check if a communicator has been registered.
/// </summary>
public static bool CommunicatorRegistered => s_Creator != null;

internal static ICommunicator Create()
{
return s_Enabled ? s_Creator() : null;
}

/// <summary>
/// Register a function that will create an ICommunicator instance.
/// </summary>
public static void Register<T>(Func<T> creator) where T : ICommunicator
{
s_Creator = () => creator();
}

/// <summary>
/// Clear the registered creator.
/// </summary>
public static void ClearCreator()
{
s_Creator = null;
Expand Down
10 changes: 10 additions & 0 deletions com.unity.ml-agents/Runtime/Communicator/ICommunicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Unity.MLAgents
{
/// <summary>
/// Communicator initialization parameters.
/// </summary>
public struct CommunicatorInitParameters
{
/// <summary>
Expand Down Expand Up @@ -32,6 +35,10 @@ public struct CommunicatorInitParameters
/// </summary>
public UnityRLCapabilities CSharpCapabilities;
}

/// <summary>
/// Initialization parameters for the Unity environment.
/// </summary>
public struct UnityRLInitParameters
{
/// <summary>
Expand Down Expand Up @@ -119,6 +126,9 @@ Since the messages are sent back and forth with exchange and simultaneously when
UnityOutput and UnityInput can be extended to provide functionalities beyond RL
UnityRLOutput and UnityRLInput can be extended to provide new RL functionalities
*/
/// <summary>
/// Interface of the Communicators
/// </summary>
public interface ICommunicator : IDisposable
{
/// <summary>
Expand Down
37 changes: 37 additions & 0 deletions com.unity.ml-agents/Runtime/Communicator/UnityRLCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,57 @@

namespace Unity.MLAgents
{
/// <summary>
/// A class holding the capabilities flags for Reinforcement Learning across C# and the Trainer codebase.
/// </summary>
public class UnityRLCapabilities
{
/// <summary>
/// Base RL capabilities.
/// </summary>
public bool BaseRLCapabilities;

/// <summary>
/// Concatenated PNG observations.
/// </summary>
public bool ConcatenatedPngObservations;

/// <summary>
/// Compressed channel mapping.
/// </summary>
public bool CompressedChannelMapping;

/// <summary>
/// Hybrid actions.
/// </summary>
public bool HybridActions;

/// <summary>
/// Training analytics.
/// </summary>
public bool TrainingAnalytics;

/// <summary>
/// Variable length observation.
/// </summary>
public bool VariableLengthObservation;

/// <summary>
/// Multi-agent groups.
/// </summary>
public bool MultiAgentGroups;

/// <summary>
/// A class holding the capabilities flags for Reinforcement Learning across C# and the Trainer codebase. This
/// struct will be used to inform users if and when they are using C# / Trainer features that are mismatched.
/// </summary>
/// <param name="baseRlCapabilities">Base RL capabilities.</param>
/// <param name="concatenatedPngObservations">Concatenated PNG observations.</param>
/// <param name="compressedChannelMapping">Compressed channel mapping.</param>
/// <param name="hybridActions">Hybrid actions.</param>
/// <param name="trainingAnalytics">Training analytics.</param>
/// <param name="variableLengthObservation">Variable length observation.</param>
/// <param name="multiAgentGroups">Multi-agent groups.</param>
public UnityRLCapabilities(
bool baseRlCapabilities = true,
bool concatenatedPngObservations = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Unity.MLAgents.Integrations.Match3
/// </summary>
/// <param name="x">X</param>
/// <param name="y">Y</param>
/// <returns>The integer value at the given (x,y) coordinate.</returns>
public delegate int GridValueProvider(int x, int y);

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions com.unity.ml-agents/Runtime/Sensors/ObservationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class ObservationWriter

TensorShape m_TensorShape;

/// <summary>
/// Initializes a new instance of the <see cref="ObservationWriter"/> class.
/// </summary>
public ObservationWriter() { }

/// <summary>
Expand Down Expand Up @@ -96,6 +99,9 @@ public float this[int index]
}
}

/// <summary>
/// Write access at the specified channel and width.
/// </summary>
public float this[int ch, int w]
{
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public int ObservationStacks
set { m_ObservationStacks = value; }
}

/// <summary>
/// Disable to provide the rays in left to right order
/// </summary>
[HideInInspector, SerializeField]
[Tooltip("Disable to provide the rays in left to right order. Warning: Alternating order will be deprecated, disable it to ensure compatibility with future versions of ML-Agents.")]
public bool m_AlternatingRayOrder = true;
Expand Down
4 changes: 4 additions & 0 deletions com.unity.ml-agents/Runtime/Sensors/SensorShapeValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Unity.MLAgents.Sensors
{
/// <summary>
/// Check that List Sensors are the same shape as the previous ones.
/// </summary>
public class SensorShapeValidator
{
List<ObservationSpec> m_SensorShapes;
Expand All @@ -11,6 +14,7 @@ public class SensorShapeValidator
/// Check that the List Sensors are the same shape as the previous ones.
/// If this is the first List of Sensors being checked, its Sensor sizes will be saved.
/// </summary>
/// <param name="sensors">List of Sensors to validate</param>
public void ValidateSensors(List<ISensor> sensors)
{
if (m_SensorShapes == null)
Expand Down

0 comments on commit d93a5fc

Please sign in to comment.