Grid#
A Grid
represents the contents of the gridworld
itself, i.e., the objects in the grid (instances of
GridObject
), their properties, and the
spatial relationships between them. Note, however, that this excludes any
information about the agent itself, which is stored in a separate
Agent
instance. The
Grid
class provides an interface to get, set,
and change its contents.
- class Grid(objects)[source]
A two-dimensional grid of objects.
A container of
GridObject
. This is typically used to represent either the global state of the environment, or a partial agent view. This is basically a two-dimensional array, with some additional methods which help in querying and manipulating its objects.Constructs a grid from the given grid-objects
- Parameters
objects (List[List[GridObject]]) – grid of GridObjects
Note
Cells of a grid are indexed using a combination of matrix-like indexing convention and some pythong indexing conventions:
The first axis is
y
, which expands downwards (as in matrix indexing),The second axis is
x
, which expands rightwards (as in matrix indexing),Indexing starts at \((0,0)\), which represents the top-left cell (as in python indexing),
Negative indices wrap around once, i.e., \((-1,-1)\) represents the bottom-right cell (as in python indexing),
If the grid has shape \((h,w)\), indices outside of the ranges \([-h,h-1]\) and \([-w,w-1]\) results in an
IndexError
being raised (as in python indexing).