def get(self, TA, TB): assert isinstance(TA, MegaState_Target) assert isinstance(TB, MegaState_Target) if TA.drop_out_f: if TB.drop_out_f: return TA TA_scheme = self.__drop_out_scheme_a elif TA.target_state_index is not None: if TB.target_state_index is not None and TA.target_state_index == TB.target_state_index: return TA TA_scheme = (TA.target_state_index,) * self.__length_a else: TA_scheme = TA.scheme if TB.drop_out_f: # TA was not drop-out, otherwise we would have returned earlier TB_scheme = self.__drop_out_scheme_b elif TB.target_state_index is not None: # TA was not the same door, otherwise we would have returned earlier TB_scheme = (TB.target_state_index,) * self.__length_b else: TB_scheme = TB.scheme return MegaState_Target.create(TA_scheme + TB_scheme)
def prepare_transition_map(TM): """Character Path objects contain transition maps of the form list of (interval, DoorID) which has now to be transformed into the form list of (interval, MegaState_Target) This is the form that code generation requires for MegaState-s. """ def adapt(Target): if isinstance(Target, DoorID): return Target.state_index return Target return [ (interval, MegaState_Target.create(adapt(target))) \ for interval, target in TM ]
def get(self, TA, TB): """RETURNS: A MegaState_Target which represents the combination of target A and target B. If both are equal the MegaState_Target may have the '.target_state_index' set. If not a 'scheme' is developped is developed, which determines a target based on a state key, i.e. 'target_state_index = scheme[state_key]'. """ assert isinstance(TA, MegaState_Target) assert isinstance(TB, MegaState_Target) if TA.drop_out_f: if TB.drop_out_f: return TA TA_scheme = self.__drop_out_scheme_a elif TA.target_state_index is not None: if TB.target_state_index is not None and TA.target_state_index == TB.target_state_index: return TA TA_scheme = (TA.target_state_index,) * self.__length_a else: TA_scheme = TA.scheme if TB.drop_out_f: # TA was not drop-out, otherwise we would have returned earlier TB_scheme = self.__drop_out_scheme_b elif TB.target_state_index is not None: # TA was not the same door, otherwise we would have returned earlier TB_scheme = (TB.target_state_index,) * self.__length_b else: TB_scheme = TB.scheme return MegaState_Target.create(TA_scheme + TB_scheme)
def get(self, TA, TB): """RETURNS: A MegaState_Target which represents the combination of target A and target B. If both are equal the MegaState_Target may have the '.target_state_index' set. If not a 'scheme' is developped is developed, which determines a target based on a state key, i.e. 'target_state_index = scheme[state_key]'. """ assert isinstance(TA, MegaState_Target) assert isinstance(TB, MegaState_Target) if TA.drop_out_f: if TB.drop_out_f: return TA TA_scheme = self.__drop_out_scheme_a elif TA.target_state_index is not None: if TB.target_state_index is not None and TA.target_state_index == TB.target_state_index: return TA TA_scheme = (TA.target_state_index, ) * self.__length_a else: TA_scheme = TA.scheme if TB.drop_out_f: # TA was not drop-out, otherwise we would have returned earlier TB_scheme = self.__drop_out_scheme_b elif TB.target_state_index is not None: # TA was not the same door, otherwise we would have returned earlier TB_scheme = (TB.target_state_index, ) * self.__length_b else: TB_scheme = TB.scheme return MegaState_Target.create(TA_scheme + TB_scheme)