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.

busqueda_no_informada is a single function that implements three frontier strategies — BFS (queue), DFS (stack), and UCS (min-heap by cost) — controlled by the modo parameter. All three strategies share the same state representation and goal check: the taxi must collect every passenger in pasajeros_totales before arriving at grid.destino. The only difference between them is how the frontier is ordered and which nodes are expanded next.

Import

from algoritmosBusqueda.noinformada.wrapper import busqueda_no_informada

Function signature

busqueda_no_informada(grid, nodo_inicial, pasajeros_totales, modo) -> dict | None
grid
Grid
required
The map object that generates neighbour states via get_vecinos. It also exposes grid.destino as the terminal position the taxi must reach.
nodo_inicial
Node
required
The starting search state. Typically constructed with posicion=grid.inicio and pasajeros_recogidos=frozenset() to represent the taxi before any pickups.
pasajeros_totales
frozenset[tuple[int,int]]
required
The complete set of passenger grid positions that must be collected before the goal is declared. Pass frozenset(grid.pasajeros) to require all passengers on the map.
modo
str
required
Frontier strategy to use. Must be one of 'bfs', 'dfs', or 'ucs'. Any other value raises a ValueError.

Return value

Returns a dict with the following keys when a solution is found, or None when the goal is unreachable.
camino
list[tuple[int,int]]
Ordered list of grid positions from the starting cell to the final destination, inclusive.
nodos_expandidos
int
Total number of states that were fully explored (popped from the frontier and added to the visited set) during the search.
profundidad
int
Depth of the solution node in the search tree — equivalent to the number of moves made.
costo
int
Total accumulated movement cost along the solution path, stored in the node’s g attribute.
Returns None when no path exists that collects all passengers and reaches the destination. Always check the return value before indexing into the result dict. Passing an unrecognised modo string raises ValueError immediately.

Frontier strategies

modoData structureStrategyOptimality
'bfs'deque (FIFO)Breadth-First SearchShortest path by number of steps
'dfs'list (LIFO stack)Depth-First SearchLow memory use; not cost-optimal
'ucs'heapq ordered by gUniform-Cost SearchOptimal by accumulated movement cost
Use 'ucs' when movement costs vary across the grid and a cost-optimal route matters. Use 'bfs' when all steps have equal cost and you want the fewest moves. Reserve 'dfs' for quick exploration where optimality is not required.

Visited state encoding

The search tracks visited states as (posicion, pasajeros_recogidos) tuples. This means the same grid cell can be visited more than once if the taxi arrives there with a different set of already-collected passengers — each combination is treated as a distinct state. This is essential for correctness: without passenger tracking in the state key, the search could incorrectly prune paths that revisit a cell on the way to a new pickup.

Usage example

from mundo import Grid, Node, leer_mapa
from algoritmosBusqueda.noinformada.wrapper import busqueda_no_informada

matriz = leer_mapa()
grid = Grid(matriz)
nodo_inicial = Node(posicion=grid.inicio, pasajeros_recogidos=frozenset())
pasajeros_totales = frozenset(grid.pasajeros)

resultado = busqueda_no_informada(grid, nodo_inicial, pasajeros_totales, 'ucs')
if resultado:
    print(f"Cost: {resultado['costo']}")
    print(f"Steps: {len(resultado['camino'])}")

Build docs developers (and LLMs) love