Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions UnitySDK/Assets/ML-Agents/Editor/Tests/DemonstrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@

namespace MLAgents.Tests
{
[TestFixture]
public class DemonstrationTests : MonoBehaviour
{
const string k_DemoDirecory = "Assets/Demonstrations/";
const string k_ExtensionType = ".demo";
const string k_DemoName = "Test";

[SetUp]
public void SetUp()
{
Academy.Instance.Dispose();
}

[Test]
public void TestSanitization()
{
Expand Down Expand Up @@ -90,19 +97,12 @@ public void TestAgentWrite()
demoRecorder.record = true;
demoRecorder.InitializeDemoStore(fileSystem);

var acaGo = new GameObject("TestAcademy");
acaGo.AddComponent<Academy>();
var aca = acaGo.GetComponent<Academy>();

var academyInitializeMethod = typeof(Academy).GetMethod("InitializeEnvironment",
BindingFlags.Instance | BindingFlags.NonPublic);
var agentEnableMethod = typeof(Agent).GetMethod("OnEnable",
BindingFlags.Instance | BindingFlags.NonPublic);
var agentSendInfo = typeof(Agent).GetMethod("SendInfo",
BindingFlags.Instance | BindingFlags.NonPublic);

agentEnableMethod?.Invoke(agent1, new object[] { });
academyInitializeMethod?.Invoke(aca, new object[] { });

// Step the agent
agent1.RequestDecision();
Expand All @@ -126,6 +126,8 @@ public void TestAgentWrite()
}
}

Academy.Instance.Dispose();


}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

namespace MLAgents.Tests
{
[TestFixture]
public class EditModeTestInternalBrainTensorGenerator
{
static IEnumerable<Agent> GetFakeAgents()
[SetUp]
public void SetUp()
{
var acaGo = new GameObject("TestAcademy");
acaGo.AddComponent<Academy>();
var aca = acaGo.GetComponent<Academy>();
Academy.Instance.Dispose();
}

static IEnumerable<Agent> GetFakeAgents()
{
var goA = new GameObject("goA");
var bpA = goA.AddComponent<BehaviorParameters>();
bpA.brainParameters.vectorObservationSize = 3;
Expand All @@ -33,7 +36,7 @@ static IEnumerable<Agent> GetFakeAgents()
{
var agentEnableMethod = typeof(Agent).GetMethod("OnEnableHelper",
BindingFlags.Instance | BindingFlags.NonPublic);
agentEnableMethod?.Invoke(agent, new object[] { aca });
agentEnableMethod?.Invoke(agent, new object[] { });
}
agentA.collectObservationsSensor.AddObservation(new Vector3(1, 2, 3));
agentB.collectObservationsSensor.AddObservation(new Vector3(4, 5, 6));
Expand Down
Loading