Ejemplo n.º 1
0
    def test_get_movement_points_obstacle_lte_max_mv_will_continue_around_corner(
            self):
        elevations = {
            Point(0, 0): 0,
            Point(1, 0): 0,
            Point(2, 0): 0,
            Point(3, 0): 0,
            Point(0, 1): 3,
            Point(1, 1): 4,
            Point(2, 1): 0,
            Point(3, 1): 0,
            Point(0, 2): 0,
            Point(1, 2): 0,
            Point(2, 2): 0,
            Point(3, 2): 0
        }
        tiles = [
            Tile(point=point, elevation=elevation)
            for point, elevation in elevations.items()
        ]
        map_ = Map(4, 3, tiles)
        origin = Point(1, 2)
        expected_four = {
            Point(1, 0): 4,
            Point(2, 0): 3,
            Point(3, 0): 4,
            Point(2, 1): 2,
            Point(3, 1): 3,
            Point(0, 2): 1,
            Point(1, 2): 0,
            Point(2, 2): 1,
            Point(3, 2): 2
        }

        expected_five = {
            Point(0, 0): 5,
            Point(1, 0): 4,
            Point(2, 0): 3,
            Point(3, 0): 4,
            Point(0, 1): 5,
            Point(1, 1): 5,
            Point(2, 1): 2,
            Point(3, 1): 3,
            Point(0, 2): 1,
            Point(1, 2): 0,
            Point(2, 2): 1,
            Point(3, 2): 2
        }

        ranger = MovementCalculator(map_)
        self.assertEqual(ranger.get_movement_points(origin, 5), expected_five)
        self.assertEqual(ranger.get_movement_points(origin, 4), expected_four)
Ejemplo n.º 2
0
    def test_get_movement_points_goes_around_obstacle_and_recalculates_on_terrain(
            self):
        terrains = {
            Point(0, 0): 1,
            Point(1, 0): 1,
            Point(2, 0): 1,
            Point(3, 0): 1,
            Point(0, 1): 1,
            Point(1, 1): 1,
            Point(2, 1): 1,
            Point(3, 1): 1,
            Point(0, 2): 1,
            Point(1, 2): 4,
            Point(2, 2): 9,
            Point(3, 2): 1,
            Point(0, 3): 1,
            Point(1, 3): 1,
            Point(2, 3): 5,
            Point(3, 3): 1
        }
        tiles = [
            Tile(point=point, terrain_mv=terrain)
            for point, terrain in terrains.items()
        ]
        map_ = Map(4, 4, tiles)
        origin = Point(1, 3)
        expected_six = {
            Point(0, 0): 4,
            Point(1, 0): 5,
            Point(2, 0): 6,
            Point(0, 1): 3,
            Point(1, 1): 4,
            Point(2, 1): 5,
            Point(3, 1): 6,
            Point(0, 2): 2,
            Point(1, 2): 1,
            Point(2, 2): 5,
            Point(0, 3): 1,
            Point(1, 3): 0,
            Point(2, 3): 1,
            Point(3, 3): 6
        }

        ranger = MovementCalculator(map_)
        self.assertEqual(ranger.get_movement_points(origin, 6), expected_six)
Ejemplo n.º 3
0
    def test_get_movement_points_after_going_around_obstacle_will_recalculate_min_distance_r_to_l(
            self):
        elevations = {
            Point(0, 0): 9,
            Point(1, 0): 0,
            Point(2, 0): 0,
            Point(3, 0): 0,
            Point(0, 1): 0,
            Point(1, 1): 0,
            Point(2, 1): 3,
            Point(3, 1): 0,
            Point(0, 2): 9,
            Point(1, 2): 0,
            Point(2, 2): 0,
            Point(3, 2): 0,
            Point(0, 3): 0,
            Point(1, 3): 0,
            Point(2, 3): 0,
            Point(3, 3): 0
        }
        tiles = [
            Tile(point=point, elevation=elevation)
            for point, elevation in elevations.items()
        ]
        map_ = Map(4, 4, tiles)
        origin = Point(3, 1)
        expected_six = {
            Point(1, 0): 3,
            Point(2, 0): 2,
            Point(3, 0): 1,
            Point(0, 1): 5,
            Point(1, 1): 4,
            Point(2, 1): 4,
            Point(3, 1): 0,
            Point(1, 2): 3,
            Point(2, 2): 2,
            Point(3, 2): 1,
            Point(0, 3): 5,
            Point(1, 3): 4,
            Point(2, 3): 3,
            Point(3, 3): 2
        }

        ranger = MovementCalculator(map_)
        self.assertEqual(ranger.get_movement_points(origin, 6), expected_six)