
    h                     \   S SK JrJrJrJrJr  S SKrS SKr	S SKJ
r
  S SKJr  \" S\\	R                  5      r " S S\R                   \\   5      r " S S	\\	R                     5      r " S
 S\\	R                     5      r " S S\\	R                     5      r " S S\R                   5      rg)    )AnyGenericOptionalTypeVarUnionN)spaces)GymStepReturnTc                      ^  \ rS rSrSS\\   S\\R                     S\4S jjrSSS.S\\   S	\\	   S
\
\\	4   4U 4S jjjrS\S
\
\\\\\	\\4   4   4S jrSS jrS\S
\4S jrSS\S
S4S jjrSrU =r$ )IdentityEnv   Ndimspace	ep_lengthc                     Uc  Uc  Sn[         R                  " U5      nO
Ub   S5       eU=U l        U l        X0l        SU l        SU l        U R                  5         g)a  
Identity environment for testing purposes

:param dim: the size of the action and observation dimension you want
    to learn. Provide at most one of ``dim`` and ``space``. If both are
    None, then initialization proceeds with ``dim=1`` and ``space=None``.
:param space: the action and observation space. Provide at most one of
    ``dim`` and ``space``.
:param ep_length: the length of each episode in timesteps
N   zBarguments for both 'dim' and 'space' provided: at most one allowedr   )r   Discreteaction_spaceobservation_spacer   current_step
num_resetsreset)selfr   r   r   s       d/home/james-whalen/.local/lib/python3.13/site-packages/stable_baselines3/common/envs/identity_env.py__init__IdentityEnv.__init__   s^     ={OOC(E;d dd;5::D2"

    seedoptionsr    r!   returnc                   > Ub  [         TU ]  US9  SU l        U =R                  S-  sl        U R	                  5         U R
                  0 4$ )Nr    r   r   )superr   r   r   _choose_next_statestater   r    r!   	__class__s      r   r   IdentityEnv.reset%   sG    GMtM$1!zz2~r   actionc                     U R                  U5      nU R                  5         U =R                  S-  sl        SnU R                  U R                  :  nU R                  X#U0 4$ Nr   F_get_rewardr&   r   r   r'   r   r+   reward
terminated	truncateds        r   stepIdentityEnv.step-   [    !!&)!Q
%%7	zz6y"<<r   c                 B    U R                   R                  5       U l        g N)r   sampler'   )r   s    r   r&   IdentityEnv._choose_next_state5   s    &&--/
r   c                 Z    [         R                  " U R                  U:H  5      (       a  S$ S$ N      ?        )npallr'   r   r+   s     r   r/   IdentityEnv._get_reward8   s$    ffTZZ6122s;;r   modec                     g r8    r   rC   s     r   renderIdentityEnv.render;       r   )r   r   r   r   r   r'   )NNd   )r"   Nhuman)__name__
__module____qualname____firstlineno__r   intr   Spacer   dicttupler
   r   floatboolstrr   r4   r&   r/   rG   __static_attributes____classcell__r)   s   @r   r   r      s    HSM &,,9O cf 0 .2T Xc] HTN V[\]_c\cVd  =1 =q%tT#s(^'K!L =0<! < <3 T  r   r   c                      ^  \ rS rSrSS\S\S\S\4U 4S jjjrS\R                  S\	\R                  \\
\
\\\4   4   4S	 jrS\R                  S\4S
 jrSrU =r$ )IdentityEnvBox?   lowhighepsr   c                 t   > [         R                  " XS[        R                  S9n[        TU ]  XES9  X0l        g)z
Identity environment for testing purposes

:param low: the lower bound of the box dim
:param high: the upper bound of the box dim
:param eps: the epsilon bound for correct value
:param ep_length: the length of each episode in timesteps
)r   r^   r_   shapedtyper   r   N)r   Boxr?   float32r%   r   r`   )r   r^   r_   r`   r   r   r)   s         r   r   IdentityEnvBox.__init__@   s0     

