class_docstr: Wraps an environment allowing keyboard inputs to interact with the environment.
class_docstr_tok: ["Wraps","an","environment","allowing","keyboard","inputs","to","interact","with","the","environment","."]
docstr: Wraps an environment with a dictionary of keyboard buttons to action and if to zoom in on the environment.
  
  Args:
      env: The environment to play
      keys_to_action: The dictionary of keyboard tuples and action value
      zoom: If to zoom in on the environment render
docstr_tok: ["Wraps","an","environment","with","a","dictionary","of","keyboard","buttons","to","action","and","if","to","zoom","in","on","the","environment",".","Args",":","env",":","The","environment","to","play","keys_to_action",":","The","dictionary","of","keyboard","tuples","and","action","value","zoom",":","If","to","zoom","in","on","the","environment","render"]
code: def __init__(
      self,
      env: Env,
      keys_to_action: Optional[Dict[Tuple[int, ...], int]] = None,
      zoom: Optional[float] = None,
  ):
      """Wraps an environment with a dictionary of keyboard buttons to action and if to zoom in on the environment.
  
      Args:
          env: The environment to play
          keys_to_action: The dictionary of keyboard tuples and action value
          zoom: If to zoom in on the environment render
      """
      if env.render_mode not in {"rgb_array", "rgb_array_list"}:
          logger.error(
              "PlayableGame wrapper works only with rgb_array and rgb_array_list render modes, "
              f"but your environment render_mode = {env.render_mode}."
          )
  
      self.env = env
      self.relevant_keys = self._get_relevant_keys(keys_to_action)
      self.video_size = self._get_video_size(zoom)
      self.screen = pygame.display.set_mode(self.video_size)
      self.pressed_keys = []
      self.running = True
  
file_path: gym/gym/utils/play.py
imports: from collections import deque
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import gym.error
  from gym import Env, logger
  from gym.core import ActType, ObsType
  from gym.error import DependencyNotInstalled
  from gym.logger import deprecation
label_desc: Use image node_id 1 to create a new PlayableGame object  with example: obj = PlayableGame(env, keys_to_action, zoom)