File tree 8 files changed +45
-2
lines changed
Project/Assets/ML-Agents/Examples
com.unity.ml-agents.extensions/Runtime/Match3 8 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ public class BasicActuatorComponent : ActuatorComponent
17
17
/// Creates a BasicActuator.
18
18
/// </summary>
19
19
/// <returns></returns>
20
+ #pragma warning disable 672
20
21
public override IActuator CreateActuator ( )
22
+ #pragma warning restore 672
21
23
{
22
24
return new BasicActuator ( basicController ) ;
23
25
}
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ namespace Unity.MLAgentsExamples
7
7
public class Match3ExampleActuatorComponent : Match3ActuatorComponent
8
8
{
9
9
/// <inheritdoc/>
10
+ #pragma warning disable 672
10
11
public override IActuator CreateActuator ( )
12
+ #pragma warning restore 672
11
13
{
12
14
var board = GetComponent < Match3Board > ( ) ;
13
15
var agent = GetComponentInParent < Agent > ( ) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ public class Match3ActuatorComponent : ActuatorComponent
28
28
public bool ForceHeuristic ;
29
29
30
30
/// <inheritdoc/>
31
+ #pragma warning disable 672
31
32
public override IActuator CreateActuator ( )
33
+ #pragma warning restore 672
32
34
{
33
35
var board = GetComponent < AbstractBoard > ( ) ;
34
36
var agent = GetComponentInParent < Agent > ( ) ;
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ removed when training with a player. The Editor still requires it to be clamped
30
30
additional memory allocations. (#4887 )
31
31
- Added ` ObservationWriter.AddList() ` and deprecated ` ObservationWriter.AddRange() ` .
32
32
` AddList() ` is recommended, as it does not generate any additional memory allocations. (#4887 )
33
+ - Added ` ActuatorComponent.CreateActuators ` , and deprecate ` ActuatorComponent.CreateActuator ` . The
34
+ default implementation will wrap ` ActuatorComponent.CreateActuator ` in an array and return that. (#4899 )
33
35
34
36
#### ml-agents / ml-agents-envs / gym-unity (Python)
35
37
- Added a ` --torch-device ` commandline option to ` mlagents-learn ` , which sets the default
Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using UnityEngine ;
2
3
3
4
namespace Unity . MLAgents . Actuators
@@ -12,8 +13,21 @@ public abstract class ActuatorComponent : MonoBehaviour
12
13
/// Create the IActuator. This is called by the Agent when it is initialized.
13
14
/// </summary>
14
15
/// <returns>Created IActuator object.</returns>
16
+ [ Obsolete ( "Use CreateActuators instead." ) ]
15
17
public abstract IActuator CreateActuator ( ) ;
16
18
19
+ /// <summary>
20
+ /// Create a collection of <see cref="IActuator"/>s. This is called by the <see cref="Agent"/> during
21
+ /// initialization.
22
+ /// </summary>
23
+ /// <returns>A collection of <see cref="IActuator"/>s</returns>
24
+ public virtual IActuator [ ] CreateActuators ( )
25
+ {
26
+ #pragma warning disable 618
27
+ return new [ ] { CreateActuator ( ) } ;
28
+ #pragma warning restore 618
29
+ }
30
+
17
31
/// <summary>
18
32
/// The specification of the possible actions for this ActuatorComponent.
19
33
/// This must produce the same results as the corresponding IActuator's ActionSpec.
Original file line number Diff line number Diff line change @@ -369,6 +369,18 @@ void ClearBufferSizes()
369
369
NumContinuousActions = NumDiscreteActions = SumOfDiscreteBranchSizes = 0 ;
370
370
}
371
371
372
+ /// <summary>
373
+ /// Add an array of <see cref="IActuator"/>s at once.
374
+ /// </summary>
375
+ /// <param name="actuators">The array of <see cref="IActuator"/>s to add.</param>
376
+ public void AddActuators ( IActuator [ ] actuators )
377
+ {
378
+ for ( var i = 0 ; i < actuators . Length ; i ++ )
379
+ {
380
+ Add ( actuators [ i ] ) ;
381
+ }
382
+ }
383
+
372
384
/*********************************************************************************
373
385
* IList implementation that delegates to m_Actuators List. *
374
386
*********************************************************************************/
@@ -432,7 +444,7 @@ public bool Remove(IActuator item)
432
444
public int Count => m_Actuators . Count ;
433
445
434
446
/// <inheritdoc/>
435
- public bool IsReadOnly => m_Actuators . IsReadOnly ;
447
+ public bool IsReadOnly => false ;
436
448
437
449
/// <inheritdoc/>
438
450
public int IndexOf ( IActuator item )
Original file line number Diff line number Diff line change @@ -1006,7 +1006,7 @@ void InitializeActuators()
1006
1006
1007
1007
foreach ( var actuatorComponent in attachedActuators )
1008
1008
{
1009
- m_ActuatorManager . Add ( actuatorComponent . CreateActuator ( ) ) ;
1009
+ m_ActuatorManager . AddActuators ( actuatorComponent . CreateActuators ( ) ) ;
1010
1010
}
1011
1011
}
1012
1012
Original file line number Diff line number Diff line change @@ -21,6 +21,15 @@ double-check that the versions are in the same. The versions can be found in
21
21
- ` VectorSensor.AddObservation(IEnumerable<float>) ` is deprecated. Use ` VectorSensor.AddObservation(IList<float>) `
22
22
instead.
23
23
- ` ObservationWriter.AddRange() ` is deprecated. Use ` ObservationWriter.AddList() ` instead.
24
+ - ` ActuatorComponent.CreateAcuator() ` is deprecated. Please use override ` ActuatorComponent.CreateActuators `
25
+ instead. Since ` ActuatorComponent.CreateActuator() ` is abstract, you will still need to override it in your
26
+ class until it is removed. It is only ever called if you don't override ` ActuatorComponent.CreateActuators ` .
27
+ You can suppress the warnings by surrounding the method with the following pragma:
28
+ ``` c#
29
+ #pragma warning disable 672
30
+ public IActuator CreateActuator () { .. . }
31
+ #pragma warning restore 672
32
+ ```
24
33
25
34
26
35
# Migrating
You can’t perform that action at this time.
0 commit comments