예제 #1
0
    def test_when_path_from_some_other_point_then_last_position_is_correct_one(
            self) -> None:
        self.grassfire_pathable_0_0 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_0_0)
        path = self.grassfire_pathable_0_0.path_from(POSITION_9_9)

        self.assertEqual(POSITION_0_0, path.movements[-1].stop)
예제 #2
0
    def test_whenPathingFromUnalignedPositionClosestToUpperAngle_thenRotationAlignsToUpperAngle(
            self) -> None:
        self.grassfire_pathable_0_0 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_0_0)
        unaligned_position = AbsoluteCoordinate(1, 3, Orientation(7 * pi / 16))

        path = self.grassfire_pathable_0_0.path_from(unaligned_position)

        self.assertEqual(Orientation(pi / 2),
                         path.movements[0].stop.orientation)
예제 #3
0
    def test_whenPathingFromSpecificPosition_thenPathIsRight(self) -> None:
        self.grassfire_pathable_0_0 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_0_0)
        unaligned_position = AbsoluteCoordinate(1, 3,
                                                Orientation(15 * pi / 16))

        path = self.grassfire_pathable_0_0.path_from(unaligned_position)

        expected_path = AbsolutePath([
            AbsoluteMovement(unaligned_position,
                             AbsoluteCoordinate(0, 2, Orientation(pi))),
            AbsoluteMovement(AbsoluteCoordinate(0, 2, Orientation(pi)),
                             AbsoluteCoordinate(0, 0, Orientation(0)))
        ])
        self.assertEqual(expected_path, path)
예제 #4
0
class TestPathableGrassfire(TestCase):
    def test_when_path_from_some_point_then_last_position_is_correct_one(
            self) -> None:
        self.grassfire_pathable_9_9 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_9_9)

        path = self.grassfire_pathable_9_9.path_from(POSITION_2_2)

        self.assertEqual(POSITION_9_9, path.movements[-1].stop)

    def test_when_path_from_some_other_point_then_last_position_is_correct_one(
            self) -> None:
        self.grassfire_pathable_0_0 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_0_0)
        path = self.grassfire_pathable_0_0.path_from(POSITION_9_9)

        self.assertEqual(POSITION_0_0, path.movements[-1].stop)

    def test_whenPathingFromUnalignedPositionClosestToLowerAngle_thenRotationAlignsToLowerAngle(
            self) -> None:
        self.grassfire_pathable_0_0 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_0_0)
        unaligned_position = AbsoluteCoordinate(1, 3, Orientation(5 * pi / 16))

        path = self.grassfire_pathable_0_0.path_from(unaligned_position)

        self.assertEqual(Orientation(pi / 4),
                         path.movements[0].stop.orientation)

    def test_whenPathingFromUnalignedPositionClosestToUpperAngle_thenRotationAlignsToUpperAngle(
            self) -> None:
        self.grassfire_pathable_0_0 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_0_0)
        unaligned_position = AbsoluteCoordinate(1, 3, Orientation(7 * pi / 16))

        path = self.grassfire_pathable_0_0.path_from(unaligned_position)

        self.assertEqual(Orientation(pi / 2),
                         path.movements[0].stop.orientation)

    def test_whenPathingFromUnalignedPositionClosestToAngle_thenRotationAlignsToAngle(
            self) -> None:
        self.grassfire_pathable_0_0 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_0_0)
        unaligned_position = AbsoluteCoordinate(1, 3,
                                                Orientation(15 * pi / 16))

        path = self.grassfire_pathable_0_0.path_from(unaligned_position)

        self.assertEqual(Orientation(pi), path.movements[0].stop.orientation)

    def test_whenPathingFromSpecificPosition_thenPathIsRight(self) -> None:
        self.grassfire_pathable_0_0 = GrassfirePathable(
            SOME_TABLE_WHICH_GOAL_IS_0_0)
        unaligned_position = AbsoluteCoordinate(1, 3,
                                                Orientation(15 * pi / 16))

        path = self.grassfire_pathable_0_0.path_from(unaligned_position)

        expected_path = AbsolutePath([
            AbsoluteMovement(unaligned_position,
                             AbsoluteCoordinate(0, 2, Orientation(pi))),
            AbsoluteMovement(AbsoluteCoordinate(0, 2, Orientation(pi)),
                             AbsoluteCoordinate(0, 0, Orientation(0)))
        ])
        self.assertEqual(expected_path, path)
예제 #5
0
 def create_from(self, data: str) -> IAbsolutePathable:
     return GrassfirePathable(Table.deserialize(data))