Skip to content

Add warning to academy docs #4226

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

Closed
wants to merge 4 commits into from
Closed

Add warning to academy docs #4226

wants to merge 4 commits into from

Conversation

andrewcoh
Copy link
Contributor

Proposed change(s)

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

#4220

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

@andrewcoh andrewcoh requested a review from vincentpierre July 14, 2020 17:07

In some games, it may be desirable to step the environment with the Academy manually via `Academy.Instance.EnvironmentStep()`.
If this is the case, be sure `Academy.Instance.EnvironmentStep()` is not called directly or indirectly by the agent's
`CollectObservations()` function as this will cause an infinite loop that prevents that main Academy update function from being called.
Copy link
Contributor

Choose a reason for hiding this comment

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

CollectObservations is not the only method that might pose problems. Anything called BY the EnvironmentStep will be problematic. For example: Heuristic and OnActionReceived.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to guard against this? We could do something like

public void EnvironmentStep() {
  if(m_Stepping) {
    throw new UnityException("Infinite recursion prevented!");
  }
  m_Stepping = true;
  // do all the work
  m_Stepping = false;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That works for me. It's up to you both.

Copy link
Contributor

Choose a reason for hiding this comment

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

(with maybe a try/finally around the main body to reset the stepping flag, and/or change the throw to just return)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vincentpierre thoughts?

Co-authored-by: Vincent-Pierre BERGES <[email protected]>
@andrewcoh
Copy link
Contributor Author

Closing because this was made obsolete by #4227

@andrewcoh andrewcoh closed this Jul 15, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 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.

3 participants