parameters: (self, time, observations, reward)
return_statement: return action
docstring: return an action given the reward for the previous action and the new observations
          @param time current time
          @param observations a DoubleVector of observations for the agent (use len() and [])
          @param the reward for the agent
docstring_summary: return an action given the reward for the previous action and the new observations
docstring_tokens: return an action given the reward for the previous action and the new observations
function: def act(self, time, observations, reward):
          """
          return an action given the reward for the previous action and the new observations
          @param time current time
          @param observations a DoubleVector of observations for the agent (use len() and [])
          @param the reward for the agent
          """
          # get the reward from the previous action
          r = reward[0]
          o = self.previous_observations
          a = self.previous_action
          
          # get the updated epsilon, in case the slider was changed by the user
          self.epsilon = get_environment().epsilon
          
          # get the old Q value
          Q_old = self.predict(o, a)
          
          # get the max expected value for our possible actions
          (max_action, max_value) = self.get_max_action(observations)
          
          # update the Q value
          info_items = (o[0], o[1], a, Q_old, r + self.gamma * max_value)
          print "Updating Q((%s, %s), %s) from %.2f toward %.2f" % info_items
          self.update(o, a, Q_old + self.alpha * (r + self.gamma * max_value - Q_old))
          
          # select the action to take
          action = self.get_epsilon_greedy(observations, max_action, max_value)
          self.previous_observations = observations
          self.previous_action = action
          return action
function_tokens: def act ( self , time , observations , reward ) : # get the reward from the previous action r = reward [ 0 ] o = self . previous_observations a = self . previous_action # get the updated epsilon, in case the slider was changed by the user self . epsilon = get_environment ( ) . epsilon # get the old Q value Q_old = self . predict ( o , a ) # get the max expected value for our possible actions ( max_action , max_value ) = self . get_max_action ( observations ) # update the Q value info_items = ( o [ 0 ] , o [ 1 ] , a , Q_old , r + self . gamma * max_value ) print "Updating Q((%s, %s), %s) from %.2f toward %.2f" % info_items self . update ( o , a , Q_old + self . alpha * ( r + self . gamma * max_value - Q_old ) ) # select the action to take action = self . get_epsilon_greedy ( observations , max_action , max_value ) self . previous_observations = observations self . previous_action = action return action