valueIterationAgents.py
def computeActionFromValues(self, state):
        """
          The policy is the best action in the given state
          according to the values currently stored in self.values.

          You may break ties any way you see fit.  Note that if
          there are no legal actions, which is the case at the
          terminal state, you should return None.
        """
        value = float("-inf")
        choice = None

        if self.mdp.isTerminal(state):
            return None

        for action in self.mdp.getPossibleActions(state):  # act greedily according to value function
            qVal = self.computeQValueFromValues(state, action)
            if qVal >= value:
                value = qVal
                choice = action
        return choice

          The policy is the best action in the given state
          according to the values currently stored in self.values.

          You may break ties any way you see fit.  Note that if
          there are no legal actions, which is the case at the
          terminal state, you should return None.
        
The policy is the best action in the given state
according to the values currently stored in self.values.

You may break ties any way you see fit.  Note that if
there are no legal actions, which is the case at the
terminal state, you should return None.
The policy is the best action in the given state according to the values currently stored in self . values . You may break ties any way you see fit . Note that if there are no legal actions which is the case at the terminal state you should return None .
def computeActionFromValues(self, state):
        value = float("-inf")
        choice = None
        if self.mdp.isTerminal(state):
            return None
        for action in self.mdp.getPossibleActions(state):  
            qVal = self.computeQValueFromValues(state, action)
            if qVal >= value:
                value = qVal
                choice = action
        return choice
def computeActionFromValues ( self , state ) : value = float ( "-inf" ) choice = None if self . mdp . isTerminal ( state ) : return None for action in self . mdp . getPossibleActions ( state ) : qVal = self . computeQValueFromValues ( state , action ) if qVal >= value : value = qVal choice = action return choice
The policy is the best action in the given state
according to the values currently stored in self.values.
The policy is the best action in the given state according to the values currently stored in self . values .
"""
          The policy is the best action in the given state
          according to the values currently stored in self.values.

          You may break ties any way you see fit.  Note that if
          there are no legal actions, which is the case at the
          terminal state, you should return None.
        """ # act greedily according to value function
self
state