Skip to content

Conversation

@vincentpierre
Copy link
Contributor

@vincentpierre vincentpierre commented Feb 27, 2020

Proposed change(s)

Rename and refactor the ActionMasker class

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

@vincentpierre vincentpierre changed the title Code edits [Renaming] SetActionMask -> SetDiscreteActionMask + added the virtual method CollectDiscreteActionMasks Feb 27, 2020
/// <returns>A mask for the agent. A boolean array of length equal to the total number of
/// actions.</returns>
internal bool[] GetMask()
internal bool[] GetDiscreteActionMask()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm OK leaving this as GetMask(). The "DiscreteAction" part in the class name seems like enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You think? Why is it different from SetMask()?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just think it's redundant. DiscreteActionMasker.GetMask() and DiscreteActionMasker.GetDiscreteActionMask() convey the same amount of info. (same for Set...)

Copy link
Contributor

@chriselion chriselion left a comment

Choose a reason for hiding this comment

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

Looks good, not sure we need "discrete" everywhere though.

Discrete.

vincentpierre and others added 3 commits February 27, 2020 16:21
Co-Authored-By: Chris Elion <chris.elion@unity3d.com>
Co-Authored-By: Chris Elion <chris.elion@unity3d.com>
Co-Authored-By: Chris Elion <chris.elion@unity3d.com>
@vincentpierre
Copy link
Contributor Author

Looks good, not sure we need "discrete" everywhere though.

I will leave this decision to the discretion of the reviewers

/// the utilities for setting and retrieving them.
/// </summary>
public class ActionMasker
public class DiscreteActionMasker
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't the file name need to change too?

/// to the agent in addition to the vector observations implemented by the
/// user in <see cref="Agent.CollectObservations(VectorSensor)"/> or
/// <see cref="Agent.CollectObservations(VectorSensor, ActionMasker)"/>.
/// <see cref="Agent.CollectObservations(VectorSensor, DiscreteActionMasker)"/>.
Copy link
Contributor

Choose a reason for hiding this comment

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

This overload no longer exists, right?

@vincentpierre
Copy link
Contributor Author

Re-requesting reviews because I changed the names again

/// Visual observations are implicitly added from the cameras attached to
/// the Agent.
/// When using Discrete Control, you can prevent the Agent from using a certain
/// action by masking it. You can call the following method on the ActionMasker
Copy link
Contributor

Choose a reason for hiding this comment

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

This still feels a bit redundant; how about something like

/// When using Discrete Control, you can prevent the Agent from using a certain /// action by masking it with <see cref="DiscreteActionMasker.SetMask(int, IEnumerable{int})"/> 

(Remove the "The first argument..." part, since the DiscreteActionMasker docs should cover that.)

Copy link
Contributor

@chriselion chriselion left a comment

Choose a reason for hiding this comment

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

Just some doc suggestions.

vincentpierre and others added 2 commits February 27, 2020 18:09
Co-Authored-By: Chris Elion <chris.elion@unity3d.com>
@vincentpierre vincentpierre merged commit ad27b4d into master Feb 28, 2020
@delete-merged-branch delete-merged-branch bot deleted the develop-masking branch February 28, 2020 17:44
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants