hex-world
    Preparing search index...

    Interface FindPathOptions

    Finds the lowest-cost path between two hex cells using A*.

    Returns an array of HexCoord from from to to (both inclusive), or null if no path exists.

    The costFn is called for every candidate step. Return Infinity to mark a transition as impassable. Close over your HexMap inside the function — the library does not read terrain data directly.

    const path = findPath(
    offsetToHex(startCol, startRow),
    offsetToHex(goalCol, goalRow),
    (from, to) => {
    const { col, row } = hexToOffset(to);
    return map.getTerrain(col, row) === TerrainType.Water ? Infinity : 1;
    },
    map,
    );
    interface FindPathOptions {
        minMoveCost?: number;
    }
    Index

    Properties

    Properties

    minMoveCost?: number

    The smallest cost your MoveCostFn can return. Scales the A* heuristic so it never overestimates. Default 1 — if your cost function can return values below 1 (e.g. cheap roads at 0.5), pass that minimum here or the returned path may not be optimal.