iclbench.environments package

Subpackages

Submodules

iclbench.environments.env_wrapper module

class iclbench.environments.env_wrapper.EnvWrapper(env, env_name, task_name)[source]

Bases: Wrapper

__init__(env, env_name, task_name)[source]

Wraps an environment to allow a modular transformation of the step() and reset() methods.

Parameters:

env – The environment to wrap

property actions
check_action_validity(candidate_action)[source]
get_instruction_prompt(instructions=None)[source]
get_stats()[source]
get_text_action(action)[source]
property max_steps
reset()[source]

Resets the environment with kwargs.

step(action)[source]

Steps through the environment with action.

Module contents

class iclbench.environments.Strings(values, seed=None)[source]

Bases: Space

__init__(values, seed=None)[source]

Constructor of Space.

Parameters:
  • shape (Optional[Sequence[int]]) – If elements of the space are numpy arrays, this should specify their shape.

  • dtype (Optional[Type | str]) – If elements of the space are numpy arrays, this should specify their dtype.

  • seed – Optionally, you can use this argument to seed the RNG that is used to sample from the space

contains(value)[source]

Return boolean specifying if x is a valid member of this space.

map(action)[source]
sample()[source]

Randomly sample an element of this space.

Can be uniform or non-uniform sampling based on boundedness of space.

Parameters:

mask – A mask used for sampling, expected dtype=np.int8 and see sample implementation for expected shape.

Returns:

A sampled actions from the space

iclbench.environments.make_env(env_name, task, config)[source]

Creates and initializes an environment based on the specified environment name and task.

This function supports multiple environment types, each with its own configuration requirements. The function will return a wrapped environment suitable for use with agents in the context of the ICLBench framework.

Parameters:
  • env_name (str) – The name of the environment to create. Supported values include: - “nle” - “minihack” - “babyai” - “crafter” - “craftax” - “textworld” - “babaisai”

  • task (str) – The specific task to be performed within the environment.

  • config (Config) – An object containing configuration settings, which must include environment-specific keys such as: - envs.nle_kwargs (dict): Arguments specific to the NLE environment. - envs.minihack_kwargs (dict): Arguments specific to the MiniHack environment. - envs.babyai_kwargs (dict): Arguments specific to the BabyAI environment. - envs.crafter_kwargs (dict): Arguments specific to the Crafter environment. - envs.craftax_kwargs (dict): Arguments specific to the Craftax environment. - envs.textworld_kwargs (dict): Arguments specific to the TextWorld environment. - envs.babaisai_kwargs (dict): Arguments specific to the Baba Is AI environment.

Returns:

A wrapped environment instance that includes language processing capabilities

and task-specific functionality.

Return type:

EnvWrapper

Raises:

ValueError – If the provided environment name is not recognized.