qgym.templates.visualiser module

Generic abstract base class for visualisers of RL environments.

All visualisers should inherit from Visualiser.

class qgym.templates.visualiser.RenderData(screen, font, colors, render_mode)[source]

Bases: object

Class containing usefull data for rendering like screen, font and colors.

colors
font
render_mode
screen
property screen_height: int

Screen height. Alias for self.screen_dimensions[1].

property screen_width: int

Screen width. Alias for self.screen_dimensions[0].

class qgym.templates.visualiser.Visualiser(render_mode, *args)[source]

Bases: object

Visualizer for the the current state of the problem.

close()[source]

Close the screen used for rendering.

Return type:

None

property colors: dict[str, Tuple[int, int, int]]

Dict containing names color pairs.

property font: dict[str, Font]

Dict containing str Font pairs.

property is_open: bool

Boolean value stating whether a pygame.screen is currently open.

abstract render(state)[source]

Render the current state using pygame.

Return type:

None | ndarray[Any, dtype[int32]]

render_data: RenderData
property screen: Surface

Main screen to draw on.

property screen_height: int

Screen height of the main screen.

property screen_width: int

Screen width of the main screen.

step(state)[source]

To be used during a step of the environment.

Renders the display if render_mode is ‘human’, does nothing otherwise.

Parameters:

state (Any) – State to render if render_mode is ‘human’.

Return type:

None