Skip to content

Commit

Permalink
Make IActuator implement IHeuristicProvider. (#5110)
Browse files Browse the repository at this point in the history
  • Loading branch information
surfnerd authored Mar 15, 2021
1 parent 8f2f73f commit edd3a5a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Unity.MLAgents.Extensions.Input
/// <see cref="Agent"/>'s <see cref="BehaviorParameters"/> indicate that the Agent is running in Heuristic Mode,
/// this Actuator will write actions from the <see cref="InputSystem"/> to the <see cref="ActionBuffers"/> object.
/// </summary>
public class InputActionActuator : IActuator, IHeuristicProvider, IBuiltInActuator
public class InputActionActuator : IActuator, IBuiltInActuator
{
readonly BehaviorParameters m_BehaviorParameters;
readonly InputAction m_Action;
Expand Down
1 change: 1 addition & 0 deletions com.unity.ml-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to
- The interface for disabling discrete actions in `IDiscreteActionMask` has changed.
`WriteMask(int branch, IEnumerable<int> actionIndices)` was replaced with
`SetActionEnabled(int branch, int actionIndex, bool isEnabled)`. See the
- IActuator now implements IHeuristicProvider. (#5110)
[Migration Guide](https://github.com/Unity-Technologies/ml-agents/blob/release_14_docs/docs/Migrating.md) for more
details. (#5060)
#### ml-agents / ml-agents-envs / gym-unity (Python)
Expand Down
4 changes: 1 addition & 3 deletions com.unity.ml-agents/Runtime/Actuators/ActuatorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ public void ApplyHeuristic(in ActionBuffers actionBuffersOut)
discreteStart,
numDiscreteActions);
}

var heuristic = actuator as IHeuristicProvider;
heuristic?.Heuristic(new ActionBuffers(continuousActions, discreteActions));
actuator.Heuristic(new ActionBuffers(continuousActions, discreteActions));
continuousStart += numContinuousActions;
discreteStart += numDiscreteActions;
}
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Actuators/IActuator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Unity.MLAgents.Actuators
/// <summary>
/// Abstraction that facilitates the execution of actions.
/// </summary>
public interface IActuator : IActionReceiver
public interface IActuator : IActionReceiver, IHeuristicProvider
{
/// <summary>
/// The specification of the actions for this IActuator.
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Actuators/VectorActuator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Unity.MLAgents.Actuators
/// <summary>
/// IActuator implementation that forwards calls to an <see cref="IActionReceiver"/> and an <see cref="IHeuristicProvider"/>.
/// </summary>
internal class VectorActuator : IActuator, IHeuristicProvider, IBuiltInActuator
internal class VectorActuator : IActuator, IBuiltInActuator
{
IActionReceiver m_ActionReceiver;
IHeuristicProvider m_HeuristicProvider;
Expand Down
2 changes: 2 additions & 0 deletions docs/Migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public override void WriteDiscreteActionMask(IDiscreteActionMask actionMask)
actionMask.SetActionEnabled(branch, 3, false);
}
```
- The `IActuator` interface now implements `IHeuristicProvider`. Please add the corresponding `Heuristic(in ActionBuffers)`
method to your custom Actuator classes.

## Migrating to Release 13
### Implementing IHeuristic in your IActuator implementations
Expand Down

0 comments on commit edd3a5a

Please sign in to comment.