# 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/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/states.py
# class Substate(DictPrintObject, Mapping):
#   def __init__(self, values):
#     HashObject.__init__(self)
#     self.__dict__[HASH_DICT] = values
#   def variables(self):
#     return set(self.__dict__[HASH_DICT].keys())
#   def includes(self, other):
#     return all(var in self and self[var] == other[var] for var in other.variables()) # TODO - test if state
#   def __getitem__(self, var):
#     return self.get(var)
#   def __iter__(self):
#     return self.__dict__[HASH_DICT].items()
#   def __len__(self):
#     return len(self.__dict__[HASH_DICT])
#   def __str__(self):
#     return 'SS' + str_args(self.__dict__[HASH_DICT])


from planner.conditions import SubstateCondition
from planner.effects import ValueEffect
from planner.states import Substate
      operator.conditions.append(SubstateCondition(Substate({variable: start})))
    if end is not None:
      operator.effects[variable] = ValueEffect(end)

def is_discrete_condition(condition):
  return isinstance(condition, SubstateCondition) and len(condition.substate) == 1

def is_discrete_effect(effect):
  return isinstance(effect, ValueEffect)

def is_discrete_operator(operator):
  for condition in operator.conditions:
    if not is_discrete_condition(condition):
      return False
  for _, effect in operator.effects.items():
    if not is_discrete_effect(effect):
      return False
  return True

def connect_discrete_conditions(rg, edge):
  for connector in edge.connectors:
    if is_discrete_condition(connector.condition):
      vertex = rg.vertex(connector.condition.substate)
      vertex.connect(connector)
      if rg.start.substate in connector.condition:
        rg.start.connect(connector)

def connect_discrete_effects(rg, edge):
  for variable, effect in edge.value.effects.items():
    if is_discrete_effect(effect):

# 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/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/states.py
# class Substate(DictPrintObject, Mapping):
#   def __init__(self, values):
#     HashObject.__init__(self)
#     self.__dict__[HASH_DICT] = values
#   def variables(self):
#     return set(self.__dict__[HASH_DICT].keys())
#   def includes(self, other):
#     return all(var in self and self[var] == other[var] for var in other.variables()) # TODO - test if state
#   def __getitem__(self, var):
#     return self.get(var)
#   def __iter__(self):
#     return self.__dict__[HASH_DICT].items()
#   def __len__(self):
#     return len(self.__dict__[HASH_DICT])
#   def __str__(self):
#     return 'SS' + str_args(self.__dict__[HASH_DICT])


# Path: retired/discrete/operators.py
from planner.conditions import SubstateCondition
from planner.effects import ValueEffect
from planner.states import Substate

      operator.conditions.append(SubstateCondition(Substate({variable: start})))
    if end is not None:
      operator.effects[variable] = ValueEffect(end)

def is_discrete_condition(condition):
  return isinstance(condition, SubstateCondition) and len(condition.substate) == 1

def is_discrete_effect(effect):
  return isinstance(effect, ValueEffect)

def is_discrete_operator(operator):
  for condition in operator.conditions:
    if not is_discrete_condition(condition):
      return False
  for _, effect in operator.effects.items():
    if not is_discrete_effect(effect):
      return False
  return True

def connect_discrete_conditions(rg, edge):
  for connector in edge.connectors:
    if is_discrete_condition(connector.condition):
      vertex = rg.vertex(connector.condition.substate)
      vertex.connect(connector)
      if rg.start.substate in connector.condition:
        rg.start.connect(connector)

def connect_discrete_effects(rg, edge):
  for variable, effect in edge.value.effects.items():
    if is_discrete_effect(effect):

      vertex = rg.vertex(Substate({variable: effect.value}))