anchor.diff:    if RMGSettings.CA then
       CellularAutomaton(A);
   
  +  if RMGSettings.Locs.Resource.MineFix then
  +    MineFix(Resources, A);
  +
     fRNG.Seed := RMGSettings.Seed;
     if RMGSettings.OnePath.ReplaceTerrain then
       SnowMountains(A);
  
positive.code: 
      StepLeft := Round((aMinOffset.Y+aMaxOffset.Y - 4) / Max(1, cntLeft));
      StepRight := Round((aMinOffset.Y+aMaxOffset.Y - 4) / Max(1, cntRight));
  
      VarianceYLeft := StepLeft shr 1;
      VarianceYRight := StepRight shr 1;
      VarianceX := (aMaxOffset.X - aMinOffset.X) shr 2;
      i := 0;
      while i < cntLeft do
      begin
        aLocs[I].X := aMinOffset.X + fRNG.RandomI(VarianceX);
        aLocs[I].Y := aMinOffset.Y + StepLeft * i + fRNG.RandomI(VarianceYLeft);
        i := i + 1;
      end;
      while i < Length(aLocs) do
      begin
        aLocs[I].X := aMaxOffset.X - fRNG.RandomI(VarianceX);
        aLocs[I].Y := aMinOffset.Y + StepRight * (i - cntLeft) + fRNG.RandomI(VarianceYRight);
        i := i + 1;
      end;
    end;
  
    // Locs in Horizontal position
    procedure Horizontal(var aLocs: TKMPointArray; aMinOffset, aMaxOffset: TKMPoint);
    var
      i: Byte;
    begin
      aMinOffset := KMPoint(aMinOffset.Y, aMinOffset.X);
      aMaxOffset := KMPoint(aMaxOffset.Y, aMaxOffset.X);
      Vertical(aLocs, aMinOffset, aMaxOffset);
      for i := Low(aLocs) to High(aLocs) do
        aLocs[I] := KMPoint(aLocs[I].Y, aLocs[I].X);
    end;
  
    // Random locs selected from group of generated points (brute force algorithm but for 1-12 locs it is fine)
    procedure Random(var Locs: TKMPointArray; const Minimum,Maximum: TKMPoint);
      var
        i,j,k, min_idx_overall, min_dist, sum_dist, min_dist_overall, sum_dist_overall: Integer;
        Size: TKMPoint;
        Distances: TInteger2Array;
        Points: TKMPointArray;
  
negative.code:   Result := not KMSamePoint(aResLoc, KMPOINT_ZERO);
  end;
  
  procedure SetSizeOfMountain(aInitPoint: TKMPoint; var aReqSize, aNewSize: Integer; var aCountArr: TInteger2Array; var aPointsArr: TKMPoint2Array; var aPointArr: TKMPointArray);
  var
    Left, Right: Boolean;
    I,X,Y, cnt, elements: Integer;
  begin
    SetLength(aPointArr, Ceil(aReqSize / (VORONOI_STEP*1.0))+10);
    Left := True;
    Right := True;
    X := aInitPoint.X;
    Y := aInitPoint.Y;
    cnt := 1;
    elements := 1;
    aPointArr[0] := KMPoint(X,Y);
    for I := 1 to aReqSize do
    begin
      if (cnt >= aReqSize) then
            break;
      if Right AND (X+I <= High(aCountArr[Y])) AND (aCountArr[Y,X+I] > 0) then
      begin
        aPointArr[elements] := KMPoint(X+I,Y);
        cnt := cnt - aPointsArr[Y,X+I-1].X + aPointsArr[Y,X+I].X;
        elements := elements + 1;
      end
      else
        Right := False;
      if (cnt >= aReqSize) then
        break;
      if Left AND (X-I >= Low(aCountArr[Y])) AND (aCountArr[Y,X-I] > 0) then
      begin
        aPointArr[elements] := KMPoint(X-I,Y);
        cnt := cnt + aPointsArr[Y,X-I+1].X - aPointsArr[Y,X-I].X;
        elements := elements + 1;
      end
      else
        Left := False;
    end;
    aNewSize := Max(0, aReqSize - cnt);
    SetLength(aPointArr, elements);
  end;
  
  
  var
    X,Y,Loc,I,K,overflow, ALL_RES_RADIUS, cnt_FINAL, cnt_ACTUAL, cnt_PREVIOUS, cnt_REQUESTED, RESOURCE, size_Mountain, new_Size: Integer;
    PROB_REDUCER, Fraction: Single;
    TP_S,TP_E, ResLoc: TKMPoint;
    Voronoi,CountArr: TInteger2Array;
    ResSettings: TIntegerArray;
    ResAmount, ResTilesAmount, MinesCnt: array[0..4] of Integer; // Amount of tiles of specific resources
    Locs, PointArr: TKMPointArray;
    PointsArr: TKMPoint2Array;
    SearchResource: TKMSearchBiome;
    FillResource: TKMFloodWithQueue;
    Output: TBalancedResource1Array;
  begin
  
    // Initialization - Voroni diagram = divide map into small shapes which will be merged later; each shape have its point in PointsArr for fast searching
  