File size: 1,411 Bytes
05c9ac2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
namespace Unity.MLAgents.Actuators
{
    /// <summary>
    /// Abstraction that facilitates the execution of actions.
    /// </summary>
    public interface IActuator : IActionReceiver, IHeuristicProvider
    {
        /// <summary>
        /// The specification of the actions for this IActuator.
        /// </summary>
        /// <seealso cref="ActionSpec"/>
        ActionSpec ActionSpec { get; }

        /// <summary>
        /// Gets the name of this IActuator which will be used to sort it.
        /// </summary>
        /// <returns></returns>
        string Name { get; }

        /// <summary>
        /// Resets the internal state of the actuator. This is called at the end of an Agent's episode.
        /// Most implementations can leave this empty.
        /// </summary>
        void ResetData();
    }

    /// <summary>
    /// Helper methods to be shared by all classes that implement <see cref="IActuator"/>.
    /// </summary>
    public static class IActuatorExtensions
    {
        /// <summary>
        /// Returns the number of discrete branches + the number of continuous actions.
        /// </summary>
        /// <param name="actuator"></param>
        /// <returns></returns>
        public static int TotalNumberOfActions(this IActuator actuator)
        {
            return actuator.ActionSpec.NumContinuousActions + actuator.ActionSpec.NumDiscreteActions;
        }
    }
}