AI Glossary / Graphs and symbolic AI / Beginner

Rectangular grid

Definition

A rectangular grid is a two-dimensional arrangement of locations organized into rows and columns. In AI, it often provides a simple representation of an environment or search space. Locations can represent cells or graph nodes, while explicitly defined connections describe permitted movement. The grid's geometry alone does not specify obstacles, movement costs, or what an agent can observe.

What it means

A grid gives every location a convenient pair of coordinates. Instead of describing a robot as being somewhere near a shelf, a simplified model might place it at row two, column four. Each location can carry information such as occupancy, terrain type, or a reward.

This representation is useful because it turns spatial questions into discrete decisions: which neighboring location can be entered, what does moving there cost, and has the destination been reached? It is also an approximation. A real room contains continuous positions, objects of different sizes, and movements that may not align neatly with rows and columns.

How it works

Choose the grid dimensions and define what each coordinate represents. Then specify the neighborhood. In a common four-neighbor grid, a location connects horizontally and vertically to adjacent locations. Interior nodes can have four neighbors, while ordinary non-wrapping boundary nodes have fewer. Other models add diagonal movement.

Mark unavailable locations or transitions and assign costs to the legal moves. A search algorithm can then explore the resulting graph. The map is the representation; the search procedure determines how it is used.

Boundary rules must be explicit. Ordinary grids stop at their edges. Periodic grids connect opposite boundaries, producing a different topology. If a state also depends on heading, remaining energy, or collected items, coordinates alone are insufficient: those additional variables must be represented too.

Three practical examples

  • Route planning: a simplified floor map marks occupied cells and searches for a path between two free locations.
  • Agent education: a grid-world exercise lets learners compare policies for reaching a goal while avoiding blocked spaces.
  • Image reasoning: a system associates labels or measurements with regularly arranged image locations and compares neighboring regions.

Think of it this way

Think of a sheet of squared paper used to sketch a room. The squares make positions and neighbor relationships easy to discuss, but a drawn square does not tell you whether a trolley fits through a doorway. The analogy highlights the grid's organizing role. Physical dimensions, movement rules, and clearance requirements still need separate modeling.

Worked example

Consider a non-wrapping grid with three rows and four columns. Label its locations (r, c), with r from one to three and c from one to four. Permit only horizontal or vertical moves, each costing one.

There are 3 × 4 = 12 nodes. Horizontal edges total 3 × 3 = 9, and vertical edges total 2 × 4 = 8, giving 17 undirected edges. Each edge is counted once.

From (1,1) to (3,4), a path must change its row twice and its column three times. In an unobstructed grid, five moves suffice. This is the Manhattan distance: |3−1| + |4−1| = 5.

Block (1,2) and (2,2). A valid five-move path still exists: (1,1), (2,1), (3,1), (3,2), (3,3), (3,4). Blocking an additional location, (3,2), creates a complete vertical barrier and makes the destination unreachable from the left column. A numerical distance estimate of five does not prove that a legal path exists.

Illustrative case study

Fictional case: Rowan Learning Lab creates a delivery-agent demonstration using a rectangular grid. Students first work with four-neighbor movement and unit costs. They can inspect the entire map, so the exercise isolates basic path search.

The instructor later adds costly floor regions and a facing direction. Students discover that the route with the fewest location changes need not have the lowest total cost once turns or terrain carry different penalties. They also learn that two visits to the same coordinate can represent different states when heading matters.

This is a fictional teaching exercise. Its successful routes demonstrate behavior inside the stated model, not validated navigation for a physical delivery robot.

Common misconceptions and mistakes

A grid is not automatically a complete state description. Position may omit information required to predict the result of an action.

Do not assume that diagonals are allowed simply because cells touch at corners. If diagonals are permitted, their costs and rules for passing between obstacles must be specified. Manhattan distance can overestimate the number of moves when unit-cost diagonal shortcuts are available.

Another mistake is confusing cells with grid intersections. Either can represent locations, but mixing those conventions changes dimensions and connectivity. Finally, reducing cell size increases spatial detail and usually increases the number of locations; it does not automatically correct inaccurate obstacle measurements.

Business use

Rectangular grids offer an understandable starting point for spatial prototypes, simulation, and algorithm comparison. Teams can visualize constraints, inspect routes, and create repeatable test situations without first building a detailed geometric model.

Choose resolution according to the decisions the model must support. A coarse grid may hide a narrow passage, while a finer one increases computation and data requirements. Record how physical space maps to coordinates, which transitions are legal, and whether travel costs correspond to distance, time, or another objective. Those choices determine whether a computed path is useful.

People also ask

Must the cells be square?

A rectangular arrangement can use different spacing along the two axes. If physical distances differ, movement costs should reflect that when distance is the objective.

Is every rectangular grid a graph?

It can be represented as a graph by defining nodes and edges. The array of stored values alone does not determine which transitions are allowed.

Does a grid require a fully known environment?

No. An agent can maintain uncertain or unknown cell information and update it from observations. Planning must then account for that uncertainty.

Check your understanding

In the worked example, does blocking all three cells in column two merely lengthen the route?

Answer: No. With four-neighbor movement and no wrapping, that column separates the start from the goal, so no legal route remains.

Related terms

  • State space
  • Graph search
  • Occupancy grid
  • Manhattan distance
  • Neighborhood
  • Path planning
  • Discretization
  • grid world

Learn next

draw the same small map with four-neighbor and eight-neighbor movement. Compare reachable locations and shortest paths, then add a heading variable to see why a location and a complete state need not be identical.

  • Shortest Paths

More in Graphs and symbolic AI

  • Recombination - Recombination is an evolutionary-computation operation that creates candidate solutions by combining information from parent candidates.
  • Reconstruction - Reconstruction, in computer vision, is the process of estimating a scene's three-dimensional structure from observations such as photographs.
  • Record linkage - Record linkage is the process of deciding which records refer to the same real-world entity across or within datasets.
  • Rectified Linear Unit - A Rectified Linear Unit, usually abbreviated ReLU, is a neural-network activation function defined by ReLU(x) = max(0, x).
  • Recursive best-first search - Recursive best-first search, or RBFS, is a heuristic search algorithm that pursues promising paths while limiting memory use.
  • Reduct - A reduct, in stable-model logic programming, is a simplified program constructed relative to a proposed set of true atoms.

Sources

Primary sources: AIMA's agent-environment documentation describes rectangular grid environments: https://aima.cs.berkeley.edu/2nd-ed/lisp/doc/overview-AGENTS.html . NetworkX documents its two-dimensional grid graph and periodic-boundary option: https://networkx.org/documentation/stable/reference/generated/networkx.generators.lattice.grid_2d_graph.html . The finite graph counts, obstacle example, and fictional case here are original teaching constructions.

Previous: Recordset Next: Rectification

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer