示例#1
0
    def _get_abstract_state(self, abstract_instance):
        if self.template_policy.get_process_likelihood(abstract_instance) >= self.min_likelihood:
            self.template_policy.process_integrate(abstract_instance)
            return self.template_policy

        candidates, likelihood = multi_max(self.parent.all_states, key=abstract_instance.get_process_likelihood)
        if likelihood >= self.min_likelihood:
            abstract_state = random.choice(candidates)
            abstract_state.process_integrate(abstract_instance)
            return abstract_state

        return abstract_instance
示例#2
0
 def _get_next_motor(self, state):
     candidates, _ = multi_max([(state, a) for a in self.actions], key=self.template_policy.get_value)
     _, motor = random.choice(candidates)
     return motor
示例#3
0
 def _get_next_state(self, pair, sub_pair, sub_state):
     key_func = lambda x: self.get_total_likelihood(pair, x) * x.get_transition_likelihood(sub_pair, sub_state)
     candidates, _ = multi_max(self.all_states, key=key_func)
     return random.choice(candidates)