# Path: planner/effects.py
# class ValueEffect(Effect):
#   def __init__(self, value):
#     super(self.__class__, self).__init__()
#     self.value = value
#   def __call__(self, *args):
#     return self.value
#   def __repr__(self):
#     return 'VE' + str_object((self.value,))
# 
# Path: planner/conditions.py
# class SubstateCondition(Condition):
#   def __init__(self, substate):
#     super(self.__class__, self).__init__()
#     self.substate = substate
#     self.variables = frozenset(substate.variables())
#   def __contains__(self, substate):
#     return all(var in substate and substate[var] == value for var, value in self.substate)
#   def __str__(self):
#     return 'SC' + str_args(self.substate.__dict__['__hash_dict'])
#   __repr__ = __str__


from .states import *
from misc.utils import *
from .effects import ValueEffect
from .conditions import SubstateCondition
    from strips.operators import derive_state
      if state in axiom:
        state = axiom(state)
        remaining.remove(axiom)
        sequence.append(axiom)
        applied = True
    if not applied:
      break
  return state, sequence

def derive_predicates(state, axioms):
  if not axioms:
    return state, []
  is_strips = 'strips' in axioms[0].__class__.__module__ # TODO: clean this up
  if is_strips:
    return derive_state(state, axioms)
  return derive_predicates_slow(state, axioms)

###########################################################################

class MacroOperator(object):
  def __init__(self, *operators):
    self.operators = tuple(operators)
    self.cost = sum(operator.cost for operator in operators)
  def __contains__(self, state):
    return self(state) is not None
  def __call__(self, state):
    states = [state]
    for operator in self.operators:
      new_state = operator(states[-1])
      if new_state is None: return None

# Path: planner/effects.py
# class ValueEffect(Effect):
#   def __init__(self, value):
#     super(self.__class__, self).__init__()
#     self.value = value
#   def __call__(self, *args):
#     return self.value
#   def __repr__(self):
#     return 'VE' + str_object((self.value,))
# 
# Path: planner/conditions.py
# class SubstateCondition(Condition):
#   def __init__(self, substate):
#     super(self.__class__, self).__init__()
#     self.substate = substate
#     self.variables = frozenset(substate.variables())
#   def __contains__(self, substate):
#     return all(var in substate and substate[var] == value for var, value in self.substate)
#   def __str__(self):
#     return 'SC' + str_args(self.substate.__dict__['__hash_dict'])
#   __repr__ = __str__


# Path: planner/operators.py
from .states import *
from misc.utils import *
from .effects import ValueEffect
from .conditions import SubstateCondition
    from strips.operators import derive_state

      if state in axiom:
        state = axiom(state)
        remaining.remove(axiom)
        sequence.append(axiom)
        applied = True
    if not applied:
      break
  return state, sequence

def derive_predicates(state, axioms):
  if not axioms:
    return state, []
  is_strips = 'strips' in axioms[0].__class__.__module__ # TODO: clean this up
  if is_strips:
    return derive_state(state, axioms)
  return derive_predicates_slow(state, axioms)

###########################################################################

class MacroOperator(object):
  def __init__(self, *operators):
    self.operators = tuple(operators)
    self.cost = sum(operator.cost for operator in operators)
  def __contains__(self, state):
    return self(state) is not None
  def __call__(self, state):
    states = [state]
    for operator in self.operators:
      new_state = operator(states[-1])
      if new_state is None: return None

      states.append(new_state)