Link Search Menu Expand Document

EvoGym Helpers and Metadata

Some helper functions and globals defined in the evogym package.

Quicklinks:   EvoWorld,   EvoSim,   EvoViewer,   WorldObject,   envs.EvoGymBase,   helper functions and metadata


Page Outline

  1. function get_uniform
  2. function draw
  3. function sample_robot
  4. function is_connected
  5. function has_actuator
  6. function get_full_connectivity
  7. function hashable
  8. constant BASELINE_ENV_NAMES
  9. constant VOXEL_TYPES

function get_uniform

get_uniform(x: int) → ndarray

Return a uniform distribution of a given size.

Args:

  • x (int): size of distribution.

Returns:

  • np.ndarray: array representing the probability distribution.

function draw

draw(pd: ndarray) → int

Sample from a probability distribution.

Args:

  • pd (np.ndarray): array representing the probability of sampling each element.

Returns:

  • int: sampled index.

function sample_robot

sample_robot(
    robot_shape: Tuple[int, int],
    pd: ndarray = None
) → Tuple[ndarray, ndarray]

Return a randomly sampled robot of a particular size.

Args:

  • robot_shape (Tuple(int, int)): robot shape to sample (h, w).
  • pd (np.ndarray): (5,) array representing the probability of sampling each robot voxel (empty, rigid, soft, h_act, v_act). Defaults to a custom distribution. (default = None)

Returns:

  • Tuple[np.ndarray, np.ndarray]: randomly sampled (valid) robot voxel array and its associated connections array.

function is_connected

is_connected(robot: ndarray) → bool

Returns whether or not a certain robot is connected by running floodfill.

Args:

  • robot (np.ndarray): array specifing the voxel structure of the robot.

Returns:

  • bool: whether or not the robot is connected.

function has_actuator

has_actuator(robot: ndarray) → bool

Returns whether or not a certain robot has an actuator.

Args:

  • robot (np.ndarray): array specifing the voxel structure of the robot.

Returns:

  • bool: whether or not the robot has an actuator.

function get_full_connectivity

get_full_connectivity(robot: ndarray) → ndarray

Returns a connections array given a connected robot structure. Assumes all adjacent voxels are connected.

Args:

  • robot (np.ndarray): array specifing the voxel structure of the robot.

Returns:

  • np.ndarray: (2, k) array specifying k pairwise voxel connections. Voxels are specified by their index into the 1D array np.flatten(robot).

function hashable

hashable(robot: ndarray) → str

Returns a hashable representation of a robot.

Args:

  • robot (np.ndarray): array specifing the voxel structure of the robot.

Returns:

  • str: string representation of the robot.

constant BASELINE_ENV_NAMES

BASELINE_ENV_NAMES: list[str]

List of all 32 evogym environment names.


constant VOXEL_TYPES

VOXEL_TYPES: Dict[str, int] = {
    'EMPTY': 0,
    'RIGID': 1,
    'SOFT': 2,
    'H_ACT': 3,
    'V_ACT': 4,
    'FIXED': 5,
}

Dictionary mapping voxel names to values.


This file was automatically generated via lazydocs.


Table of contents