Skip to content

1681-engine / index / nearestOpen

Function: nearestOpen() ​

ts
function nearestOpen(
   g, 
   tx, 
   ty, 
   maxRadius?, 
   ok?
): TilePoint | null;

Defined in: src/nav/nearestOpen.ts:8

The open tile nearest to (tx, ty) within maxRadius rings, or null: a start or a goal inside a rock still gets a route. ok narrows what counts (an open tile that is not a door, say). On each ring the closest tile wins, not the first scanned — scanning order once always picked the ring's top-left corner.

Parameters ​

ParameterTypeDefault value
gNavGridundefined
txnumberundefined
tynumberundefined
maxRadiusnumber12
ok(x, y) => boolean...

Returns ​

TilePoint | null

Released under the MIT License.