WorldObject
Helper class to store and manipulate objects in an EvoWorld.
Quicklinks: EvoWorld, EvoSim, EvoViewer, WorldObject, envs.EvoGymBase, helper functions and metadata
Page Outline
class WorldObject 
Store and manipulate objects in a Evolution Gym environment.
method __init__ 
__init__() → None
method copy 
copy() → WorldObject
Returns a copy of object.
Returns:
WorldObject: copy of object.
classmethod from_array 
from_array(
name: 'str',
structure: 'ndarray',
connections: 'Optional[ndarray]' = None
) → WorldObject
Load an object from array and return it.
Args:
name(str): object name.structure(np.ndarray):(n, m)array specifing the voxel structure of the object. Seeevogym.VOXEL_TYPES.connections(Optional[np.ndarray]):(2, k)array specifyingkpairwise voxel connections. Voxels are specified by their index into the 1D arraynp.flatten(structure). The default behavior assumes all adjacent voxels are connected. (default = None)
classmethod from_json 
from_json(file_path: 'str') → WorldObject
Load object from a .json environment specification file (these can be created using the EvoGym Design Tool) and return it. Throws a ValueError if the file contains more than one object.
Args:
file_path(str): path to file. Ex:my_env.json.
Returns:
WorldObject: resultingWorldObjectobject.
method get_connections 
get_connections() → ndarray
Return an object’s connections matrix.
Return: np.ndarray: (2, k) array specifying k pairwise voxel connections. Voxels are specified by their index into the 1D array np.flatten(structure).
method get_name 
get_name() → str
Return an object’s name.
Return: str: name of object.
method get_pos 
get_pos() → Tuple[int, int]
Return an object’s position.
Return: Tuple[int, int]: position of the object (x, y).
method get_structure 
get_structure() → ndarray
Return an object’s structure matrix.
Return: np.ndarray: (n, m) array specifing the voxel structure of the object. See evogym.VOXEL_TYPES.
method load_from_array 
load_from_array(
name: 'str',
structure: 'ndarray',
connections: 'Optional[ndarray]' = None
) → None
Load an object from array.
Args:
name(str): object name.structure(np.ndarray):(n, m)array specifing the voxel structure of the object. Seeevogym.VOXEL_TYPES.connections(Optional[np.ndarray]):(2, k)array specifyingkpairwise voxel connections. Voxels are specified by their index into the 1D arraynp.flatten(structure). The default behavior assumes all adjacent voxels are connected. (default = None)
method load_from_json 
load_from_json(file_path: 'str') → None
Load object from a .json environment specification file (these can be created using the EvoGym Design Tool). Throws a ValueError if the file contains more than one object.
Args:
file_path(str): path to file. Ex:my_env.json.
method load_from_parsed_json 
load_from_parsed_json(name: 'str', json_data: 'Any', grid_size: 'Pair') → None
Load object from parsed json data. It is recommended to use WorldObject.load_from_json() instead.
Args:
name(str): object name.json_data(Any): parsed json data.grid_size(Pair): grid size of world object is loaded from.
method rename 
rename(name: 'str') → None
Rename an object.
Args:
name(str): new name.
method set_pos 
set_pos(x: 'int', y: 'int') → None
Move an object. Objects retain their position when added to an instance of EvoWorld.
Args:
x(int): x-position of the bottom & leftmost voxel of the object. Starts at0.y(int): y-position of the bottom & leftmost voxel of the object. Starts at0.
method translate 
translate(dx: 'int', dy: 'int') → None
Translate an object. Objects retain their position when added to an instance of EvoWorld.
Args:
dx(int): change in x-position.dy(int): change in y-position.
This file was automatically generated via lazydocs.