class_docstr: <a id="GameEnvironment"></a>
  
  ## Game environment
  
  This is a wrapper for OpenAI gym game environment.
  We do a few things here:
  
  1. Apply the same action on four frames and get the last frame
  2. Convert observation frames to gray and scale it to (84, 84)
  3. Stack four frames of the last four actions
  4. Add episode information (total reward for the entire episode) for monitoring
  5. Restrict an episode to a single life (game has 5 lives, we reset after every single life)
  
  #### Observation format
  Observation is tensor of size (4, 84, 84). It is four frames
  (images of the game screen) stacked on first axis.
  i.e, each channel is a frame.
class_docstr_tok: ["<","a","id=","''","GameEnvironment","''",">","<","\/a",">","#","#","Game","environment","This","is","a","wrapper","for","OpenAI","gym","game","environment",".","We","do","a","few","things","here",":","1",".","Apply","the","same","action","on","four","frames","and","get","the","last","frame","2",".","Convert","observation","frames","to","gray","and","scale","it","to","(","84",",","84",")","3",".","Stack","four","frames","of","the","last","four","actions","4",".","Add","episode","information","(","total","reward","for","the","entire","episode",")","for","monitoring","5",".","Restrict","an","episode","to","a","single","life","(","game","has","5","lives",",","we","reset","after","every","single","life",")","#","#","#","#","Observation","format","Observation","is","tensor","of","size","(","4",",","84",",","84",")",".","It","is","four","frames","(","images","of","the","game","screen",")","stacked","on","first","axis",".","i.e",",","each","channel","is","a","frame","."]
code: def __init__(self, seed: int):
      # create environment
      self.env = gym.make("BreakoutNoFrameskip-v4")
      self.env.seed(seed)
  
      # tensor for a stack of 4 frames
      self.obs_4 = np.zeros((4, 84, 84))
  
      # buffer to keep the maximum of last 2 frames
      self.obs_2_max = np.zeros((2, 84, 84))
  
      # keep track of the episode rewards
      self.rewards = []
      # and number of lives left
      self.lives = 0
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/rl/game.py
imports: import multiprocessing
  import multiprocessing.connection
  import cv2
  import gym
  import numpy
label_desc: Use image node_id 1 to create a new Game object  with example: obj = Game(seed)