Skip to content

Integrate IActuators into ML-Agents core code. #4315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 13, 2020
Merged

Conversation

surfnerd
Copy link
Contributor

@surfnerd surfnerd commented Aug 6, 2020

Proposed change(s)

This PR is an attempt to integrate Actuators into the core of ML-Agents code without breaking backward compatibility.

The biggest architectural change (aside from the Actuator abstraction) is splitting the action buffer between the types of actions that are available for use. This propagates all the way down to the IPolicy interface and makes for some unflattering hoop-jumping in order to keep Heuristic backward compatible.

Two follow up PRs will be made:

  1. Change environments.
  2. Documentation (markdown) changes.

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@surfnerd surfnerd self-assigned this Aug 6, 2020

/// <summary>
/// DiscreteVectorActuator which is used by default if no other sensors exist on this Agent. This VectorSensor will
/// delegate its actions to <see cref="IActionReceiver.OnActionReceived"/> by default in order to keep backward compatibility
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I need to read more, but it sends to Agent.OnActionReceived, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Agent Implements that interface method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I misunderstood this comment. I'll fix it.

@@ -15,19 +14,13 @@ namespace Unity.MLAgents
/// may be illegal. For example, if an agent is adjacent to a wall or other obstacle
/// you could mask any actions that direct the agent to move into the blocked space.
/// </remarks>
public class DiscreteActionMasker
public class DiscreteActionMasker : IDiscreteActionMask
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking - this isn't considered a breaking change, right? I've seen some chatter about things the look harmless because the old code still compiles, but the assemblies would be incompatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question. I wonder if we can check the version bump with the validation suite somehow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intuition would be that since the default behavior didn't change, and the method's signature that uses this type is concretely defined, therefore, it should be ok. Would be good to know the answer to this question concretely.

@@ -45,6 +49,7 @@ internal class BarracudaPolicy : IPolicy
{
var modelRunner = Academy.Instance.GetOrCreateModelRunner(model, brainParameters, inferenceDevice);
m_ModelRunner = modelRunner;
m_SapceType = brainParameters.VectorActionSpaceType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. typo: m_SapceType -> m_SpaceType
  2. Should we be dealing in ActionSpecs here instead? Would adding a method to BrainParameters to return an equivalent ActionSpec be helpful anywhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be used in creating the vector actuator.

@surfnerd surfnerd merged commit 41d07d5 into master Aug 13, 2020
@surfnerd surfnerd deleted the master-actuators-2 branch August 14, 2020 00:32
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants