Trait ExperienceBufferBase

Source
pub trait ExperienceBufferBase {
    type Item;

    // Required methods
    fn push(&mut self, tr: Self::Item) -> Result<()>;
    fn len(&self) -> usize;
}
Expand description

Interface for buffers that store experiences from environments.

This trait defines the basic operations for storing experiences in a buffer. It is typically used by processes that need to sample experiences for training.

§Type Parameters

  • Item - The type of experience stored in the buffer

§Examples

struct SimpleBuffer<T> {
    items: Vec<T>,
}

impl<T> ExperienceBufferBase for SimpleBuffer<T> {
    type Item = T;

    fn push(&mut self, tr: T) -> Result<()> {
        self.items.push(tr);
        Ok(())
    }

    fn len(&self) -> usize {
        self.items.len()
    }
}

Required Associated Types§

Source

type Item

The type of items stored in the buffer.

This can be any type that represents an experience or transition from the environment.

Required Methods§

Source

fn push(&mut self, tr: Self::Item) -> Result<()>

Pushes a new experience into the buffer.

§Arguments
  • tr - The experience to store
§Returns

Ok(()) if the push was successful, or an error if it failed

Source

fn len(&self) -> usize

Returns the current number of experiences in the buffer.

§Returns

The number of experiences currently stored

Implementors§