# Path: stripstream/utils.py
# def random_sequence(sequence):
#     indices = range(len(sequence))
#     shuffle(indices)
#     for i in indices:
#         yield sequence[i]
# 
# def irange(start, end, step=1):
#     n = start
#     while n < end:
#         yield n
#         n += step


from collections import namedtuple
from random import random
from time import sleep
from stripstream.utils import random_sequence, irange

TMPProblem = namedtuple('TMPProblem', ['env_region', 'initial_config', 'initial_holding', 'initial_poses',
                                       'goal_config', 'goal_holding', 'goal_poses', 'goal_regions'])


class TMPProblem(object):

    def __init__(self, env_region, initial_config, initial_holding, initial_poses,
                 goal_config, goal_holding, goal_poses, goal_regions):
        self.env_region = env_region
        self.initial_config = initial_config
        self.initial_holding = initial_holding
        self.initial_poses = initial_poses
        self.goal_config = goal_config
        self.goal_holding = goal_holding
        self.goal_poses = goal_poses
        self.goal_regions = goal_regions

    def get_blocks(self):
        blocks = self.initial_poses.keys()
        if self.initial_holding is not None:
            blocks.append(self.initial_holding)
        return blocks

    def get_regions(self):
        return set(region for _, region in self.goal_regions)


def sample_block_poses(blocks, timeout=100):
    block_poses = {}

# Path: stripstream/utils.py
# def random_sequence(sequence):
#     indices = range(len(sequence))
#     shuffle(indices)
#     for i in indices:
#         yield sequence[i]
# 
# def irange(start, end, step=1):
#     n = start
#     while n < end:
#         yield n
#         n += step


# Path: stripstream/pddl/examples/continuous_tamp/continuous_tamp_utils.py
from collections import namedtuple
from random import random
from time import sleep
from stripstream.utils import random_sequence, irange


TMPProblem = namedtuple('TMPProblem', ['env_region', 'initial_config', 'initial_holding', 'initial_poses',
                                       'goal_config', 'goal_holding', 'goal_poses', 'goal_regions'])


class TMPProblem(object):

    def __init__(self, env_region, initial_config, initial_holding, initial_poses,
                 goal_config, goal_holding, goal_poses, goal_regions):
        self.env_region = env_region
        self.initial_config = initial_config
        self.initial_holding = initial_holding
        self.initial_poses = initial_poses
        self.goal_config = goal_config
        self.goal_holding = goal_holding
        self.goal_poses = goal_poses
        self.goal_regions = goal_regions

    def get_blocks(self):
        blocks = self.initial_poses.keys()
        if self.initial_holding is not None:
            blocks.append(self.initial_holding)
        return blocks

    def get_regions(self):
        return set(region for _, region in self.goal_regions)


def sample_block_poses(blocks, timeout=100):
    block_poses = {}

    for block, region in random_sequence(blocks):