src.plangym.videogames.retro
============================

.. py:module:: src.plangym.videogames.retro

.. autoapi-nested-parse::

   Implement the ``plangym`` API for retro environments.



Classes
-------

.. autoapisummary::

   src.plangym.videogames.retro.ActionDiscretizer
   src.plangym.videogames.retro.RetroEnv


Module Contents
---------------

.. py:class:: ActionDiscretizer(env, actions=None)

   Bases: :py:obj:`gymnasium.ActionWrapper`


   Wrap a gym-retro environment and make it use discrete actions for the Sonic game.


   .. py:attribute:: buttons
      :value: ['B', 'A', 'MODE', 'START', 'UP', 'DOWN', 'LEFT', 'RIGHT', 'C', 'Y', 'X', 'Z']



   .. py:attribute:: actions


   .. py:attribute:: _actions
      :value: []



   .. py:attribute:: action_space

      Return the :attr:`Env` :attr:`action_space` unless overwritten then the wrapper :attr:`action_space` is used.


   .. py:method:: action(a)

      Return the corresponding action in the emulator's format.



.. py:class:: RetroEnv(name, frameskip = 5, episodic_life = False, autoreset = True, delay_setup = False, remove_time_limit = True, obs_type = 'rgb', render_mode = None, wrappers = None, **kwargs)

   Bases: :py:obj:`plangym.videogames.env.VideogameEnv`


   Environment for playing ``gym-retro`` games.


   .. py:attribute:: AVAILABLE_OBS_TYPES


   .. py:attribute:: SINGLETON
      :value: True



   .. py:method:: __getattr__(item)

      Forward getattr to self.gym_env.



   .. py:method:: get_win_condition(info)
      :staticmethod:


      Get win condition for games that have the end of the screen available.



   .. py:method:: get_ram()

      Return the ram of the emulator as a numpy array.



   .. py:method:: clone(**kwargs)

      Return a copy of the environment with its initialization delayed.



   .. py:method:: init_gym_env()

      Initialize the retro environment.



   .. py:method:: get_state()

      Get the state of the retro environment.



   .. py:method:: set_state(state)

      Set the state of the retro environment.



   .. py:method:: close()

      Close the underlying :class:`gym.Env`.



   .. py:method:: reset(return_state = True)

      Restart the environment.

      :param return_state: If ``True``, it will return the state of the environment.

      :returns: ``(state, obs)`` if ```return_state`` is ``True`` else return ``obs``.



