EvoWorld
Specifies the initial state of any voxels & objects that make up an EvoGym environment.
Quicklinks: EvoWorld, EvoSim, EvoViewer, WorldObject, envs.EvoGymBase, helper functions and metadata
Page Outline
class EvoWorld
Specify the layout of an Evolution Gym environment.
method __init__
__init__() → None
method add_from_array
add_from_array(
name: 'str',
structure: 'ndarray',
x: 'int',
y: 'int',
connections: 'Optional[ndarray]' = None
) → None
Add a single object to the world from array.
Args:
name
(str): object name.structure
(np.ndarray):(n, m)
array specifing the voxel structure of the object. Seeevogym.VOXEL_TYPES
.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
.connections
(Optional[np.ndarray]):(2, k)
array specifyingk
pairwise 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 add_from_json
add_from_json(file_path: 'str') → None
Add objects to an existing EvoWorld
object from a .json
environment specification file. These can be created using the EvoGym Design Tool.
Args:
file_path
(str): path to file. Ex:my_env.json
.
method add_object
add_object(obj: 'WorldObject') → None
Add a single object to the world.
Args:
obj
(WorldObject): object to add.
classmethod from_json
from_json(file_path: 'str') → EvoWorld
Create an EvoWorld
object from a .json
environment specification file (these can be created using the EvoGym Design Tool) and return it.
Args:
file_path
(str): path to file. Ex:my_env.json
.
Returns:
EvoWorld
: resultingEvoWorld
object.
method move_object
move_object(obj_name: 'str', x: 'int', y: 'int') → None
Move an object in world by name.
Args:
obj_name
(str): object name.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 pretty_print
pretty_print(voxels_per_line: 'int' = 50) → None
Print world to console for debugging. Voxels are specified by (R)igid, (S)oft, (H)orizontal Actuator, (V)ertical Actuator, (F)ixed.
Args:
voxels_per_line
(int): Number of voxels to print per line – reduce for smaller screens. (default = 50)
method remove_object
remove_object(obj_name: 'str') → WorldObject
Remove an object from world by name and return it.
Args:
obj_name
(str): object name.
Returns:
WorldObject
: removed, returned object.
method translate_object
translate_object(obj_name: 'str', dx: 'int', dy: 'int') → None
Translate an object in world by name.
Args:
obj_name
(str): object name.dx
(int): change in x-position.dy
(int): change in y-position.
This file was automatically generated via lazydocs.