hyphi_gym.common.rendering#
Vizualisation helper to render hyphi-gym board based envs using blender
Module Contents#
Classes#
Base for grid-based games managing |
Attributes#
- hyphi_gym.common.rendering.SCENE#
- class hyphi_gym.common.rendering.Rendering#
Bases:
hyphi_gym.common.board.BoardBase for grid-based games managing • A layout of a variable size • Containing CELLS ∈ [WALL, FIELD, AGENT, TARGET, HOLE] • Navigable with ACTIONS ∈ [UP, RIGHT, DOWN,LEFT]
- setup3D(layout: hyphi_gym.common.board.np.ndarray)#
- reset_world()#
Reset simulation and reposition agent and target to respective i_pos
- update_world(action, mPos, Cell)#
- render()#
Compute the render frames as specified by
render_modeduring the initialization of the environment.The environment’s
metadatarender modes (env.metadata[“render_modes”]) should contain the possible ways to implement the render modes. In addition, list versions for most render modes is achieved through gymnasium.make which automatically applies a wrapper to collect rendered frames.- Note:
As the
render_modeis known during__init__, the objects used to render the environment state should be initialised in__init__.
By convention, if the
render_modeis:None (default): no render is computed.
“human”: The environment is continuously rendered in the current display or terminal, usually for human consumption. This rendering should occur during
step()andrender()doesn’t need to be called. ReturnsNone.“rgb_array”: Return a single frame representing the current state of the environment. A frame is a
np.ndarraywith shape(x, y, 3)representing RGB values for an x-by-y pixel image.“ansi”: Return a strings (
str) orStringIO.StringIOcontaining a terminal-style text representation for each time step. The text can include newlines and ANSI escape sequences (e.g. for colors).“rgb_array_list” and “ansi_list”: List based version of render modes are possible (except Human) through the wrapper,
gymnasium.wrappers.RenderCollectionthat is automatically applied duringgymnasium.make(..., render_mode="rgb_array_list"). The frames collected are popped afterrender()is called orreset().
- Note:
Make sure that your class’s
metadata"render_modes"key includes the list of supported modes.
Changed in version 0.25.0: The render function was changed to no longer accept parameters, rather these parameters should be specified in the environment initialised, i.e.,
gymnasium.make("CartPole-v1", render_mode="human")