o
    ciV                     @   s6   d dl Zd dlZd dlmZ eG dd dejZdS )    N)	PublicAPIc                       sD   e Zd ZdZdejdef fddZdd Zdd	 Z	d
d Z
  ZS )RepeatedaY  Represents a variable-length list of child spaces.

    Example:
        self.observation_space = spaces.Repeated(spaces.Box(4,), max_len=10)
            --> from 0 to 10 boxes of shape (4,)

    See also: documentation for rllib.models.RepeatedValues, which shows how
        the lists are represented as batched input for ModelV2 classes.
    child_spacemax_lenc                    s   t    || _|| _d S N)super__init__r   r   )selfr   r   	__class__ S/home/ubuntu/.local/lib/python3.10/site-packages/ray/rllib/utils/spaces/repeated.pyr      s   

zRepeated.__init__c                    s&    fddt  jd jd D S )Nc                    s   g | ]} j  qS r   )r   sample).0_r	   r   r   
<listcomp>   s    z#Repeated.sample.<locals>.<listcomp>   )range	np_randomintegersr   r   r   r   r   r      s   
zRepeated.samplec                    s4   t |ttjfot| jkot fdd|D S )Nc                 3   s    | ]	} j |V  qd S r   )r   contains)r   cr   r   r   	<genexpr>"   s    z$Repeated.contains.<locals>.<genexpr>)
isinstancelistnpndarraylenr   all)r	   xr   r   r   r      s
   zRepeated.containsc                 C   s   d | j| jS )NzRepeated({}, {}))formatr   r   r   r   r   r   __repr__%   s   zRepeated.__repr__)__name__
__module____qualname____doc__gymSpaceintr   r   r   r"   __classcell__r   r   r
   r   r      s    
r   )	gymnasiumr'   numpyr   ray.rllib.utils.annotationsr   r(   r   r   r   r   r   <module>   s
    