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.

Node represents a single state in the search tree. It stores the taxi’s current position, the set of passengers already collected, the accumulated path cost from the root, and the heuristic estimate to the goal. Instances are immutable by convention — each move produces a fresh child node rather than modifying an existing one. Node implements __eq__, __hash__, and __lt__ so it can be stored in sets, used as dictionary keys, and placed directly on a priority heap.
from mundo import Node

Constructor

Node(posicion, pasajeros_recogidos=None, padre=None, g=0, h=0)

Creates a search-tree node and immediately computes the two derived attributes f and profundidad.
posicion
tuple[int, int]
required
The (row, column) coordinates of the taxi in the grid at this state.
pasajeros_recogidos
Collection[tuple[int, int]] | None
default:"None"
Positions of passengers that have already been picked up on the path leading to this node. Any iterable of coordinate tuples is accepted and stored as a frozenset. Defaults to an empty frozenset when None is passed.
padre
Node | None
default:"None"
The parent node in the search tree — the state from which this node was reached. Pass None for the root node.
g
int | float
default:"0"
Accumulated movement cost from the root node to this node.
h
int | float
default:"0"
Heuristic estimate of the remaining cost from this node to the goal. Defaults to 0, which makes uninformed algorithms (BFS, DFS, UCS) behave correctly without needing to supply a heuristic.
Two additional attributes are computed at construction time and are not passed as arguments:
  • f — priority value equal to g + h, used for heap ordering in informed searches.
  • profundidad — depth in the search tree, equal to padre.profundidad + 1 if a parent exists, otherwise 0.
from mundo import Node

raiz = Node((2, 0))
hijo = Node((2, 1), padre=raiz, g=1)

print(hijo.profundidad)  # 1
print(hijo.f)            # 1

Attributes

NameTypeDescription
posiciontuple[int, int](row, column) coordinates in the grid
pasajeros_recogidosfrozenset[tuple[int, int]]Passengers collected on the path to this node
padreNode | NoneParent node in the search tree; None for the root
gint | floatAccumulated cost from the root node
hint | floatHeuristic estimate of remaining cost to the goal
fint | floatPriority score — g + h — used for heap ordering
profundidadintDepth from the root node (0-based)

Methods

obtener_camino()

Reconstructs the full path from the root of the search tree to this node by walking the padre chain backwards and reversing the result.
result
list[tuple[int, int]]
An ordered list of (row, column) positions starting at the root node and ending at this node’s position.
from mundo import Node

raiz = Node((0, 0))
n1 = Node((0, 1), padre=raiz, g=1)
n2 = Node((0, 2), padre=n1, g=2)

print(n2.obtener_camino())  # [(0, 0), (0, 1), (0, 2)]
For goal-test nodes returned by a search algorithm, call obtener_camino() directly to recover the solution path without any additional bookkeeping.

__eq__(other)

Two nodes are considered equal when they represent the same search state — that is, the same grid position and the same set of collected passengers. The values of g, h, f, and profundidad are intentionally ignored so that revisit detection works correctly regardless of how a state was reached.
other
Node
required
The node to compare against.
result
bool
True if self.posicion == other.posicion and self.pasajeros_recogidos == other.pasajeros_recogidos.
a = Node((1, 2), g=3)
b = Node((1, 2), g=10)

print(a == b)  # True  — same position, same (empty) passenger set

__hash__()

Returns a hash derived from (posicion, pasajeros_recogidos), matching the equality definition. This makes Node instances safe to use in set collections and as dict keys, which closed-list implementations rely on for O(1) revisit checks.
result
int
An integer hash of the tuple (posicion, pasajeros_recogidos).
visited = set()
n = Node((0, 0))
visited.add(n)

print(Node((0, 0)) in visited)  # True

__lt__(other)

Compares two nodes by their f value. This is required by Python’s heapq module, which calls < when two queue entries have equal priority keys.
other
Node
required
The node to compare against.
result
bool
True when self.f < other.f.
import heapq
from mundo import Node

heap = []
heapq.heappush(heap, Node((0, 2), g=5, h=2))
heapq.heappush(heap, Node((0, 1), g=1, h=1))

# Node with f=2 pops first
print(heapq.heappop(heap).posicion)  # (0, 1)
__lt__ only compares f values; it does not break ties by depth or insertion order. For algorithms like A* that need a stable tie-breaking strategy, wrap nodes in a (f, counter, node) tuple before pushing to the heap.

Build docs developers (and LLMs) love