sTL9:r   r+   r"   c                     U R                  U5      nU R                  5         U =R                  S-  sl        SnU R                  U R                  :  nU R                  X#U0 4$ r-   r.   r0   s        r   r4   IdentityEnvBox.stepM   r6   r   c                     U R                   U R                  -
  Us=::  a  U R                   U R                  -   ::  a  S$   S$ r<   )r'   r`   rA   s     r   r/   IdentityEnvBox._get_rewardU   s7    zzDHH,RDJJ<QRs[RX[[r   )r`   )g      r=   g?rJ   )rM   rN   rO   rP   rU   rQ   r   r?   ndarrayrT   rV   rS   rW   r   r4   r/   rX   rY   rZ   s   @r   r\   r\   ?   s    E  % [^  =2:: =%

E4tTWY\T\~0]*^ =\"** \ \ \r   r\   c                   <   ^  \ rS rSrSS\S\SS4U 4S jjjrSrU =r$ )	IdentityEnvMultiDiscreteY   r   r   r"   Nc                 N   > [         R                  " X/5      n[        TU ]  X#S9  gz
Identity environment for testing purposes

:param dim: the size of the dimensions you want to learn
:param ep_length: the length of each episode in timesteps
re   N)r   MultiDiscreter%   r   r   r   r   r   r)   s       r   r   !IdentityEnvMultiDiscrete.__init__Z   s'     $$cZ09:r   rE   r   rJ   rM   rN   rO   rP   rQ   r   rX   rY   rZ   s   @r   ro   ro   Y   "    ;C ; ;d ; ;r   ro   c                   <   ^  \ rS rSrSS\S\SS4U 4S jjjrSrU =r$ )	IdentityEnvMultiBinarye   r   r   r"   Nc                 L   > [         R                  " U5      n[        TU ]  X#S9  grr   )r   MultiBinaryr%   r   rt   s       r   r   IdentityEnvMultiBinary.__init__f   s%     ""3'9:r   rE   rv   rw   rZ   s   @r   rz   rz   e   rx   r   rz   c                      ^  \ rS rSrSr      SS\S\S\S\S\S\S	S
4S jjrS
S
S.S\\   S\\	   S	\
\R                  \	4   4U 4S jjjrS\\R                  \4   S	\4S jrSS\S	S
4S jjrSrU =r$ )FakeImageEnvq   aw  
Fake image environment for testing purposes, it mimics Atari games.

:param action_dim: Number of discrete actions
:param screen_height: Height of the image
:param screen_width: Width of the image
:param n_channels: Number of color channels
:param discrete: Create discrete action space instead of continuous
:param channel_first: Put channels on first axis instead of last

action_dimscreen_heightscreen_width
n_channelsdiscretechannel_firstr"   Nc                 T   X#U4U l         U(       a	  XBU4U l         [        R                  " SSU R                   [        R                  S9U l        U(       a  [        R                  " U5      U l        O*[        R                  " SSS[        R                  S9U l        SU l	        SU l
        g )Nr      rb   r   r   )   
   )observation_shaper   rf   r?   uint8r   r   r   rg   r   r   )r   r   r   r   r   r   r   s          r   r   FakeImageEnv.__init__}   s     #0z!J&0%ND"!'4CYCYacaiai!j &
 ;D &

rRZZ XDr   r   r    r!   c                j   > Ub  [         TU ]  US9  SU l        U R                  R	                  5       0 4$ )Nr$   r   )r%   r   r   r   r9   r(   s      r   r   FakeImageEnv.reset   s9    GMtM$%%,,.22r   r+   c                     SnU =R                   S-  sl         SnU R                   U R                  :  nU R                  R                  5       X#U0 4$ )Nr>   r   F)r   r   r   r9   r0   s        r   r4   FakeImageEnv.step   sO    Q
%%7	%%,,.IrQQr   rC   c                     g r8   rE   rF   s     r   rG   FakeImageEnv.render   rI   r   )r   r   r   r   r   )   T   r   r   TFrK   )rM   rN   rO   rP   __doc__rQ   rV   r   r   rS   rT   r?   rm   r   r   r	   r4   rW   rG   rX   rY   rZ   s   @r   r   r   q   s    	 #  	
    
( .2T 3Xc] 3HTN 3V[\^\f\fhl\lVm 3 3R5S1 Rm R3 T  r   r   )typingr   r   r   r   r   	gymnasiumgymnumpyr?   r   %stable_baselines3.common.type_aliasesr	   rQ   rm   r
   Envr   r\   ro   rz   r   rE   r   r   <module>r      s    9 9    ?Cbjj!0#''71: 0f\[, \4	;{2::6 	;	;[4 	;.377 .r   