hex-world
    Preparing search index...

    Function computeFlowField

    • Builds a FlowField over map in one call.

      Convenience for one-off fields. When the destination changes every turn or every frame, construct a FlowField once and call FlowField.compute on it instead — that path reuses its buffers.

      Parameters

      Returns FlowField

      const field = computeFlowField(offsetToHex(goalCol, goalRow), moveCost, map);
      for (const unit of army) {
      const path = field.path(offsetToHex(unit.col, unit.row));
      if (path && path.length > 1) unit.travel(path);
      }