public void PerceiveNotSelf() { testGo.tag = k_Tag2; string[] tags = { k_Tag1, k_Tag2 }; gridSensorComponent.SetComponentParameters(tags, useGridSensorBase: true); 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); }
public void TestOneHotSensor() { testGo.tag = k_Tag2; string[] tags = { k_Tag1, k_Tag2 }; gridSensorComponent.SetComponentParameters(tags, useOneHotTag: true); var gridSensor = (OneHotGridSensor)gridSensorComponent.CreateSensors()[0]; Assert.AreEqual(gridSensor.PerceptionBuffer.Length, 10 * 10 * 2); gridSensor.Update(); int[] subarrayIndicies = new int[] { 77, 78, 87, 88 }; float[][] expectedSubarrays = GridObsTestUtils.DuplicateArray(new float[] { 1, 0 }, 4); float[] expectedDefault = new float[] { 0, 0 }; GridObsTestUtils.AssertSubarraysAtIndex(gridSensor.PerceptionBuffer, subarrayIndicies, expectedSubarrays, expectedDefault); }
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); }