public void TestBasicExploration() { bool[,] map = new bool[5, 5]; ExplorationMap.Configuration config = defaultConfig; config.visibilityCheck = v => map[v.y, v.x]; ExplorationMap dut = new ExplorationMap(config); Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); dut.Update(); Assert.IsTrue(dut.map[2, 2].needsVisit); Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, v, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); dut.Update(); Assert.IsFalse(dut.map[2, 2].needsVisit); Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); for (int i = 0; i < 10; i++) { dut.Update(); Assert.IsFalse(dut.map[2, 2].needsVisit); } dut.Update(); Assert.IsTrue(dut.map[2, 2].needsVisit); }
public void TestCritical() { bool[,] map = new bool[5, 5]; ExplorationMap.Configuration config = defaultConfig; config.visibilityCheck = v => map[v.y, v.x]; ExplorationMap dut = new ExplorationMap(config); dut.SetCriticalZone(new Vector2i(3, 2), 1); Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); dut.Update(); Assert.IsTrue(dut.map[3, 2].needsVisit); Assert.IsTrue(dut.map[3, 1].needsVisit); Assert.IsTrue(dut.map[1, 1].needsVisit); Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, v, _, v, _ }, { _, _, _, v, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); dut.Update(); Assert.IsFalse(dut.map[3, 2].needsVisit); Assert.IsFalse(dut.map[3, 1].needsVisit); Assert.IsFalse(dut.map[1, 1].needsVisit); Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, v, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); dut.Update(); Assert.IsFalse(dut.map[3, 2].needsVisit); Assert.IsFalse(dut.map[3, 1].needsVisit); Assert.IsFalse(dut.map[1, 1].needsVisit); for (int i = 0; i < 2; i++) { dut.Update(); } // // CRITICAL ZONE ACTIVATES HERE // Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); dut.Update(); Assert.IsTrue(dut.map[3, 2].needsVisit); Assert.IsTrue(dut.map[3, 1].needsVisit); Assert.IsFalse(dut.map[1, 1].needsVisit); Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, v, _, v, _ }, { _, _, _, v, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); dut.Update(); Assert.IsFalse(dut.map[3, 2].needsVisit); Assert.IsFalse(dut.map[3, 1].needsVisit); Assert.IsFalse(dut.map[1, 1].needsVisit); Copy(new bool[5, 5] { { _, _, _, _, _ }, { _, v, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, { _, _, _, _, _ }, }, map, 5, 5); dut.Update(); Assert.IsTrue(dut.map[3, 2].needsVisit); Assert.IsTrue(dut.map[3, 1].needsVisit); Assert.IsFalse(dut.map[1, 1].needsVisit); for (int i = 0; i < 2; i++) { dut.Update(); } }