grid_rendering#

Classes#

class prt_sim.common.grid_rendering.GridworldRender(grid_width: int, grid_height: int, window_size: Tuple[int, int], agent_icons: Dict[str, str], render_mode: str = 'human', render_fps: int = 5, window_title: str = 'Gridworld', background_color: Tuple[int, int, int] = (255, 255, 255))[source]#

This class renders a grid world using icons for the agents in the world.

It is assumed that position (0, 0) is the top left of the window, and x is positive right and y is positive down.

Parameters:
  • grid_width (int) – width of the grid

  • grid_height (int) – height of the grid

  • window_size (Tuple[int, int]) – size of the window in pixels

  • agent_icons (Dict[str, str]) – dictionary of agent names and icon file locations

  • render_fps (int) – frames per second for rendering

  • window_title (str) – title of the window

Examples:

close() None[source]#

Safely closes pygame and the display.

render(agent_positions: Dict[str, ndarray])[source]#

Renders the grid world and the agent icons from dictionary of agent names and positions.

Parameters:

agent_positions (Dict[str, np.ndarray]) – dictionary of agent names and numpy array of (x,y) grid positions