Exemplo n.º 1
0
    def generate_step(self, state, action):
        if action is None:
            print('Tried to generate a step with a null action')
            return None
        elif type(action) is int:
            action = NetworkAction(action)

        result = StepResult()
        result.next_state, is_legal = self.make_next_state(state, action)
        if self.fresh and result.action is not ActionType.SCAN:
            self.fresh = False
            action = NetworkAction(ActionType.SCAN)
        result.action = action.copy()
        if result.action.bin_number is ActionType.SCAN:
            self.last_action_scan = True
        else:
            self.last_action_scan = False
        result.observation = self.make_observation(action, result.next_state)
        result.reward = self.make_reward(state, action, result.next_state, is_legal)
        result.is_terminal = self.is_terminal(result.next_state)
        #print('action')
        #print(result.action.to_string())
        #print('observation')
        #print(result.observation.to_string())
        #print('next state node')
        #print(result.next_state.current_node.to_string())
        #sys.exit(0)
        return result, is_legal
Exemplo n.º 2
0
    def generate_step(self, state, action):
        if action is None:
            print("Tried to generate a step with a null action")
            return None
        elif type(action) is int:
            action = RockAction(action)

        result = StepResult()
        result.next_state, is_legal = self.make_next_state(state, action)
        result.action = action.copy()
        result.observation = self.make_observation(action, result.next_state)
        result.reward = self.make_reward(state, action, result.next_state,
                                         is_legal)
        result.is_terminal = self.is_terminal(result.next_state)

        return result, is_legal
Exemplo n.º 3
0
    def generate_step(self, state, action):
        # type: (object, object) -> object
        if type(action) is int:
            action = RobotAction(action)
        elif action is None:
            logging.error("Tried to generate a step with a null action")
            return None

        result = StepResult()
        result.next_state, is_legal = self.make_next_state(state, action)
        result.action = action
        result.observation = self.make_observation(action, result.next_state)
        result.reward = self.make_reward(state, action, result.next_state,
                                         is_legal)
        result.is_terminal = self.is_terminal(result.next_state)

        return result, is_legal