# 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
        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):
        for _ in irange(0, timeout):
            x = sample_region_pose(region, block)
            if not any(are_colliding(block, x, block2, x2) for block2, x2 in block_poses.iteritems()):
                block_poses[block] = x
                break
        else:
            return sample_block_poses(blocks)
    return block_poses


def sample_grasp_problem(block_w=1., block_h=1., env_w=10.):
    env_region = Region('env', 0., env_w)

    blocks = [
        Block('block0', block_w, block_h, 'red'),
    ]

    initial_regions = [

# 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

        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):
        for _ in irange(0, timeout):
            x = sample_region_pose(region, block)
            if not any(are_colliding(block, x, block2, x2) for block2, x2 in block_poses.iteritems()):
                block_poses[block] = x
                break
        else:
            return sample_block_poses(blocks)
    return block_poses


def sample_grasp_problem(block_w=1., block_h=1., env_w=10.):
    env_region = Region('env', 0., env_w)

    blocks = [
        Block('block0', block_w, block_h, 'red'),
    ]

    initial_regions = [

        env_region,