ethicalgardeners.renderer.Renderer

class ethicalgardeners.renderer.Renderer(display=False)[source]

Bases: ABC

Abstract base class defining the interface for environment visualization.

This class provides the foundation for different rendering strategies. It supports both real-time visualization during simulation execution and post-analysis recording for later video export.

Renderers are responsible for visually representing all elements of the simulation environment, including the grid world, agents, flowers, and pollution levels.

display

Flag to enable rendering. If True, the renderer will display the environment.

Type:

bool

__init__(display=False)[source]

Create the renderer.

Parameters:

display (bool, optional) – Flag to enable rendering. If True, the renderer will display the environment. Defaults to False.

Methods

__init__([display])

Create the renderer.

display_render()

Display the rendered frame in the rendering window.

end_render()

Finalize the rendering process.

init(grid_world)

Initialize the renderer with the grid world environment.

render(grid_world, agents)

Render the current state of the grid world.

abstractmethod display_render()[source]

Display the rendered frame in the rendering window.

This method is called to update the rendering window with the current frame. It should be implemented in concrete renderers.

end_render()[source]

Finalize the rendering process.

This method is called at the end of simulation to perform cleanup tasks and finalize any outputs.

init(grid_world)[source]

Initialize the renderer with the grid world environment.

This method is called once at the beginning of simulation to set up the rendering environment based on the grid world properties.

Parameters:

grid_world (GridWorld) – The grid world environment to be rendered.

abstractmethod render(grid_world, agents: dict)[source]

Render the current state of the grid world.

This method visualizes the current state of the environment, including the grid cells, agents, flowers, and pollution levels. It should be implemented in concrete renderers.

Parameters:
  • grid_world (GridWorld) – The current state of the world grid to render.

  • agents (dict) – Dictionary mapping the agent’s gymnasium ID to the Agent instance of the agents to display.