hex-world
    Preparing search index...

    Function getMovementRange

    • Returns all cells reachable from center within a movement budget.

      Uses Dijkstra's algorithm — each reachable cell is visited once at its minimum cost. The center cell is always included (at cost 0).

      The returned array includes the center itself. Order is not guaranteed.

      Parameters

      Returns HexCoord[]

      const reachable = getMovementRange(
      offsetToHex(unitCol, unitRow),
      3,
      (from, to) => {
      const { col, row } = hexToOffset(to);
      if (map.getTerrain(col, row) === TerrainType.Water) return Infinity;
      return map.getElevation(col, row) > 4 ? 2 : 1;
      },
      map,
      );