Esempio n. 1
0
        public void TestBufferSize()
        {
            testGo.tag = k_Tag2;
            string[] tags = { k_Tag1, k_Tag2 };
            gridSensorComponent.SetComponentParameters(tags, gridSizeX: 3, gridSizeZ: 4, useTestingGridSensor: true);
            TestGridSensorConfig.SetParameters(5, true, false);
            var gridSensor = (SimpleTestGridSensor)gridSensorComponent.CreateSensors()[0];

            Assert.AreEqual(gridSensor.PerceptionBuffer.Length, 3 * 4 * 5);
        }
Esempio n. 2
0
        public void TestCustomSensorInvalidData()
        {
            testGo.tag = k_Tag2;
            string[] tags = { k_Tag1, k_Tag2 };
            gridSensorComponent.SetComponentParameters(tags, compression: SensorCompressionType.PNG, useTestingGridSensor: true);
            TestGridSensorConfig.SetParameters(5, true, false);
            var gridSensor = (SimpleTestGridSensor)gridSensorComponent.CreateSensors()[0];

            gridSensor.DummyData = new float[] { 1, 2, 3, 4, 5 };
            Assert.Throws <UnityAgentsException>(() =>
            {
                gridSensor.Update();
            });
        }
Esempio n. 3
0
        public IEnumerator SetupScene()
        {
            testGo = new GameObject("test");
            testGo.transform.position = Vector3.zero;
            gridSensorComponent       = testGo.AddComponent <SimpleTestGridSensorComponent>();

            boxGo     = new GameObject("block");
            boxGo.tag = k_Tag1;
            boxGo.transform.position = new Vector3(3f, 0f, 3f);
            boxGo.AddComponent <BoxCollider>();

            TestGridSensorConfig.Reset();
            yield return(null);
        }
Esempio n. 4
0
        public void TestReset()
        {
            testGo.tag = k_Tag2;
            string[] tags = { k_Tag1, k_Tag2 };
            gridSensorComponent.SetComponentParameters(tags, useGridSensorBase: true);
            TestGridSensorConfig.SetParameters(3, false, false);
            var gridSensor = (GridSensorBase)gridSensorComponent.CreateSensors()[0];

            gridSensor.Update();

            int[]     subarrayIndicies  = new int[] { 77, 78, 87, 88 };
            float[][] expectedSubarrays = GridObsTestUtils.DuplicateArray(new float[] { 1 }, 4);
            float[]   expectedDefault   = new float[] { 0 };
            GridObsTestUtils.AssertSubarraysAtIndex(gridSensor.PerceptionBuffer, subarrayIndicies, expectedSubarrays, expectedDefault);
            Object.DestroyImmediate(boxGo);

            gridSensor.Update();

            subarrayIndicies  = new int[0];
            expectedSubarrays = new float[0][];
            GridObsTestUtils.AssertSubarraysAtIndex(gridSensor.PerceptionBuffer, subarrayIndicies, expectedSubarrays, expectedDefault);
        }