Exemplo n.º 1
0
    def test_getset_robot_direction(self):
        """Test get_robot_direction and set_robot_direction"""
        # instantiate iRoom from solutions for testing
        width, height, dirt_amount = (3, 4, 2)
        solution_room = ps3.iRoom(width, height, dirt_amount)

        robots = [ps3.Robot(solution_room, 1.0, 1) for i in range(5)]
        directions = [1, 333, 105, 75, 74.3]
        for dir_index, robot in enumerate(robots):
            robot.set_robot_direction(directions[dir_index])
        for dir_index, robot in enumerate(robots):
            robot_dir = robot.get_robot_direction()
            self.assertEqual(robot_dir, directions[dir_index],
                              "Robot direction set or retrieved incorrectly: expected {}, got {}".format(directions[dir_index], robot_dir)
                              )
Exemplo n.º 2
0
 def test_unimplemented_methods(self):
     """Test if student implemented methods in Robot abstract class that should not be implemented"""
     room = test.RectangularRoom(2, 2, 1)
     robot = ps3.Robot(room, 1, 1)
     self.assertRaises(NotImplementedError, robot.update_position_and_clean)
Exemplo n.º 3
0
print('get_dirt_amopunt(1,3)', room.get_dirt_amount(1, 3))
print('get_num_cleaned_tiles', room.get_num_cleaned_tiles())
print('is_tile_cleaned(1,3)', room.is_tile_cleaned(1, 3))
botpos = ps3.Position(1, 3)
room.clean_tile_at_position(botpos, 15)
print('1,3 after 15 cleaning (5)', room.is_tile_cleaned(1, 3),
      room.get_dirt_amount(1, 3))
room.clean_tile_at_position(botpos, 5)
print('1,3 after 5 more cleaning (0)', room.is_tile_cleaned(1, 3))
room.clean_tile_at_position(botpos, 5)
print('1,3 after 5 more cleaning (-5)', room.is_tile_cleaned(1, 3))

# create robot
room = ps3.EmptyRoom(5, 5, 20)
for i in range(0, 15):
    helper = ps3.Robot(room, 1, 1)
    print(str(helper), str(helper.get_robot_true_position()))
upperboundscheck = 0
normal_check = 0
err_check = 0
count = 0
err_list = []
while count < 1000:
    count += 1
    helper = ps3.Robot(room, 1, 1)
    x, y = helper.get_robot_true_position()
    if x > room.width or y > room.height:
        #print(str(helper), str(helper.get_robot_true_position()))
        upperboundscheck += 1
    if x >= 0 and x < room.width + 1 and y >= 0 and y < room.height + 1:
        normal_check += 1