Viewer

The Viewer is a simple way to visualize your simulations. After creating the Viewer, just call draw() each step (or less frequently) to see the current state of the World.

Note

The maximum Viewer refresh rate (set at creation with the display_rate argument) also limits the simulation rate. If you want to run faster/higher-throughput simulations, don’t use the Viewer.

class gridsim.viewer.Viewer(world: gridsim.world.World, window_width: int = 1080, display_rate: int = 10, show_grid: bool = False)
__init__(world: gridsim.world.World, window_width: int = 1080, display_rate: int = 10, show_grid: bool = False)

Create a Viewer to display the simulation of a World.

This is optional (for debugging and visualization); simulations can be run much faster if the Viewer is not used.

Parameters
  • world (World) – World to display

  • window_width (int, optional) – Width (in pixels) of the window to display the World, by default 1080

  • display_rate (int, optional) – How fast to update the view (ticks/s), by default 10. In each tick, robots will move by one cell, so keep this low to be able to interpret what’s going on.

  • show_grid (bool, optional) – Whether to show the underlying grid in the World, by default False.

draw()

Draw all of the robots in the world into the World and its environment.