コード例 #1
0
        public void TestVectorObservations()
        {
            var boardString =
                @"000
                  000
                  010";
            var gameObj = new GameObject("board");
            var board   = gameObj.AddComponent <StringBoard>();

            board.SetBoard(boardString);

            var sensorComponent = gameObj.AddComponent <Match3SensorComponent>();

            sensorComponent.ObservationType = Match3ObservationType.Vector;
            var sensor = sensorComponent.CreateSensor();

            var expectedShape = new[] { 3 * 3 * 2 };

            Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape());
            Assert.AreEqual(InplaceArray <int> .FromList(expectedShape), sensor.GetObservationSpec().Shape);

            var expectedObs = new float[]
            {
                1, 0, /**/ 0, 1, /**/ 1, 0,
                1, 0, /**/ 1, 0, /**/ 1, 0,
                1, 0, /**/ 1, 0, /**/ 1, 0,
            };

            SensorTestHelper.CompareObservation(sensor, expectedObs);
        }
        public void TestRenderTextureSensorComponent()
        {
            foreach (var grayscale in new[] { true, false })
            {
                foreach (SensorCompressionType compression in Enum.GetValues(typeof(SensorCompressionType)))
                {
                    var width   = 24;
                    var height  = 16;
                    var texture = new RenderTexture(width, height, 0);

                    var agentGameObj = new GameObject("agent");

                    var renderTexComponent = agentGameObj.AddComponent <RenderTextureSensorComponent>();
                    renderTexComponent.RenderTexture   = texture;
                    renderTexComponent.Grayscale       = grayscale;
                    renderTexComponent.CompressionType = compression;

                    var expectedShape = new InplaceArray <int>(height, width, grayscale ? 1 : 3);

                    var sensor = renderTexComponent.CreateSensors()[0];
                    Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape);
                    Assert.AreEqual(typeof(RenderTextureSensor), sensor.GetType());
                }
            }
        }
コード例 #3
0
        public void TestBufferSensor()
        {
            var bufferSensor = new BufferSensor(20, 4, "testName");
            var shape        = bufferSensor.GetObservationSpec().Shape;
            var dimProp      = bufferSensor.GetObservationSpec().DimensionProperties;

            Assert.AreEqual(shape[0], 20);
            Assert.AreEqual(shape[1], 4);
            Assert.AreEqual(shape.Length, 2);
            Assert.AreEqual(dimProp[0], DimensionProperty.VariableSize);
            Assert.AreEqual(dimProp[1], DimensionProperty.None);
            Assert.AreEqual(dimProp.Length, 2);

            bufferSensor.AppendObservation(new float[] { 1, 2, 3, 4 });
            bufferSensor.AppendObservation(new float[] { 5, 6, 7, 8 });

            var obsWriter = new ObservationWriter();
            var obs       = bufferSensor.GetObservationProto(obsWriter);

            Assert.AreEqual(shape, InplaceArray <int> .FromList(obs.Shape));
            Assert.AreEqual(obs.DimensionProperties.Count, 2);
            Assert.AreEqual((int)dimProp[0], obs.DimensionProperties[0]);
            Assert.AreEqual((int)dimProp[1], obs.DimensionProperties[1]);

            for (int i = 0; i < 8; i++)
            {
                Assert.AreEqual(obs.FloatData.Data[i], i + 1);
            }
            for (int i = 8; i < 80; i++)
            {
                Assert.AreEqual(obs.FloatData.Data[i], 0);
            }
        }
コード例 #4
0
        public void TestCompressedVisualObservations()
        {
            var boardString =
                @"000
                  000
                  010";
            var gameObj = new GameObject("board");
            var board   = gameObj.AddComponent <StringBoard>();

            board.SetBoard(boardString);

            var sensorComponent = gameObj.AddComponent <Match3SensorComponent>();

            sensorComponent.ObservationType = Match3ObservationType.CompressedVisual;
            var sensor = sensorComponent.CreateSensor();

            var expectedShape = new[] { 3, 3, 2 };

            Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape());
            Assert.AreEqual(InplaceArray <int> .FromList(expectedShape), sensor.GetObservationSpec().Shape);

            Assert.AreEqual(SensorCompressionType.PNG, sensor.GetCompressionType());

            var pngData = sensor.GetCompressedObservation();

            if (WritePNGDataToFile)
            {
                // Enable this if the format of the observation changes
                SavePNGs(pngData, "match3obs");
            }

            var expectedPng = LoadPNGs("match3obs", 1);

            Assert.AreEqual(expectedPng, pngData);
        }
