anchor.diff:      end;
       Result := Output;
     end;
  -
  -  // Quarry planner (constants in this function are critical and will not be set by CA)
  -  function FindPlaceForQuary(): Boolean;
  -  const
  -    MAX_DERIVATION = 75;
  -    MAX_SCAN_DIST = 3;
  -  var
  -    Output, IsWalkable: Boolean;
  -    I, Y, MinIdx, MaxIdx: Integer;
  -    Gain, BestGain: Single;
  -    Loc, BestLoc: TKMPoint;
  -    HouseReq: TKMHouseRequirements;
  -    StoneLocs: TKMPointTagList;
  -    InitPointsArr: TKMPointArray;
  -    BuildFF: TKMBuildFF;
  -  begin
  -    Output := False;
  -    BuildFF := gAIFields.Eye.BuildFF;
  -
  -    with HouseReq do
  -    begin
  -      HouseType := aHT;
  -      IgnoreTrees := False;
  -      IgnoreAvoidBuilding := True;
  -      MaxCnt := 20;
  -      MaxDist := 11;
  -    end;
  -
  -    StoneLocs := gAIFields.Eye.GetStoneLocs(); // Find stone locs
  -    try
  -      if (StoneLocs.Count > 0) then
  -      begin
  -        BuildFF.UpdateState(); // Mark walkable area in owner's city
  -        // Consider Ownership in picking stone locs
  -        with StoneLocs do
  -          for I := Count - 1 downto 0 do
  -          begin
  -            IsWalkable := False;
  -            for Y := Items[I].Y to Min(Items[I].Y + MAX_SCAN_DIST, gTerrain.MapY - 1) do
  -              if (BuildFF.VisitIdx = BuildFF.Visited[Y,Items[I].X]) then
  -              begin
  -                Items[I] := KMPoint(Items[I].X,Y);// Set stone loc to closest walkable point (which is bellow actual point)
  -                Tag[I] := Max(0, 10000
  -                                 + Tag[I]
  -                                 - gAIFields.Influences.GetOtherOwnerships(fOwner,Items[I].X,Items[I].Y)
  -                                 - BuildFF.Distance[ Items[I] ]) * 10;
  -                IsWalkable := True;
  -                break;
  -              end;
  -            if not IsWalkable then
  -              Delete(I);
  -          end;
  -        StoneLocs.SortByTag();
  -        MaxIdx := StoneLocs.Count - 1;
  -        // Try find place for quarry
  -        while not Output AND (MaxIdx > 0) do
  -        begin
  -          // Try find cluster of stone locs by influence
  -          for MinIdx := MaxIdx - 1 downto 0 do
  -            if (StoneLocs.Tag[MinIdx + 1] - StoneLocs.Tag[MinIdx] > MAX_DERIVATION) then
  -              break;
  -          // Copy points in stone mountain in specific influence (it can be multiple stone mountains but in same influence area)
  -          SetLength(InitPointsArr, MaxIdx - MinIdx);
  -          for I := MaxIdx downto MinIdx + 1 do
  -            InitPointsArr[MaxIdx - I] := StoneLocs.Items[I];
  -          MaxIdx := MinIdx;
  -          // Try to find stone locs -> array will be automatically filtered by walkable areas inside of BuildFF
  -          BuildFF.FindPlaceForHouse(HouseReq, InitPointsArr, True);
  -          // Evaluate new locs
  -          BestGain := -10000000;
  -          for I := 0 to BuildFF.Locs.Count - 1 do
  -          begin
  -            Loc := BuildFF.Locs.Items[I];
  -            Gain := - ObstaclesInHousePlan(htQuary,Loc) * 10
  -                    - BuildFF.Distance[Loc] * 20 // Snap crit is aggressive
  -                    - BuildFF.DistanceInitPoint[Loc] * 5
  -                    + SnapCrit(aHT, Loc);
  -            if (Gain > BestGain) then
  -            begin
  -              BestGain := Gain;
  -              BestLoc := Loc;
  -              Output := True;
  -            end;
  -          end;
  -        end;
  -        if Output then
  -        begin
  -          AddPlan(aHT, BestLoc);
  -          gHands[fOwner].AI.CityManagement.Builder.LockHouseLoc(aHT, BestLoc);
  -        end;
  -      end;
  -    finally
  -      StoneLocs.Free;
  -    end;
  -    Result := Output;
  -  end;
  -
   var
     Output: Boolean;
   begin
  
positive.code:   begin
      case aHT of
        htWoodcutters: FindForestAndWoodcutter();
        htGoldMine, htCoalMine, htIronMine, htQuary: FindPlaceForMines(aHT);
        htWatchTower:
        begin
          if not fDefenceTowersPlanned then
  
negative.code:   Time := TimeGet() - Time;
    fTimeMeasure := fTimeMeasure + Time;
  end;
  
  
  function TKMCityPlanner.FindPlaceForMines(aHT: TKMHouseType): Boolean;
  