def test_SearchNotPossible_ShouldReturnFalse(self):
        ValidationUtility.set_up_test_method('impossible', Node((2, 0, 0)),
                                             Node((0, 0, 0)))

        result = ValidationUtility.a_star_controller.search_path()

        self.assertFalse(result)
Beispiel #2
0
    def test_DestroyWithBlaster_ShouldCostOne(self):
        ValidationUtility.set_up_test_method('destroy', Node((0, 0, 0)),
                                             Node((0, 0, 0)))

        expected = 1
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) - 1].g  # get the final cost

        self.assertEqual(expected, actual)
    def test_BlastWall_ShouldCostThree(self):
        ValidationUtility.set_up_test_method('blasting', Node((1, 0, 0)),
                                             Node((0, 0, 0)))

        # cost 3 to blast through wall
        # cost 1 to destroy
        expected = 4
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) - 1].g  # get the final cost

        self.assertEqual(expected, actual)
    def test_Door_ShouldCostTwo(self):
        ValidationUtility.set_up_test_method('simple_links', Node((1, 0, 0)),
                                             Node((0, 0, 0)))

        # cost 2 through door
        # cost 1 to destroy
        expected = 3
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) - 1].g  # get the final cost

        self.assertEqual(expected, actual)
    def test_LadderDown_ShouldCostPointFive(self):
        ValidationUtility.set_up_test_method('simple_links', Node((0, 0, 1)),
                                             Node((0, 0, 0)))

        # cost 0.5 through ladder down
        # cost 1 to destroy
        expected = 1.5
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) - 1].g  # get the final cost

        self.assertEqual(expected, actual)
    def test_Search_ShouldTakeCheaperPath(self):
        ValidationUtility.set_up_test_method('cheapest', Node((2, 0, 0)),
                                             Node((0, 0, 0)))
        # cheaper.csv has shortest path of cost 6
        # cost 3 through open doors
        # cost 2 through closed door
        # cost 1 to destroy
        expected = 12
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) - 1].g  # get the final cost

        self.assertEqual(expected, actual)
Beispiel #7
0
    def test_UseEnergy_ShouldReduceEnergyCount(self):
        ValidationUtility.set_up_test_method('energy',
                                             Node((2, 0, 0)),
                                             Node((0, 0, 0)),
                                             energy=2)

        expected = 0
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) -
                        1].energy_units  # get the final energy unit count

        self.assertEqual(expected, actual)
    def test_LeastResistance_ShouldHaveTwelveEnergyUnits(self):
        ValidationUtility.set_up_test_method('least_resistance', Node(
            (3, 0, 0)), Node((0, 0, 0)))

        # least_resistance.csv has shortest path of cost 13
        # path with least resistance is door (5x2) and open (1x1)
        # path of same length is sentinel(3)-wait(5)-sentinel(3)
        # energy_units should be unchanged because path of least resistance is taken
        expected = 12
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) - 1].energy_units  # get the final cost

        self.assertEqual(expected, actual)
Beispiel #9
0
    def test_UseBlaster_ShouldReduceBlasterCount(self):
        ValidationUtility.set_up_test_method('blasting',
                                             Node((1, 0, 0)),
                                             Node((0, 0, 0)),
                                             blaster=1)

        expected = 0
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[
            len(result) -
            1].tritanium_blaster  # get the final tritanium blaster count

        self.assertEqual(expected, actual)
Beispiel #10
0
    def test_RegenerationBlastWall_ShouldReduceRegenerationTimeByThree(self):
        ValidationUtility.set_up_test_method('regeneration_blasting',
                                             Node((2, 0, 0)), Node((0, 0, 0)))

        # regeneration time at 5
        # blast wall takes 3
        # destroy takes 1
        expected = 1
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) -
                        1].regeneration_time  # get the final cost

        self.assertEqual(expected, actual)
Beispiel #11
0
    def test_RegenerationLadderUp_ShouldReduceRegenerationTimeByTwo(self):
        ValidationUtility.set_up_test_method('regeneration_ladder_up',
                                             Node((1, 0, -1)), Node((0, 0, 0)))

        # regeneration time at 5
        # ladder up takes 2
        # destroy takes 1
        expected = 2
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) -
                        1].regeneration_time  # get the final cost

        self.assertEqual(expected, actual)
Beispiel #12
0
    def test_RegenerationOpen_ShouldReduceRegenerationTimeByOne(self):
        ValidationUtility.set_up_test_method('regeneration_open',
                                             Node((1, 1, 0)), Node((0, 0, 0)))

        # regeneration time at 5
        # open takes 1
        # destroy takes 1
        expected = 3
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) -
                        1].regeneration_time  # get the final cost

        self.assertEqual(expected, actual)
Beispiel #13
0
    def test_EnergyCooldown_ShouldRegardCooldownOfFive(self):
        ValidationUtility.set_up_test_method('energy', Node((2, 0, 0)),
                                             Node((0, 0, 0)))

        # cost 3 through sentinel hallway
        # cost 5 for cooldown (wait)
        # cost 3 through sentinel hallway
        # cost 1 to destroy
        expected = 12
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) - 1].g  # get the final cost

        self.assertEqual(expected, actual)
Beispiel #14
0
    def test_RegenerationLadderDown_ShouldReduceRegenerationTimeByPointFive(
            self):
        ValidationUtility.set_up_test_method('regeneration_ladder_down',
                                             Node((1, 0, 1)), Node((0, 0, 0)))

        # regeneration time at 5
        # ladder down takes 0.5
        # destroy takes 1
        expected = 3.5
        result = ValidationUtility.a_star_controller.search_path()
        actual = result[len(result) -
                        1].regeneration_time  # get the final cost

        self.assertEqual(expected, actual)