Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Resolved Play mode testing with ML Agents

Discussion in 'ML-Agents' started by StewedHarry, Jul 31, 2020.

  1. StewedHarry


    Jan 20, 2020
    I was trying to run some play-mode tests for a training scenario and encountered problems which I have subsequently solved. I am sharing here in case anyone else runs into the same issue.

    My tests are relatively simple - a training instance prefab is instantiated and then tests are conducted on it.

    Running consecutive tests (e.g. 'run all') would cause most of the tests to fail, whereas they would pass when run individually.

    I have been using the Academy.Instance.OnEnvironmentReset event system to set up the training environment. However, this was creating the unwanted behaviour above because it is a singleton, and some state from the previous tests was being left over and causing the subsequent tests to fail.

    This is fixed by adding a setup and teardown method to the test class which calls the Acedemy.Instance.Dispose method:

    Code (CSharp):
    1. [TearDown]
    2. public void TearDown()
    3. {
    4.      Academy.Instance.Dispose();
    5. }