hex-world
    Preparing search index...

    Type Alias MoveCostFn

    MoveCostFn: (from: HexCoord, to: HexCoord) => number

    Cost function supplied by the game. Called for each candidate move. Return Infinity (or any non-finite value) to mark a cell as impassable. Costs must be non-negative.

    IMPORTANT: findPath's A* heuristic assumes every step costs at least 1. If your cost function can return values below 1 (e.g. cheap roads at 0.5), pass that minimum as minMoveCost in FindPathOptions — otherwise returned paths may not be optimal.

    Type Declaration

    const cost: MoveCostFn = (from, to) => {
    const terrain = map.getTerrain(col, row); // close over your HexMap
    if (terrain === TerrainType.Water) return Infinity;
    if (terrain === TerrainType.Rock) return 3;
    return 1;
    };