コード例 #5
0
        public void TestCameraSensorComponent()
        {
            foreach (var grayscale in new[] { true, false })
            {
                foreach (SensorCompressionType compression in Enum.GetValues(typeof(SensorCompressionType)))
                {
                    var width  = 24;
                    var height = 16;
                    var camera = Camera.main;

                    var agentGameObj = new GameObject("agent");

                    var cameraComponent = agentGameObj.AddComponent <CameraSensorComponent>();
                    cameraComponent.Camera          = camera;
                    cameraComponent.Height          = height;
                    cameraComponent.Width           = width;
                    cameraComponent.Grayscale       = grayscale;
                    cameraComponent.CompressionType = compression;

                    var sensor        = cameraComponent.CreateSensors()[0];
                    var expectedShape = new InplaceArray <int>(height, width, grayscale ? 1 : 3);
                    Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape);
                    Assert.AreEqual(typeof(CameraSensor), sensor.GetType());

                    // Make sure cleaning up the component cleans up the sensor too
                    cameraComponent.Dispose();
                    var flags = BindingFlags.Instance | BindingFlags.NonPublic;
                    var cameraComponentSensor = (CameraSensor)typeof(CameraSensorComponent).GetField("m_Sensor", flags).GetValue(cameraComponent);
                    Assert.IsNull(cameraComponentSensor);
                    var cameraTexture = (Texture2D)typeof(CameraSensor).GetField("m_Texture", flags).GetValue(sensor);
                    Assert.IsNull(cameraTexture);
                }
            }
        }
コード例 #6
0
        public void TestInplaceArrayCtor()
        {
            var a1 = new InplaceArray <int>(11);

            Assert.AreEqual(1, a1.Length);
            Assert.AreEqual(11, a1[0]);

            var a2 = new InplaceArray <int>(11, 22);

            Assert.AreEqual(2, a2.Length);
            Assert.AreEqual(11, a2[0]);
            Assert.AreEqual(22, a2[1]);

            var a3 = new InplaceArray <int>(11, 22, 33);

            Assert.AreEqual(3, a3.Length);
            Assert.AreEqual(11, a3[0]);
            Assert.AreEqual(22, a3[1]);
            Assert.AreEqual(33, a3[2]);

            var a4 = new InplaceArray <int>(11, 22, 33, 44);

            Assert.AreEqual(4, a4.Length);
            Assert.AreEqual(11, a4[0]);
            Assert.AreEqual(22, a4[1]);
            Assert.AreEqual(33, a4[2]);
            Assert.AreEqual(44, a4[3]);
        }
コード例 #7
0
        public void TestCameraSensorComponent()
        {
            foreach (var grayscale in new[] { true, false })
            {
                foreach (SensorCompressionType compression in Enum.GetValues(typeof(SensorCompressionType)))
                {
                    var width  = 24;
                    var height = 16;
                    var camera = Camera.main;

                    var agentGameObj = new GameObject("agent");

                    var cameraComponent = agentGameObj.AddComponent <CameraSensorComponent>();
                    cameraComponent.Camera          = camera;
                    cameraComponent.Height          = height;
                    cameraComponent.Width           = width;
                    cameraComponent.Grayscale       = grayscale;
                    cameraComponent.CompressionType = compression;

                    var sensor        = cameraComponent.CreateSensors()[0];
                    var expectedShape = new InplaceArray <int>(height, width, grayscale ? 1 : 3);
                    Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape);
                    Assert.AreEqual(typeof(CameraSensor), sensor.GetType());
                }
            }
        }
