示例#1
0
    /// <summary>
    /// Configures the agent. Given an integer config, the wall will have
    /// different height and a different brain will be assigned to the agent.
    /// </summary>
    /// <param name="config">Config.
    /// If 0 : No wall and noWallBrain.
    /// If 1:  Small wall and smallWallBrain.
    /// Other : Tall wall and BigWallBrain.
    /// </param>
    void ConfigureAgent(int config)
    {
        var localScale = wall.transform.localScale;

        if (config == 0)
        {
            localScale = new Vector3(
                localScale.x,
                m_FloatProperties.GetPropertyWithDefault("no_wall_height", 0),
                localScale.z);
            wall.transform.localScale = localScale;
            SetModel("SmallWallJump", noWallBrain);
        }
        else if (config == 1)
        {
            localScale = new Vector3(
                localScale.x,
                m_FloatProperties.GetPropertyWithDefault("small_wall_height", 4),
                localScale.z);
            wall.transform.localScale = localScale;
            SetModel("SmallWallJump", smallWallBrain);
        }
        else
        {
            var min    = m_FloatProperties.GetPropertyWithDefault("big_wall_min_height", 8);
            var max    = m_FloatProperties.GetPropertyWithDefault("big_wall_max_height", 8);
            var height = min + Random.value * (max - min);
            localScale = new Vector3(
                localScale.x,
                height,
                localScale.z);
            wall.transform.localScale = localScale;
            SetModel("BigWallJump", bigWallBrain);
        }
    }
