Beispiel #1
0
    def test_update_position_and_cleanStandardRobot(self):
        "Test StandardRobot.update_position_and_clean"
        r = ps3.EmptyRoom(3, 5, 1)
        robot = ps3.StandardRobot(r, 1.0, 1)
        robot.set_robot_position(test.Position(1.5, 2.5))
        robot.set_robot_direction(90)
        robot.update_position_and_clean()
        self.assertEquals(robot.get_robot_direction(), 90,
                          "Robot direction is updated incorrectly by update_position_and_clean: expected %r, got %r" %
                          (90, robot.get_robot_direction()))
        # check if robot position is valid
        robotPos = robot.get_robot_position()
        correctPos = test.Position(2.5, 2.5)
        self.assertTrue(robotPos.get_x() == correctPos.get_x() and robotPos.get_y() == correctPos.get_y(),
                          "Robot position is updated incorrectly by update_position_and_clean: expected %r, got %r" %
                          (ps3.Position(2.5, 2.5), robot.get_robot_position()))
        self.assertTrue(2>=r.get_num_cleaned_tiles() >= 1,
                        "update_position_and_clean should have marked one or two tiles as clean")
        self.assertTrue(r.is_tile_cleaned(1, 2) or r.is_tile_cleaned(2, 2),
                        "update_position_and_clean should have marked either (1, 2) or (2, 2) as clean")
 
        # Simulate a lot of time passing...
        for i in range(20):
            robot.update_position_and_clean()
            self.assertTrue(r.is_position_in_room(robot.get_robot_position()),
                            "Robot position %r is not in room!" % (robot.get_robot_position(),))
        self.assertNotEquals(robot.get_robot_direction(), 90,
                          "Robot direction should have been changed in update_position_and_clean")
        self.assertTrue(r.get_num_cleaned_tiles() >= 1,
                        "update_position_and_clean should have marked another tile as clean")
Beispiel #2
0
def createRoomAndRobots(num_robots):
    #   Create common room
    room = ps3.EmptyRoom(5, 7, 1)

    #  Create robots
    speed = 1.0
    capacity = 1
    robots = [
        ps3.StandardRobot(room, speed, capacity) for i in range(num_robots)
    ]
    return room, robots

    "Test strict inequalities in random positions for the EmptyRoom and StandardRobot"
Beispiel #3
0
 def createRoomAndRobots(self, num_robots):
     r = ps3.RectangularRoom(5, 7, 1)
     robots = [ps3.StandardRobot(r, 1.0, 1) for i in range(num_robots)]
     return r, robots