Informed search algorithms use a heuristic functionDocumentation 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.
h to estimate the cost remaining from any state to the goal, guiding the search toward promising nodes rather than expanding the frontier blindly. In Robotaxi Zoox, both informed algorithms — Greedy Best-First and A* — are exposed through a single function, busqueda_informada, and share the same Manhattan-distance heuristic. They differ only in what value drives the priority queue: Greedy uses h alone, while A* uses f = g + h, balancing real cost against estimated remaining cost.
Function signature
| Parameter | Type | Description |
|---|---|---|
grid | Grid | The map object that generates neighbour nodes and movement costs |
inicio | tuple[int, int] | Starting position (row, col) — typically grid.inicio |
destino | tuple[int, int] | Destination position (row, col) — typically grid.destino |
pasajeros | Collection[tuple[int, int]] | All passenger positions that must be collected before reaching the destination |
modo | str | Search strategy: "avara" (Greedy) or "a_estrella" (A*) |
The Manhattan heuristic
The heuristic estimates the cheapest possible remaining path using straight-line Manhattan distance — the sum of absolute row and column differences between two grid positions:algoritmosBusqueda/informada/wrapper.py:
h adapts to the taxi’s current state:
- Passengers still pending →
h= distance to the nearest uncollected passenger - All passengers collected →
h= distance to the destination
Admissibility
The Manhattan heuristic is admissible — it never overestimates the true cost to reach the goal. On a grid, the actual path between two cells must traverse at least as many steps as the Manhattan distance (which assumes movement in a straight line with no walls). Becauseh ≤ actual remaining cost at every node, A* is guaranteed to return an optimal solution.
Admissibility is preserved even with
FLUJO_ALTO cells. Those cells cost 7 to enter, so the real cost can only be greater than or equal to the Manhattan estimate, never less.Greedy Best-First Search ("avara")
Greedy search prioritises nodes purely by their heuristic value h, ignoring how much the path so far has cost. The node that looks closest to the goal is always expanded first.
- Priority:
honly (accumulated costgis ignored) - Frontier:
heapqmin-heap ordered byh - Complete: no — on certain map configurations the algorithm can revisit states or exhaust the frontier without finding the goal (the visited set mitigates cycles but does not guarantee completeness)
- Optimal: no — the cheapest-looking path at each step is not necessarily the cheapest overall
A* Search ("a_estrella")
A* combines the real accumulated cost g with the heuristic estimate h into a single priority value f = g + h. This balances exploration of cheap paths with guidance toward the goal, making it both complete and optimal.
- Priority:
f = g + h - Frontier:
heapqmin-heap ordered byf - Complete: yes
- Optimal: yes (with an admissible heuristic)
best_g instead of a visited set
A* uses a best_g dictionary rather than a plain visited set. This allows a node to be re-expanded if a cheaper path to the same state is discovered later — something a simple visited set would prevent:
Return value
On success,busqueda_informada returns a dictionary that extends the uninformed result with one extra key:
None is returned when the frontier empties without finding a valid route.
The "heuristica" key holds the final h at the destination. Because all passengers have been collected when the goal is reached, this value will always be 0 (Manhattan distance from the destination to itself) — it is included for reporting and verification purposes.
Full usage example
'a_estrella' with 'avara' to run Greedy Best-First instead — all other arguments remain the same.