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.
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.
Viewer(world: gridsim.world.World, window_width: int = 1080, display_rate: int = 10, show_grid: bool = True)¶
__init__(world: gridsim.world.World, window_width: int = 1080, display_rate: int = 10, show_grid: bool = True)¶
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.
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 True. If false, it’s blank.
Draw all of the robots in the world onto the background.