
    &`i|                         d dl Z d dlmZmZ d dlZd dlmZ d dlm	Z	m
Z
 d dlmZ  e j        e          Zeddefd            Zeddefd	            Zd
edeeeej                 f         dej        fdZdS )    N)TypeUnion)
EnvContext)ERR_MSG_INVALID_ENV_DESCRIPTOREnvError)	PublicAPIFerrorc                 T    	 ddl }|S # t          $ r | rt          d          Y dS w xY w)a	  Tries importing pyspiel and returns the module (or None).

    Args:
        error: Whether to raise an error if pyspiel cannot be imported.

    Returns:
        The pyspiel module.

    Raises:
        ImportError: If error=True and pyspiel is not installed.
    r   NzCould not import pyspiel! Pyspiel is not a dependency of RLlib and RLlib requires you to install pyspiel separately: `pip install open_spiel`.)pyspielImportError)r	   r   s     p/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/rllib/env/utils/__init__.pytry_import_pyspielr      sX        	,  
 tt    ''c                 T    	 ddl }|S # t          $ r | rt          d          Y dS w xY w)a  Tries importing open_spiel and returns the module (or None).

    Args:
        error: Whether to raise an error if open_spiel cannot be imported.

    Returns:
        The open_spiel module.

    Raises:
        ImportError: If error=True and open_spiel is not installed.
    r   NzCould not import open_spiel! open_spiel is not a dependency of RLlib and RLlib requires you to install open_spiel separately: `pip install open_spiel`.)
open_spielr   )r	   r   s     r   try_import_open_spielr   +   s\        	,  
 ttr   env_contextenv_descriptorreturnc                 f   t          |t                    r-|                    d          rddl}t	          j        |           	 t          |t                    r ||           }nt	          j        |fi | }n9# t          j        j	        $ r" t          t          j        |                    w xY w|S )a  Tries to create a gym env given an EnvContext object and descriptor.

    Note: This function tries to construct the env from a string descriptor
    only using possibly installed RL env packages (such as gymnasium).
    These packages are no installation requirements for RLlib. In case
    you would like to support more such env packages, add the necessary imports
    and construction logic below.

    Args:
        env_context: The env context object to configure the env.
            Note that this is a config dict, plus the properties:
            `worker_index`, `vector_index`, and `remote`.
        env_descriptor: The env descriptor as a gym-registered string, e.g.
            "CartPole-v1", "ale_py:ALE/Breakout-v5".
            Alternatively, the gym.Env subclass to use.

    Returns:
        The actual gym environment object.

    Raises:
        gym.error.Error: If the env cannot be constructed.
    zale_py:ALE/r   N)
isinstancestr
startswithale_pygymregister_envstypemaker	   Errorr   r   format)r   r   r   envs       r   _gym_env_creatorr"   F   s    8 .#&& ">+D+D]+S+S "&!!!Nnd++ 	: .--CC(>99[99C9? N N N5<^LLMMMN Js   3A8 86B.)F)loggingtypingr   r   	gymnasiumr   ray.rllib.env.env_contextr   ray.rllib.utils.errorr   r   ray.util.annotationsr   	getLogger__name__loggerboolr   r   r   Envr"        r   <module>r0      s4                0 0 0 0 0 0        + * * * * *		8	$	$  d    4      4,,#tCG},-, 	W, , , , , ,r/   