示例#1
0
    def test_wall_blocks_movement_correctly(self, start_point, end_point,
                                            expected_end_point):
        shape = rectangle(geometry.Point((0.5, 0.0)),
                          geometry.Point((0.75, 1.0)))
        wall = puddle_world.WallPuddle(shape)

        new_end_point = wall.update_transition_end_point(
            start_point, end_point)
        self.assertPointsAlmostEqual(new_end_point, expected_end_point)
示例#2
0
    def test_wall_blocks_movement_for_non_convex_shape(self):
        # This is a special case that can't be worked into the parameterized test.
        # The following shape is a square 'U' shape.
        shape = geometry.Polygon(
            ((0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.75, 1.0), (0.75, 0.25),
             (0.25, 0.25), (0.25, 1.0), (0.0, 1.0)))
        wall = puddle_world.WallPuddle(shape)

        # We are stepping across empty space, from one wall boundary to another.
        start_point = geometry.Point((0.25, 0.5))
        end_point = geometry.Point((0.75, 0.5))
        new_end_point = wall.update_transition_end_point(
            start_point, end_point)

        self.assertEqual(new_end_point, geometry.Point((0.75, 0.5)))
示例#3
0
    def test_puddle_world_correctly_applies_wall_puddles(self):
        pw = puddle_world.PuddleWorld(
            puddles=(puddle_world.SlowPuddle(
                shape=puddle_world.circle(geometry.Point((0.5, 0.5)), 0.25)),
                     puddle_world.WallPuddle(
                         shape=puddle_world.circle(geometry.Point((
                             0.5, 0.5)), 0.1))),
            goal_position=geometry.Point((0.5, 0.5)),
            noise=0.0,
            thrust=0.5)  # A large thrust to step over multiple circles.

        start_position = geometry.Point((0.2, 0.5))
        transition = pw.transition(start_position, puddle_world.Action.RIGHT)

        # We should stop at the inner wall puddle.
        expected_end_position = geometry.Point((0.4, 0.5))

        self.assertEqual(transition.state, start_position)
        self.assertPointsAlmostEqual(transition.next_state,
                                     expected_end_position)
示例#4
0
HYDROGEN = (
    puddle_world.SlowPuddle(
        puddle_world.circle(geometry.Point((0.5, 0.5)), 0.3)),
    puddle_world.SlowPuddle(
        puddle_world.circle(geometry.Point((0.5, 0.5)), 0.15)),
)

SUTTON = (
    puddle_world.SlowPuddle(
        geometry.LineString([(0.1, 0.75), (0.45, 0.75)]).buffer(0.1)),
    puddle_world.SlowPuddle(
        geometry.LineString([(0.45, 0.4), (0.45, 0.8)]).buffer(0.1)),
)

TWO_ROOM = (
    puddle_world.WallPuddle(_TOP_WALL),
    puddle_world.WallPuddle(_BOTTOM_WALL),
)

TWO_ROOM_SLOW = (
    puddle_world.SlowPuddle(_TOP_WALL),
    puddle_world.SlowPuddle(_BOTTOM_WALL),
)

# LINT.IfChange(arena_names)
_ARENAS = frozendict.frozendict({
    'empty': EMPTY,
    'hydrogen': HYDROGEN,
    'sutton': SUTTON,
    'two_room': TWO_ROOM,
    'two_room_slow': TWO_ROOM_SLOW,