INNER CODE UNIT · Python

get_action

rlcode/reinforcement-learning · 1-grid-world/2-value_iteration.py:31

    def get_action(self, state):
        action_list = []
        max_value = -99999

        if state == [2, 2]:
            return []

        # calculating q values for the all actions and
        # append the action to action list which has maximum q value
        for action in self.env.possible_actions:

            next_state = self.env.state_after_action(state, action)
            reward = self.env.get_reward(state, action)
            next_value = self.get_value(next_state)
            value = (reward + self.discount_factor * next_value)

            if value > max_value:
                action_list.clear()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…