# Path: spriteworld/factor_distributions.py
# _MAX_TRIES = int(1e5)
# class AbstractDistribution(object):
# class Continuous(AbstractDistribution):
# class Discrete(AbstractDistribution):
# class Mixture(AbstractDistribution):
# class Intersection(AbstractDistribution):
# class Product(AbstractDistribution):
# class SetMinus(AbstractDistribution):
# class Selection(AbstractDistribution):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def __str__(self):
#   def _get_rng(self, rng=None):
#   def keys(self):
#   def __init__(self, key, minval, maxval, dtype='float32'):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, key, candidates, probs=None):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components, probs=None):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components, index_for_sampling=0):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, base, hold_out):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, base, filtering):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
# 
# Path: spriteworld/sprite_generators.py
# def generate_sprites(factor_dist, num_sprites=1):
#   def _generate():
# def chain_generators(*sprite_generators):
#   def _generate():
# def sample_generator(sprite_generators, p=None):
#   def _generate():
# def shuffle(sprite_generator):
#   def _generate():
# 
# Path: spriteworld/tasks.py
# class AbstractTask(object):
# class NoReward(AbstractTask):
# class FindGoalPosition(AbstractTask):
# class Clustering(AbstractTask):
# class MetaAggregated(AbstractTask):
#   def reward(self, sprites):
#   def success(self, sprites):
#   def __init__(self):
#   def reward(self, unused_sprites):
#   def success(self, unused_sprites):
#   def __init__(self,
#                filter_distrib=None,
#                goal_position=(0.5, 0.5),
#                terminate_distance=0.05,
#                terminate_bonus=0.0,
#                weights_dimensions=(1, 1),
#                sparse_reward=False,
#                raw_reward_multiplier=50):
#   def _single_sprite_reward(self, sprite):
#   def _filtered_sprites_rewards(self, sprites):
#   def reward(self, sprites):
#   def success(self, sprites):
#   def __init__(self,
#                cluster_distribs,
#                termination_threshold=2.5,
#                terminate_bonus=0.0,
#                sparse_reward=False,
#                reward_range=10):
#   def _cluster_assignments(self, sprites):
#   def _compute_clustering_metric(self, sprites):
#   def reward(self, sprites):
#   def success(self, sprites):
#   def __init__(self,
#                subtasks,
#                reward_aggregator='sum',
#                termination_criterion='all',
#                terminate_bonus=0.0):
#   def reward(self, sprites):
#   def success(self, sprites):
#   REWARD_AGGREGATOR = {
#       'sum': np.nansum,
#       'max': np.nanmax,
#       'min': np.nanmin,
#       'mean': np.nanmean
#   }
#   TERMINATION_CRITERION = {'all': np.all, 'any': np.any}
# 
# Path: spriteworld/configs/cobra/common.py
# def action_space():
# def renderers():


import itertools
import os
import numpy as np
from spriteworld import factor_distributions as distribs
from spriteworld import sprite_generators
from spriteworld import tasks
from spriteworld.configs.cobra import common
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
# python2 python3
"""Sorting task used in COBRA.

Sort sprites into target locations based on color.

We use 5 narrow hue ranges (red, blue, green, purple, yellow), and associated to
each a goal location (the corners and center of the arena). Each episode we
sample two sprites in random locations with different colors and reward the
agent for bringing them each to their respective goal location. in the training
mode we hold out one color pair, and in the test mode we sample only that pair.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


# Task Parameters
MAX_EPISODE_LENGTH = 50
TERMINATE_DISTANCE = 0.075
RAW_REWARD_MULTIPLIER = 20.
NUM_TARGETS = 2

# Sub-tasks for each color/goal
SUBTASKS = (
    {

# Path: spriteworld/factor_distributions.py
# _MAX_TRIES = int(1e5)
# class AbstractDistribution(object):
# class Continuous(AbstractDistribution):
# class Discrete(AbstractDistribution):
# class Mixture(AbstractDistribution):
# class Intersection(AbstractDistribution):
# class Product(AbstractDistribution):
# class SetMinus(AbstractDistribution):
# class Selection(AbstractDistribution):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def __str__(self):
#   def _get_rng(self, rng=None):
#   def keys(self):
#   def __init__(self, key, minval, maxval, dtype='float32'):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, key, candidates, probs=None):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components, probs=None):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components, index_for_sampling=0):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, base, hold_out):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, base, filtering):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
# 
# Path: spriteworld/sprite_generators.py
# def generate_sprites(factor_dist, num_sprites=1):
#   def _generate():
# def chain_generators(*sprite_generators):
#   def _generate():
# def sample_generator(sprite_generators, p=None):
#   def _generate():
# def shuffle(sprite_generator):
#   def _generate():
# 
# Path: spriteworld/tasks.py
# class AbstractTask(object):
# class NoReward(AbstractTask):
# class FindGoalPosition(AbstractTask):
# class Clustering(AbstractTask):
# class MetaAggregated(AbstractTask):
#   def reward(self, sprites):
#   def success(self, sprites):
#   def __init__(self):
#   def reward(self, unused_sprites):
#   def success(self, unused_sprites):
#   def __init__(self,
#                filter_distrib=None,
#                goal_position=(0.5, 0.5),
#                terminate_distance=0.05,
#                terminate_bonus=0.0,
#                weights_dimensions=(1, 1),
#                sparse_reward=False,
#                raw_reward_multiplier=50):
#   def _single_sprite_reward(self, sprite):
#   def _filtered_sprites_rewards(self, sprites):
#   def reward(self, sprites):
#   def success(self, sprites):
#   def __init__(self,
#                cluster_distribs,
#                termination_threshold=2.5,
#                terminate_bonus=0.0,
#                sparse_reward=False,
#                reward_range=10):
#   def _cluster_assignments(self, sprites):
#   def _compute_clustering_metric(self, sprites):
#   def reward(self, sprites):
#   def success(self, sprites):
#   def __init__(self,
#                subtasks,
#                reward_aggregator='sum',
#                termination_criterion='all',
#                terminate_bonus=0.0):
#   def reward(self, sprites):
#   def success(self, sprites):
#   REWARD_AGGREGATOR = {
#       'sum': np.nansum,
#       'max': np.nanmax,
#       'min': np.nanmin,
#       'mean': np.nanmean
#   }
#   TERMINATION_CRITERION = {'all': np.all, 'any': np.any}
# 
# Path: spriteworld/configs/cobra/common.py
# def action_space():
# def renderers():


# Path: spriteworld/configs/cobra/sorting.py
import itertools
import os
import numpy as np
from spriteworld import factor_distributions as distribs
from spriteworld import sprite_generators
from spriteworld import tasks
from spriteworld.configs.cobra import common

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
# python2 python3
"""Sorting task used in COBRA.

Sort sprites into target locations based on color.

We use 5 narrow hue ranges (red, blue, green, purple, yellow), and associated to
each a goal location (the corners and center of the arena). Each episode we
sample two sprites in random locations with different colors and reward the
agent for bringing them each to their respective goal location. in the training
mode we hold out one color pair, and in the test mode we sample only that pair.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


# Task Parameters
MAX_EPISODE_LENGTH = 50
TERMINATE_DISTANCE = 0.075
RAW_REWARD_MULTIPLIER = 20.
NUM_TARGETS = 2

# Sub-tasks for each color/goal
SUBTASKS = (
    {

        'distrib': distribs.Continuous('c0', 0.9, 1.),  # red