class_docstr: A random agent using spring-like forces for its action evolution.
class_docstr_tok: ["A","random","agent","using","spring-like","forces","for","its","action","evolution","."]
docstr: Gets an image state and a reward, returns an action.
docstr_tok: ["Gets","an","image","state","and","a","reward",",","returns","an","action","."]
code: def step(self, reward, unused_frame):
      """Gets an image state and a reward, returns an action."""
      self.rewards += reward
  
      action = (self.maxs - self.mins) * np.random.random_sample(
          size=[len(self.action_spec)]
      ) + self.mins
  
      # Compute the 'velocity' 1 time unit after a critical damped force
      # dragged us towards the random `action`, given our current velocity.
      self.velocity = self.critically_damped_derivative(
          1, self.omega, action, self.velocity
      )
  
      # Since walk and strafe are binary, we need some additional memory to
      # smoothen the movement. Adding half of action from the last step works.
      self.action = (
          self.velocity / self.velocity_scaling + 0.5 * self.action
      )
  
      # Fire with p = 0.01 at each step
      self.action[self.indices["FIRE"]] = int(np.random.random() > 0.99)
  
      # Jump/crouch with p = 0.005 at each step
      self.action[self.indices["JUMP"]] = int(
          np.random.random() > 0.995
      )
      self.action[self.indices["CROUCH"]] = int(
          np.random.random() > 0.995
      )
  
      # Clip to the valid range and convert to the right dtype
      return self.clip_action(self.action)
  
file_path: lab/python/random_agent.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import random
  import numpy
  import six
  import deepmind_lab
label_desc: Use image node_id 3 for calling the SpringAgent obj's underlying member method code with example usage: obj.step(reward, unused_frame) and returns: self