コード例 #8
0
        public void TestWritesToIList()
        {
            ObservationWriter writer = new ObservationWriter();
            var buffer = new[] { 0f, 0f, 0f };
            var shape  = new InplaceArray <int>(3);

            writer.SetTarget(buffer, shape, 0);
            // Elementwise writes
            writer[0] = 1f;
            writer[2] = 2f;
            Assert.AreEqual(new[] { 1f, 0f, 2f }, buffer);

            // Elementwise writes with offset
            writer.SetTarget(buffer, shape, 1);
            writer[0] = 3f;
            Assert.AreEqual(new[] { 1f, 3f, 2f }, buffer);

            // AddList
            writer.SetTarget(buffer, shape, 0);
            writer.AddList(new[] { 4f, 5f });
            Assert.AreEqual(new[] { 4f, 5f, 2f }, buffer);

            // AddList with offset
            writer.SetTarget(buffer, shape, 1);
            writer.AddList(new[] { 6f, 7f });
            Assert.AreEqual(new[] { 4f, 6f, 7f }, buffer);
        }
コード例 #9
0
        public void TestMismatchShapeDimensionPropThrows()
        {
            var shape    = new InplaceArray <int>(1, 2);
            var dimProps = new InplaceArray <DimensionProperty>(DimensionProperty.TranslationalEquivariance);

            Assert.Throws <UnityAgentsException>(() =>
            {
                new ObservationSpec(shape, dimProps);
            });
        }
コード例 #10
0
        public void TwoChannelsDepthThreeThree()
        {
            string[] tags = { "Box", "Ball" };
            int[] depths = { 3, 3 };
            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, 6);
            Assert.AreEqual(expectedShape, gridSensor.GetObservationSpec().Shape);
        }
コード例 #11
0
        public void TwoChannelsDepthThreeThree()
        {
            string[] tags   = { "Box", "Ball" };
            int[]    depths = { 3, 3 };
            Color[]  colors = { Color.magenta };
            gridSensor.SetParameters(tags, depths, GridSensor.GridDepthType.ChannelHot,
                                     1f, 1f, 10, 10, LayerMask.GetMask("Default"), false, colors);
            gridSensor.Start();

            var expectedShape = new InplaceArray <int>(10, 10, 6);

            Assert.AreEqual(expectedShape, gridSensor.GetObservationSpec().Shape);
        }
コード例 #12
0
        public void TestFromList(int length)
        {
            var intArray = new int[length];

            for (var i = 0; i < length; i++)
            {
                intArray[i] = (i + 1) * 11; // 11, 22, etc.
            }

            var converted = InplaceArray <int> .FromList(intArray);

            Assert.AreEqual(GetTestArray(length), converted);
        }
コード例 #13
0
        public void TestVectorObservationsSpecial()
        {
            var boardString =
                @"000
                  000
                  010";
            var specialString =
                @"010
                  200
                  000";

            var gameObj = new GameObject("board");
            var board   = gameObj.AddComponent <StringBoard>();

            board.SetBoard(boardString);
            board.SetSpecial(specialString);

            var sensorComponent = gameObj.AddComponent <Match3SensorComponent>();

            sensorComponent.ObservationType = Match3ObservationType.Vector;
            var sensors       = sensorComponent.CreateSensors();
            var cellSensor    = sensors[0];
            var specialSensor = sensors[1];


            {
                var expectedShape = new InplaceArray <int>(3 * 3 * 2);
                Assert.AreEqual(expectedShape, cellSensor.GetObservationSpec().Shape);

                var expectedObs = new float[]
                {
                    1, 0, /* (0) */ 0, 1, /* (1) */ 1, 0, /* (0) */
                    1, 0, /* (0) */ 1, 0, /* (0) */ 1, 0, /* (0) */
                    1, 0, /* (0) */ 1, 0, /* (0) */ 1, 0, /* (0) */
                };
                SensorTestHelper.CompareObservation(cellSensor, expectedObs);
            }
            {
                var expectedShape = new InplaceArray <int>(3 * 3 * 3);
                Assert.AreEqual(expectedShape, specialSensor.GetObservationSpec().Shape);

                var expectedObs = new float[]
                {
                    1, 0, 0, /* (0) */ 1, 0, 0, /* (1) */ 1, 0, 0, /* (0) */
                    0, 0, 1, /* (2) */ 1, 0, 0, /* (0) */ 1, 0, 0, /* (0) */
                    1, 0, 0, /* (0) */ 0, 1, 0, /* (1) */ 1, 0, 0, /* (0) */
                };
                SensorTestHelper.CompareObservation(specialSensor, expectedObs);
            }
        }
