Exemplo n.º 1
0
    def load_elements_from_file(self, robot_init_filename, block_init_filename):
        map = Map((int(self.cfg['MAP']['grid_row_dimension']), int(self.cfg['MAP']['grid_column_dimension'])))
        for x, y in map.get_blocks_init_place(block_init_filename):
            if not map.is_location_in_environment(x, y, (
            int(self.cfg['MAP']['grid_row_dimension']), int(self.cfg['MAP']['grid_column_dimension']))):
                raise OutsideBoundryError('init block (x, y) not in map!')
            map.grid[x][y] = BLOCK_AREA
            map.blocks.append((x, y))

        for x, y in map.get_robot_init_place(robot_init_filename):
            if not map.is_location_in_environment(x, y, (
            int(self.cfg['MAP']['grid_row_dimension']), int(self.cfg['MAP']['grid_column_dimension']))):
                raise OutsideBoundryError('init robot (x, y) not in map!')
            map.grid[x][y] = ROBOT_AREA
            map.robots.append(Robot(x, y))  # add robots
        return map
Exemplo n.º 2
0
    def load_elements_by_click(self, robots_sequences, blocks_sequences):
        map = Map((int(self.cfg['MAP']['grid_row_dimension']), int(self.cfg['MAP']['grid_column_dimension'])))
        for x, y in blocks_sequences:
            if not map.is_location_in_environment(x, y, (
            int(self.cfg['MAP']['grid_row_dimension']), int(self.cfg['MAP']['grid_column_dimension']))):
                raise OutsideBoundryError('init block (x, y) not in map!')
            map.grid[x][y] = BLOCK_AREA
            map.blocks.append((x, y))

        for x, y in robots_sequences:
            if not map.is_location_in_environment(x, y, (
            int(self.cfg['MAP']['grid_row_dimension']), int(self.cfg['MAP']['grid_column_dimension']))):
                raise OutsideBoundryError('init robot (x, y) not in map!')
            map.grid[x][y] = ROBOT_AREA
            map.robots.append(Robot(x, y))  # add robots
        return map