Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Juan-Carlos-Cruz/robotaxi-zoox/llms.txt

Use this file to discover all available pages before exploring further.

Grid models the city map as a 2D integer matrix. It identifies start, destination, and passenger positions at construction time, and exposes movement rules used by every search algorithm. Every search algorithm in Robotaxi Zoox accepts a Grid instance as its environment and delegates all questions about validity, cost, and adjacency to it.
from mundo import Grid

Cell type constants

Each cell in the matrix is represented by one of six integer constants defined as class attributes on Grid. Algorithms and map files both use these values.
ConstantValueDescription
Grid.LIBRE0Free road cell — passable, movement cost 1
Grid.MURO1Wall — impassable, blocks all movement
Grid.INICIO2Taxi starting position — passable, movement cost 1
Grid.FLUJO_ALTO3High-traffic cell — passable, movement cost 7
Grid.PASAJERO4Passenger pickup cell — passable, movement cost 1
Grid.DESTINO5Goal destination — passable, movement cost 1

Constructor

Grid(matriz)

Initialises the grid, computes its dimensions, and scans the matrix once to locate the start cell, destination cell, and all passenger cells.
matriz
list[list[int]]
required
A rectangular 2D list of integer cell-type values. Each inner list is one row; all rows must have the same length. Use the class constants (Grid.LIBRE, Grid.MURO, etc.) or their raw integer equivalents.
After construction the following attributes are available on the instance:
AttributeTypeDescription
matrizlist[list[int]]The raw cell matrix passed to the constructor
filasintNumber of rows
columnasintNumber of columns
iniciotuple[int, int] | None(row, col) of the first INICIO cell, or None
destinotuple[int, int] | None(row, col) of the first DESTINO cell, or None
pasajeroslist[tuple[int, int]]All PASAJERO positions in reading order
from mundo import Grid

grid = Grid([[2, 0, 5]])
print(grid.inicio)    # (0, 0)
print(grid.destino)   # (0, 2)
print(grid.columnas)  # 3

Methods

es_valida(fila, col)

Returns True when the given coordinates fall inside the grid boundaries.
fila
int
required
Row index to check (0-based).
col
int
required
Column index to check (0-based).
result
bool
True if 0 <= fila < filas and 0 <= col < columnas; False otherwise.
grid = Grid([[2, 0, 5]])

grid.es_valida(0, 2)   # True  — within bounds
grid.es_valida(0, 3)   # False — column 3 doesn't exist
grid.es_valida(-1, 0)  # False — negative index

es_transitable(fila, col)

Returns True when a cell both exists within the grid and is not a wall (Grid.MURO). This is the primary gate used by get_vecinos to filter candidate moves.
fila
int
required
Row index of the target cell.
col
int
required
Column index of the target cell.
result
bool
True if the cell is in-bounds and its value is not Grid.MURO (1).
grid = Grid([[2, 1, 5]])

grid.es_transitable(0, 0)  # True  — INICIO cell
grid.es_transitable(0, 1)  # False — MURO cell
grid.es_transitable(0, 2)  # True  — DESTINO cell

costo_movimiento(fila, col)

Returns the movement cost the taxi incurs when entering a specific cell. All passable cell types have a cost of 1 except FLUJO_ALTO, which costs 7.
fila
int
required
Row index of the destination cell.
col
int
required
Column index of the destination cell.
result
int
7 for high-traffic cells (Grid.FLUJO_ALTO); 1 for all other passable cell types (Grid.LIBRE, Grid.INICIO, Grid.PASAJERO, Grid.DESTINO).
grid = Grid([[2, 3, 5]])

grid.costo_movimiento(0, 0)  # 1 — INICIO
grid.costo_movimiento(0, 1)  # 7 — FLUJO_ALTO
grid.costo_movimiento(0, 2)  # 1 — DESTINO
costo_movimiento does not validate whether the cell is within bounds or traversable. Always call es_transitable first, or rely on get_vecinos which performs that check automatically.

get_vecinos(nodo)

The central movement primitive used by every search algorithm. Given a Node, it attempts to step in four cardinal directions and returns a list of new Node objects for every reachable neighbour. For each passable neighbour the method:
  1. Computes the new accumulated cost (nodo.g + costo_movimiento(...)).
  2. Copies the current set of collected passengers.
  3. If the neighbour cell is Grid.PASAJERO, adds its coordinates to the passenger set.
  4. Constructs and appends a new Node with the updated state.
nodo
Node
required
The current search state. The method reads nodo.posicion, nodo.pasajeros_recogidos, and nodo.g.
result
list[Node]
A list of neighbour nodes, one per passable adjacent cell. The list may be empty if the taxi is completely surrounded by walls or grid edges.
Neighbours are generated in a fixed order: right (0, +1), up (-1, 0), down (+1, 0), left (0, -1). This order is consistent across all algorithms and affects which paths are explored first when costs are equal.
from mundo import Grid, Node

# Row: INICIO — PASAJERO — DESTINO
grid = Grid([[2, 4, 5]])
raiz = Node((0, 0))

vecinos = grid.get_vecinos(raiz)
print(vecinos[0].posicion)             # (0, 1)
print(vecinos[0].pasajeros_recogidos)  # frozenset({(0, 1)}) — passenger collected
print(vecinos[0].g)                    # 1
# Walls block expansion
grid = Grid([
    [2, 1],
    [0, 5],
])
raiz = Node((0, 0))
vecinos = grid.get_vecinos(raiz)

# Only (1, 0) is reachable — right is a wall, up/left are out of bounds
print([v.posicion for v in vecinos])  # [(1, 0)]

Build docs developers (and LLMs) love