コード例 #14
0
        public void TestVectorObservations(bool fullBoard)
        {
            var boardString =
                @"000
                  000
                  010";
            var gameObj = new GameObject("board");
            var board   = gameObj.AddComponent <StringBoard>();

            board.SetBoard(boardString);
            if (!fullBoard)
            {
                board.CurrentRows    = 2;
                board.CurrentColumns = 2;
            }

            var sensorComponent = gameObj.AddComponent <Match3SensorComponent>();

            sensorComponent.ObservationType = Match3ObservationType.Vector;
            var sensor = sensorComponent.CreateSensors()[0];

            var expectedShape = new InplaceArray <int>(3 * 3 * 2);

            Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape);

            float[] expectedObs;

            if (fullBoard)
            {
                expectedObs = new float[]
                {
                    1, 0, /* 0 */ 0, 1, /* 1 */ 1, 0, /* 0 */
                    1, 0, /* 0 */ 1, 0, /* 0 */ 1, 0, /* 0 */
                    1, 0, /* 0 */ 1, 0, /* 0 */ 1, 0, /* 0 */
                };
            }
            else
            {
                expectedObs = new float[]
                {
                    1, 0, /*   0   */ 0, 1, /*   1   */ 0, 0, /* empty */
                    1, 0, /*   0   */ 1, 0, /*   0   */ 0, 0, /* empty */
                    0, 0, /* empty */ 0, 0, /* empty */ 0, 0, /* empty */
                };
            }
            SensorTestHelper.CompareObservation(sensor, expectedObs);
        }
コード例 #15
0
        public void TestVisualObservationsSpecial()
        {
            var boardString =
                @"000
                  000
                  010";
            var specialString =
                @"010
                  200
                  000";

            var gameObj = new GameObject("board");
            var board   = gameObj.AddComponent <StringBoard>();

            board.SetBoard(boardString);
            board.SetSpecial(specialString);

            var sensorComponent = gameObj.AddComponent <Match3SensorComponent>();

            sensorComponent.ObservationType = Match3ObservationType.UncompressedVisual;
            var sensor = sensorComponent.CreateSensor();

            var expectedShape = new[] { 3, 3, 2 + 3 };

            Assert.AreEqual(expectedShape, sensorComponent.GetObservationShape());
            Assert.AreEqual(InplaceArray <int> .FromList(expectedShape), sensor.GetObservationSpec().Shape);

            Assert.AreEqual(SensorCompressionType.None, sensor.GetCompressionType());

            var expectedObs = new float[]
            {
                1, 0, 1, 0, 0, /* (0, 0) */ 0, 1, 1, 0, 0, /* (0, 1) */ 1, 0, 1, 0, 0, /* (0, 0) */
                1, 0, 0, 0, 1, /* (0, 2) */ 1, 0, 1, 0, 0, /* (0, 0) */ 1, 0, 1, 0, 0, /* (0, 0) */
                1, 0, 1, 0, 0, /* (0, 0) */ 1, 0, 0, 1, 0, /* (0, 1) */ 1, 0, 1, 0, 0, /* (0, 0) */
            };

            SensorTestHelper.CompareObservation(sensor, expectedObs);

            var expectedObs3D = new float[, , ]
            {
                { { 1, 0, 1, 0, 0 }, { 0, 1, 1, 0, 0 }, { 1, 0, 1, 0, 0 } },
                { { 1, 0, 0, 0, 1 }, { 1, 0, 1, 0, 0 }, { 1, 0, 1, 0, 0 } },
                { { 1, 0, 1, 0, 0 }, { 1, 0, 0, 1, 0 }, { 1, 0, 1, 0, 0 } },
            };

            SensorTestHelper.CompareObservation(sensor, expectedObs3D);
        }
コード例 #16
0
        public void TestCompressedVisualObservationsSpecial()
        {
            var boardString =
                @"000
                  000
                  010";
            var specialString =
                @"010
                  200
                  000";

            var gameObj = new GameObject("board");
            var board   = gameObj.AddComponent <StringBoard>();

            board.SetBoard(boardString);
            board.SetSpecial(specialString);

            var sensorComponent = gameObj.AddComponent <Match3SensorComponent>();

            sensorComponent.ObservationType = Match3ObservationType.CompressedVisual;
            var sensors = sensorComponent.CreateSensors();

            var paths            = new[] { k_CellObservationPng, k_SpecialObservationPng };
            var expectedChannels = new[] { 2, 3 };

            for (var i = 0; i < 2; i++)
            {
                var sensor        = sensors[i];
                var expectedShape = new InplaceArray <int>(3, 3, expectedChannels[i]);
                Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape);

                Assert.AreEqual(SensorCompressionType.PNG, sensor.GetCompressionSpec().SensorCompressionType);

                var pngData = sensor.GetCompressedObservation();
                if (WritePNGDataToFile)
                {
                    // Enable this if the format of the observation changes
                    SavePNGs(pngData, paths[i]);
                }

                var expectedPng = LoadPNGs(paths[i], 1);
                Assert.AreEqual(expectedPng, pngData);
            }
        }
