anchor.diff:    SQR_MIN_DEF_POINT_DISTANCE = 3*3;
   var
     Check: Boolean;
  -  Idx, NearbyIdx, Cnt: Word;
  +  PL: TKMHandIndex;
  +  Idx, NearbyIdx, Cnt, ScannedCnt, AllianceCnt: Word;
     I, K: Integer;
     Direction: TKMDirection;
     PolyArr: TPolygonArray;
   begin
     Result := False;
  +
  +  AllianceCnt := 1;
  +  for PL := 0 to gHands.Count - 1 do
  +    if (fOwner <> PL) AND (gHands[fOwner].Alliances[PL] = at_Ally) then
  +      AllianceCnt := AllianceCnt + 1;
  +
     // Check and determine counts
  +  aFirstLine := BestDefLines.Count;
     if (BestDefLines.Count = 0) then
       Exit
     else if aMinDefeces then
       aBaseCnt := Max(4,BestDefLines.Count)
     else
  -    aBaseCnt := Max(aBaseCnt,BestDefLines.Count);
  +    aBaseCnt := Max(aBaseCnt * AllianceCnt,BestDefLines.Count * 2); // We need much more defeces because most of them will be used by allies
   
     PolyArr := gAIFields.NavMesh.Polygons;
     // Prepare defensive FF - add all polygon is BestDefLines to queue
     NewQueue(fVisitedIdx + 1);
  -  aFirstLine := BestDefLines.Count;
     for I := 0 to BestDefLines.Count - 1 do
     begin
       Idx := BestDefLines.Lines[I].Polygon;
  
positive.code:       end;
      end;
    end;
    SetLength(DefPosArr, Cnt);
    Result := True;
  end;
  
negative.code:   // Execute FF
    SetLength(DefPosArr, aBaseCnt);
    Cnt := 0;
    ScannedCnt := 0;
    while RemoveFromQueue(Idx) AND (Cnt < aBaseCnt) do
    begin
      ScannedCnt := ScannedCnt + 1;
      // Add only defence points with specicific distance
      Check := True;
      for I := 0 to Cnt - 1 do
  