direction At
Unit vector pointing from point toward the center of the passable neighbor of point's cell with the smallest field value (i.e., the most-downhill step in the gradient).
Returns Point2D(0.0, 0.0) when the agent should not move:
already at a source (goal reached),
cell is unreachable from any source,
cell is blocked or out of bounds,
no passable neighbor strictly improves the field value — i.e. the agent is on a flat plateau or local minimum (which can happen with equal- or zero-cost regions); such cells intentionally yield a stop.
When several neighbors tie for the best (lowest) field value, the unit directions toward each are averaged, so a symmetric layout produces an unbiased heading rather than arbitrarily snapping to whichever neighbor happens to come first in iteration order. If the tied directions cancel exactly, the single best neighbor is used as a fallback.
The zero-vector return lets a force-summation expression like field.directionAt(pos) * speed short-circuit cleanly when the agent has nowhere to go.