コード例 #17
0
        /// <summary>
        /// Set the writer to write to an IList at the given channelOffset.
        /// </summary>
        /// <param name="data">Float array or list that will be written to.</param>
        /// <param name="shape">Shape of the observations to be written.</param>
        /// <param name="offset">Offset from the start of the float data to write to.</param>
        internal void SetTarget(IList <float> data, InplaceArray <int> shape, int offset)
        {
            m_Data   = data;
            m_Offset = offset;
            m_Proxy  = null;
            m_Batch  = 0;

            if (shape.Length == 1)
            {
                m_TensorShape = new TensorShape(m_Batch, shape[0]);
            }
            else if (shape.Length == 2)
            {
                m_TensorShape = new TensorShape(new[] { m_Batch, 1, shape[0], shape[1] });
            }
            else
            {
                m_TensorShape = new TensorShape(m_Batch, shape[0], shape[1], shape[2]);
            }
        }
コード例 #18
0
        public void TestBufferSensorComponent()
        {
            var agentGameObj    = new GameObject("agent");
            var bufferComponent = agentGameObj.AddComponent <BufferSensorComponent>();

            bufferComponent.MaxNumObservables = 20;
            bufferComponent.ObservableSize    = 4;
            bufferComponent.SensorName        = "TestName";

            var sensor = bufferComponent.CreateSensors()[0];
            var shape  = sensor.GetObservationSpec().Shape;

            Assert.AreEqual(shape[0], 20);
            Assert.AreEqual(shape[1], 4);
            Assert.AreEqual(shape.Length, 2);

            bufferComponent.AppendObservation(new float[] { 1, 2, 3, 4 });
            bufferComponent.AppendObservation(new float[] { 5, 6, 7, 8 });

            var obsWriter = new ObservationWriter();
            var obs       = sensor.GetObservationProto(obsWriter);

            Assert.AreEqual(shape, InplaceArray <int> .FromList(obs.Shape));
            Assert.AreEqual(obs.DimensionProperties.Count, 2);

            Assert.AreEqual(sensor.GetName(), "TestName");

            for (int i = 0; i < 8; i++)
            {
                Assert.AreEqual(obs.FloatData.Data[i], i + 1);
            }
            for (int i = 8; i < 80; i++)
            {
                Assert.AreEqual(obs.FloatData.Data[i], 0);
            }
        }