示例#2
0
    public void SetEnvironment()
    {
        transform.position = m_InitialPosition * (m_ResetParameters.GetPropertyWithDefault("gridSize", 5f) + 1);
        var playersList = new List <int>();

        for (var i = 0; i < (int)m_ResetParameters.GetPropertyWithDefault("numObstacles", 1); i++)
        {
            playersList.Add(1);
        }

        for (var i = 0; i < (int)m_ResetParameters.GetPropertyWithDefault("numGoals", 1f); i++)
        {
            playersList.Add(0);
        }
        players = playersList.ToArray();

        var gridSize = (int)m_ResetParameters.GetPropertyWithDefault("gridSize", 5f);

        m_Plane.transform.localScale    = new Vector3(gridSize / 10.0f, 1f, gridSize / 10.0f);
        m_Plane.transform.localPosition = new Vector3((gridSize - 1) / 2f, -0.5f, (gridSize - 1) / 2f);
        m_Sn.transform.localScale       = new Vector3(1, 1, gridSize + 2);
        m_Ss.transform.localScale       = new Vector3(1, 1, gridSize + 2);
        m_Sn.transform.localPosition    = new Vector3((gridSize - 1) / 2f, 0.0f, gridSize);
        m_Ss.transform.localPosition    = new Vector3((gridSize - 1) / 2f, 0.0f, -1);
        m_Se.transform.localScale       = new Vector3(1, 1, gridSize + 2);
        m_Sw.transform.localScale       = new Vector3(1, 1, gridSize + 2);
        m_Se.transform.localPosition    = new Vector3(gridSize, 0.0f, (gridSize - 1) / 2f);
        m_Sw.transform.localPosition    = new Vector3(-1, 0.0f, (gridSize - 1) / 2f);

        m_AgentCam.orthographicSize        = (gridSize) / 2f;
        m_AgentCam.transform.localPosition = new Vector3((gridSize - 1) / 2f, gridSize + 1f, (gridSize - 1) / 2f);
    }
    public void SetBall()
    {
        //Set the attributes of the ball by fetching the information from the academy
        m_BallRb.mass = m_ResetParams.GetPropertyWithDefault("mass", 1.0f);
        var scale = m_ResetParams.GetPropertyWithDefault("scale", 1.0f);

        ball.transform.localScale = new Vector3(scale, scale, scale);
    }
 public void SetRacket()
 {
     angle = m_ResetParams.GetPropertyWithDefault("angle", 55);
     gameObject.transform.eulerAngles = new Vector3(
         gameObject.transform.eulerAngles.x,
         gameObject.transform.eulerAngles.y,
         m_InvertMult * angle
         );
 }
        public void TestFloatPropertiesSideChannel()
        {
            var k1        = "gravity";
            var k2        = "length";
            int wasCalled = 0;

            var propA        = new FloatPropertiesChannel();
            var propB        = new FloatPropertiesChannel();
            var dictReceiver = new Dictionary <Guid, SideChannel> {
                { propA.ChannelId, propA }
            };
            var dictSender = new Dictionary <Guid, SideChannel> {
                { propB.ChannelId, propB }
            };

            propA.RegisterCallback(k1, f => { wasCalled++; });
            var tmp = propB.GetPropertyWithDefault(k2, 3.0f);

            Assert.AreEqual(tmp, 3.0f);
            propB.SetProperty(k2, 1.0f);
            tmp = propB.GetPropertyWithDefault(k2, 3.0f);
            Assert.AreEqual(tmp, 1.0f);

            byte[] fakeData = SideChannelUtils.GetSideChannelMessage(dictSender);
            SideChannelUtils.ProcessSideChannelData(dictReceiver, fakeData);

            tmp = propA.GetPropertyWithDefault(k2, 3.0f);
            Assert.AreEqual(tmp, 1.0f);

            Assert.AreEqual(wasCalled, 0);
            propB.SetProperty(k1, 1.0f);
            Assert.AreEqual(wasCalled, 0);
            fakeData = SideChannelUtils.GetSideChannelMessage(dictSender);
            SideChannelUtils.ProcessSideChannelData(dictReceiver, fakeData);
            Assert.AreEqual(wasCalled, 1);

            var keysA = propA.ListProperties();

            Assert.AreEqual(2, keysA.Count);
            Assert.IsTrue(keysA.Contains(k1));
            Assert.IsTrue(keysA.Contains(k2));

            var keysB = propA.ListProperties();

            Assert.AreEqual(2, keysB.Count);
            Assert.IsTrue(keysB.Contains(k1));
            Assert.IsTrue(keysB.Contains(k2));
        }
        public void TestFloatPropertiesSideChannel()
        {
            var k1        = "gravity";
            var k2        = "length";
            int wasCalled = 0;

            var propA        = new FloatPropertiesChannel();
            var propB        = new FloatPropertiesChannel();
            var dictReceiver = new Dictionary <Guid, SideChannel> {
                { propA.ChannelId, propA }
            };
            var dictSender = new Dictionary <Guid, SideChannel> {
                { propB.ChannelId, propB }
            };

            propA.RegisterCallback(k1, f => { wasCalled++; });
            var tmp = propB.GetPropertyWithDefault(k2, 3.0f);

            Assert.AreEqual(tmp, 3.0f);
            propB.SetProperty(k2, 1.0f);
            tmp = propB.GetPropertyWithDefault(k2, 3.0f);
            Assert.AreEqual(tmp, 1.0f);

            byte[] fakeData = RpcCommunicator.GetSideChannelMessage(dictSender);
            RpcCommunicator.ProcessSideChannelData(dictReceiver, fakeData);

            tmp = propA.GetPropertyWithDefault(k2, 3.0f);
            Assert.AreEqual(tmp, 1.0f);

            Assert.AreEqual(wasCalled, 0);
            propB.SetProperty(k1, 1.0f);
            Assert.AreEqual(wasCalled, 0);
            fakeData = RpcCommunicator.GetSideChannelMessage(dictSender);
            RpcCommunicator.ProcessSideChannelData(dictReceiver, fakeData);
            Assert.AreEqual(wasCalled, 1);
        }
示例#7
0
    public void SetTargetScale()
    {
        var targetScale = m_ResetParams.GetPropertyWithDefault("target_scale", 1.0f);

        target.transform.localScale = new Vector3(targetScale, targetScale, targetScale);
    }
 public void SetTorsoMass()
 {
     m_ChestRb.mass = m_ResetParams.GetPropertyWithDefault("chest_mass", 8);
     m_SpineRb.mass = m_ResetParams.GetPropertyWithDefault("spine_mass", 10);
     m_HipsRb.mass  = m_ResetParams.GetPropertyWithDefault("hip_mass", 15);
 }
示例#9
0
 //時間で定期的に呼ばれる。詳しいことはわかんない
 void FixedUpdate()
 {
     curic = (int)curriculum.GetPropertyWithDefault("ChallengeComplexity", 0); //右の数字なんもわかってない
 }