Example #1
0
        public void TestAcademyDispose()
        {
            var floatProperties1 = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>();

            Academy.Instance.Dispose();

            Academy.Instance.LazyInitialize();
            var floatProperties2 = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>();

            Academy.Instance.Dispose();

            Assert.AreNotEqual(floatProperties1, floatProperties2);
        }
Example #2
0
    public override void Initialize()
    {
        m_WallJumpSettings = FindObjectOfType <WallJumpSettings>();
        m_Configuration    = Random.Range(0, 5);

        m_AgentRb         = GetComponent <Rigidbody>();
        m_ShortBlockRb    = shortBlock.GetComponent <Rigidbody>();
        m_SpawnAreaBounds = spawnArea.GetComponent <Collider>().bounds;
        m_GroundRenderer  = ground.GetComponent <Renderer>();
        m_GroundMaterial  = m_GroundRenderer.material;

        spawnArea.SetActive(false);

        m_FloatProperties = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>();
    }
Example #3
0
 public override void OnEpisodeBegin()
 {
     timePenalty = 0;
     m_BallTouch = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>().GetPropertyWithDefault("ball_touch", 0);
     if (team == Team.Purple)
     {
         transform.rotation = Quaternion.Euler(0f, -90f, 0f);
     }
     else
     {
         transform.rotation = Quaternion.Euler(0f, 90f, 0f);
     }
     transform.position      = m_Transform;
     agentRb.velocity        = Vector3.zero;
     agentRb.angularVelocity = Vector3.zero;
     SetResetParameters();
 }
        public void Awake()
        {
            // Save the original values
            m_OriginalGravity                  = Physics.gravity;
            m_OriginalFixedDeltaTime           = Time.fixedDeltaTime;
            m_OriginalMaximumDeltaTime         = Time.maximumDeltaTime;
            m_OriginalSolverIterations         = Physics.defaultSolverIterations;
            m_OriginalSolverVelocityIterations = Physics.defaultSolverVelocityIterations;

            // Override
            Physics.gravity                        *= gravityMultiplier;
            Time.fixedDeltaTime                     = fixedDeltaTime;
            Time.maximumDeltaTime                   = maximumDeltaTime;
            Physics.defaultSolverIterations         = solverIterations;
            Physics.defaultSolverVelocityIterations = solverVelocityIterations;

            SideChannelUtils.GetSideChannel <FloatPropertiesChannel>().RegisterCallback("gravity", f => { Physics.gravity = new Vector3(0, -f, 0); });
        }
Example #5
0
    public override void Initialize()
    {
        m_AgentRb = GetComponent <Rigidbody>();
        m_BallRb  = ball.GetComponent <Rigidbody>();
        var        canvas = GameObject.Find(k_CanvasName);
        GameObject scoreBoard;

        m_ResetParams = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>();
        if (invertX)
        {
            scoreBoard = canvas.transform.Find(k_ScoreBoardBName).gameObject;
        }
        else
        {
            scoreBoard = canvas.transform.Find(k_ScoreBoardAName).gameObject;
        }
        m_TextComponent = scoreBoard.GetComponent <Text>();
        SetResetParameters();
    }
Example #6
0
    public void Start()
    {
        m_ResetParameters = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>();

        m_Objects = new[] { goalPref, pitPref };

        m_AgentCam = transform.Find("agentCam").GetComponent <Camera>();

        actorObjs = new List <GameObject>();

        var sceneTransform = transform.Find("scene");

        m_Plane           = sceneTransform.Find("Plane").gameObject;
        m_Sn              = sceneTransform.Find("sN").gameObject;
        m_Ss              = sceneTransform.Find("sS").gameObject;
        m_Sw              = sceneTransform.Find("sW").gameObject;
        m_Se              = sceneTransform.Find("sE").gameObject;
        m_InitialPosition = transform.position;
    }
Example #7
0
        public void TestAcademy()
        {
            Assert.AreEqual(false, Academy.IsInitialized);
            var aca = Academy.Instance;

            Assert.AreEqual(true, Academy.IsInitialized);

            // Check that init is idempotent
            aca.LazyInitialize();
            aca.LazyInitialize();

            Assert.AreEqual(0, aca.EpisodeCount);
            Assert.AreEqual(0, aca.StepCount);
            Assert.AreEqual(0, aca.TotalStepCount);
            Assert.AreNotEqual(null, SideChannelUtils.GetSideChannel <FloatPropertiesChannel>());

            // Check that Dispose is idempotent
            aca.Dispose();
            Assert.AreEqual(false, Academy.IsInitialized);
            aca.Dispose();
        }
        public void Awake()
        {
            // Save the original values
            m_OriginalGravity                  = Physics.gravity;
            m_OriginalFixedDeltaTime           = Time.fixedDeltaTime;
            m_OriginalMaximumDeltaTime         = Time.maximumDeltaTime;
            m_OriginalSolverIterations         = Physics.defaultSolverIterations;
            m_OriginalSolverVelocityIterations = Physics.defaultSolverVelocityIterations;

            // Override
            Physics.gravity                        *= gravityMultiplier;
            Time.fixedDeltaTime                     = fixedDeltaTime;
            Time.maximumDeltaTime                   = maximumDeltaTime;
            Physics.defaultSolverIterations         = solverIterations;
            Physics.defaultSolverVelocityIterations = solverVelocityIterations;

            // Make sure the Academy singleton is initialized first, since it will create the SideChannels.
            var academy = Academy.Instance;

            SideChannelUtils.GetSideChannel <FloatPropertiesChannel>().RegisterCallback("gravity", f => { Physics.gravity = new Vector3(0, -f, 0); });
        }
 public void Awake()
 {
     Academy.Instance.OnEnvironmentReset += EnvironmentReset;
     m_statsSideChannel = SideChannelUtils.GetSideChannel <StatsSideChannel>();
 }
 public override void Initialize()
 {
     m_BallRb      = ball.GetComponent <Rigidbody>();
     m_ResetParams = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>();
     SetResetParameters();
 }
    public void SetAgentScale()
    {
        float agentScale = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>().GetPropertyWithDefault("agent_scale", 1.0f);

        gameObject.transform.localScale = new Vector3(agentScale, agentScale, agentScale);
    }
 public void SetLaserLengths()
 {
     m_LaserLength = SideChannelUtils.GetSideChannel <FloatPropertiesChannel>().GetPropertyWithDefault("laser_length", 1.0f);
 }