コード例 #19
0
        public void TestVisualObservationsSpecial()
        {
            var boardString =
                @"000
                  000
                  010";
            var specialString =
                @"010
                  200
                  000";

            var gameObj = new GameObject("board");
            var board   = gameObj.AddComponent <StringBoard>();

            board.SetBoard(boardString);
            board.SetSpecial(specialString);

            var sensorComponent = gameObj.AddComponent <Match3SensorComponent>();

            sensorComponent.ObservationType = Match3ObservationType.UncompressedVisual;
            var sensors       = sensorComponent.CreateSensors();
            var cellSensor    = sensors[0];
            var specialSensor = sensors[1];

            {
                var expectedShape = new InplaceArray <int>(3, 3, 2);
                Assert.AreEqual(expectedShape, cellSensor.GetObservationSpec().Shape);

                Assert.AreEqual(SensorCompressionType.None, cellSensor.GetCompressionSpec().SensorCompressionType);

                var expectedObs = new float[]
                {
                    1, 0, /* (0) */ 0, 1, /* (1) */ 1, 0, /* (0) */
                    1, 0, /* (0) */ 1, 0, /* (0) */ 1, 0, /* (0) */
                    1, 0, /* (0) */ 1, 0, /* (0) */ 1, 0, /* (0) */
                };
                SensorTestHelper.CompareObservation(cellSensor, expectedObs);

                var expectedObs3D = new float[, , ]
                {
                    { { 1, 0 }, { 0, 1 }, { 1, 0 } },
                    { { 1, 0 }, { 1, 0 }, { 1, 0 } },
                    { { 1, 0 }, { 1, 0 }, { 1, 0 } },
                };
                SensorTestHelper.CompareObservation(cellSensor, expectedObs3D);
            }
            {
                var expectedShape = new InplaceArray <int>(3, 3, 3);
                Assert.AreEqual(expectedShape, specialSensor.GetObservationSpec().Shape);

                Assert.AreEqual(SensorCompressionType.None, specialSensor.GetCompressionSpec().SensorCompressionType);

                var expectedObs = new float[]
                {
                    1, 0, 0, /* (0) */ 1, 0, 0, /* (1) */ 1, 0, 0, /* (0) */
                    0, 0, 1, /* (2) */ 1, 0, 0, /* (0) */ 1, 0, 0, /* (0) */
                    1, 0, 0, /* (0) */ 0, 1, 0, /* (1) */ 1, 0, 0, /* (0) */
                };
                SensorTestHelper.CompareObservation(specialSensor, expectedObs);

                var expectedObs3D = new float[, , ]
                {
                    { { 1, 0, 0 }, { 1, 0, 0 }, { 1, 0, 0 } },
                    { { 0, 0, 1 }, { 1, 0, 0 }, { 1, 0, 0 } },
                    { { 1, 0, 0 }, { 0, 1, 0 }, { 1, 0, 0 } },
                };
                SensorTestHelper.CompareObservation(specialSensor, expectedObs3D);
            }

            // Test that Dispose() cleans up the component and its sensors
            sensorComponent.Dispose();

            var flags            = BindingFlags.Instance | BindingFlags.NonPublic;
            var componentSensors = (ISensor[])typeof(Match3SensorComponent).GetField("m_Sensors", flags).GetValue(sensorComponent);

            Assert.IsNull(componentSensors);
            var cellTexture = (Texture2D)typeof(Match3Sensor).GetField("m_ObservationTexture", flags).GetValue(cellSensor);

            Assert.IsNull(cellTexture);
            var specialTexture = (Texture2D)typeof(Match3Sensor).GetField("m_ObservationTexture", flags).GetValue(cellSensor);

            Assert.IsNull(specialTexture);
        }
コード例 #20
0
        public void TestCompressedVisualObservationsSpecial(bool fullBoard, bool useSpecial)
        {
            var boardString =
                @"003
                  000
                  010";
            var specialString =
                @"014
                  200
                  000";

            var gameObj = new GameObject("board");
            var board   = gameObj.AddComponent <StringBoard>();

            board.SetBoard(boardString);
            var paths = new List <string> {
                k_CellObservationPng
            };

            if (useSpecial)
            {
                board.SetSpecial(specialString);
                paths.Add(k_SpecialObservationPng);
            }

            if (!fullBoard)
            {
                // Shrink the board, and change the paths we're using for the ground truth PNGs
                board.CurrentRows    = 2;
                board.CurrentColumns = 2;
                for (var i = 0; i < paths.Count; i++)
                {
                    paths[i] = paths[i] + k_Suffix2x2;
                }
            }

            var sensorComponent = gameObj.AddComponent <Match3SensorComponent>();

            sensorComponent.ObservationType = Match3ObservationType.CompressedVisual;
            var sensors = sensorComponent.CreateSensors();

            var expectedNumChannels = new[] { 4, 5 };

            for (var i = 0; i < paths.Count; i++)
            {
                var sensor        = sensors[i];
                var expectedShape = new InplaceArray <int>(3, 3, expectedNumChannels[i]);
                Assert.AreEqual(expectedShape, sensor.GetObservationSpec().Shape);

                Assert.AreEqual(SensorCompressionType.PNG, sensor.GetCompressionSpec().SensorCompressionType);

                var pngData = sensor.GetCompressedObservation();
                if (WritePNGDataToFile)
                {
                    // Enable this if the format of the observation changes
                    SavePNGs(pngData, paths[i]);
                }

                var expectedPng = LoadPNGs(paths[i], 2);
                Assert.AreEqual(expectedPng, pngData);
            }
        }