예제 #1
0
        public void OneChannelDepthOne()
        {
            string[] tags = { "Box", "Ball" };
            int[] depths = { 1 };
            Color[] colors = { Color.magenta };
            GridObsTestUtils.SetComponentParameters(gridSensorComponent, tags, depths, GridDepthType.ChannelHot,
                1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            var gridSensor = (GridSensor)gridSensorComponent.CreateSensors()[0];

            var expectedShape = new InplaceArray<int>(10, 10, 1);
            Assert.AreEqual(expectedShape, gridSensor.GetObservationSpec().Shape);
        }
예제 #2
0
 public void OneTagMoreDepthError()
 {
     string[] tags   = { "block" };
     int[]    depths = { 1, 1 };
     Color[]  colors = { Color.magenta };
     GridObsTestUtils.SetComponentParameters(gridSensorComponent, tags, depths, GridDepthType.Counting, 1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
     Assert.Throws <UnityAgentsException>(() =>
     {
         gridSensorComponent.CreateSensors();
     });
 }
        public IEnumerator OneChannelDepthOneCount()
        {
            string[] tags   = { k_Tag1 };
            int[]    depths = { 1 };
            Color[]  colors = { Color.red, Color.magenta };
            GridObsTestUtils.SetComponentParameters(gridSensorComponent, tags, depths, GridDepthType.Counting,
                                                    1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            var gridSensor = (GridSensor)gridSensorComponent.CreateSensors()[0];

            yield return(null);

            gridSensor.Perceive();

            Assert.AreEqual(10 * 10 * 1, gridSensor.m_PerceptionBuffer.Length);

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