ppo-Pyramids-Training
/
com.unity.ml-agents
/Tests
/Editor
/SideChannels
/EngineConfigurationChannelTests.cs
using NUnit.Framework; | |
using Unity.MLAgents.SideChannels; | |
using UnityEngine; | |
namespace Unity.MLAgents.Tests | |
{ | |
public class EngineConfigurationChannelTests | |
{ | |
float m_OldTimeScale = 1.0f; | |
[ | ]|
public void Setup() | |
{ | |
m_OldTimeScale = Time.timeScale; | |
} | |
[ | ]|
public void TearDown() | |
{ | |
Time.timeScale = m_OldTimeScale; | |
} | |
[ | ]|
public void TestTimeScaleClamping() | |
{ | |
OutgoingMessage pythonMsg = new OutgoingMessage(); | |
pythonMsg.WriteInt32((int)EngineConfigurationChannel.ConfigurationType.TimeScale); | |
pythonMsg.WriteFloat32(1000f); | |
var sideChannel = new EngineConfigurationChannel(); | |
sideChannel.ProcessMessage(pythonMsg.ToByteArray()); | |
// Should be clamped | |
Assert.AreEqual(100.0f, Time.timeScale); | |
// Not sure we can run this test from a player, but just in case, shouldn't clamp. | |
Assert.AreEqual(1000.0f, Time.timeScale); | |
} | |
} | |
} | |