def _on_set_properties(self, from_server): log.simulator_ws('Setting properties') data = from_server.set_properties_data self._prediction_schema = data.prediction_schema self.objective_name = data.reward_name dynamic_properties = data.dynamic_properties properties_message = self._inkling.message_for_dynamic_message( dynamic_properties, self._properties_schema) self._init_properties = dict_for_message(properties_message)
def _process_sim_step(self): try: event = None step = next(self._step_iter) step.state = self._new_state_message() if self._prev_step_finish: event = EpisodeStartEvent(self._init_properties, step.state) self._prev_step_finish = False else: action_message = self._inkling.message_for_dynamic_message( step.prediction, self._prediction_schema) action = dict_for_message(action_message) event = SimulateEvent(action, step, self._prev_step_terminal) return event except StopIteration: return None
def _cache_action_for_predictor(self, prediction): """ Converts a server prediction into an action dictionary and saves it for the predictor class """ action_message = self._inkling.message_for_dynamic_message( prediction, self._prediction_schema) self._predictor_action = dict_for_message(action_message)
def state(self): return dict_for_message(self._sim_step.state)
def initial_state(self): return dict_for_message(self._initial_state)