anchor.diff:    Result := Output - GA_PLANNER_DistCrit_CenterStore * DistFromHouse([ht_Store]);
   end;
   
  -
  +{
  +function TKMCityPlanner.FindPlaceForHouse(aUnlockProcedure: Boolean; aHT: THouseType; out aBestLocs: TKMPointArray): Byte;
  +const
  +  BEST_PLANS_CNT = 5;
  +  INIT_BEST_BID = -1000000;
  +var
  +  BestBidArr: array[0..BEST_PLANS_CNT-1] of Single;
  +
  +  procedure EvaluateLoc(aLoc: TKMPoint);
  +  var
  +    L: Integer;
  +    Bid, POMBid: Single;
  +  begin
  +    Bid := + SnapCrit(aHT, aLoc) * GA_PLANNER_FindPlaceForHouse_SnapCrit
  +           + DistCrit(aHT, aLoc) * GA_PLANNER_FindPlaceForHouse_DistCrit
  +           - GetTreesInHousePlanCnt(aHT, aLoc) * GA_PLANNER_FindPlaceForHouse_TreeInPlan
  +           //+ Abs(fPlannedHouses[HType,I].Loc.Y - Loc.Y) * 3 // Prefer to build houses on left / right side
  +           //+ Abs(fPlannedHouses[HType,I].Loc.X - Loc.X) * 2
  +           - gAIFields.Influences.GetOtherOwnerships(fOwner, aLoc.X, aLoc.Y) * ManTune_PLANNER_FindPlaceForHouse_Influence;
  +    if (aHT = ht_Farm) OR (aHT = ht_Wineyard) then
  +      Bid := Bid + FieldCrit(aHT, aLoc) * GA_PLANNER_FindPlaceForHouse_FarmCrit;
  +    for L := Low(BestBidArr) to High(BestBidArr) do
  +      if KMSamePoint(aLoc, aBestLocs[L]) then
  +        break
  +      else if (Bid > BestBidArr[L]) then
  +      begin
  +        KMSwapPoints(aLoc, aBestLocs[L]);
  +        POMBid := BestBidArr[L];
  +        BestBidArr[L] := Bid;
  +        Bid := POMBid;
  +      end;
  +  end;
  +
  +  procedure FindPlaceInHType(aHT: THouseType);
  +  var
  +    I,K, Dist: Integer;
  +    Dir: TDirection;
  +    HType: THouseType;
  +    Loc: TKMPoint;
  +    HMA: THouseMappingArray;
  +  begin
  +  HMA := gAIFields.Eye.HousesMapping;
  +    for Dist := 2 to MAX_SCAN_DIST_FROM_HOUSE do
  +    begin
  +      for I := fPlannedHouses[HType].Count - 1 downto 0 do
  +        for Dir := Low(HMA[HType].Surroundings[Dist]) to High(HMA[HType].Surroundings[Dist]) do
  +          for K := Low(HMA[HType].Surroundings[Dist,Dir]) to High(HMA[HType].Surroundings[Dist,Dir]) do
  +          begin
  +            Loc := KMPointAdd(fPlannedHouses[HType].Plans[I].Loc, HMA[HType].Surroundings[Dist,Dir,K], HMA[aHT].MoveToEntrance[Dir]);
  +            if gAIFields.Eye.CanAddHousePlan(Loc, aHT, False, not aUnlockProcedure) then
  +              EvaluateLoc(Loc);
  +          end;
  +      if (Dist > 2) AND (BestBidArr[0] <> INIT_BEST_BID) then
  +        break;
  +    end;
  +  end;
  +var
  +  HIdx, I,K,L,Dist: Integer;
  +  Dir: TDirection;
  +  HType: THouseType;
  +  Loc: TKMPoint;
  +  Bid, POMBid: Single;
  +begin
  +  SetLength(aBestLocs, BEST_PLANS_CNT);
  +  for I := Low(BestBidArr) to High(BestBidArr) do
  +    BestBidArr[I] := INIT_BEST_BID;
  +
  +  for HIdx := 0 to 3 do
  +  begin
  +    if (HOUSE_DEPENDENCE[aHT,HIdx] = ht_None) then
  +      break;
  +    FindPlaceInHType( HOUSE_DEPENDENCE[aHT,HIdx] );
  +  end;
  +  for I := High(BestBidArr) downto Low(BestBidArr) do
  +    if (BestBidArr[I] <> INIT_BEST_BID) then
  +      break;
  +  Result := I;
  +end;
  +//}
  +
  +
  +//{
   function TKMCityPlanner.FindPlaceForHouse(aUnlockProcedure: Boolean; aHT: THouseType; out aBestLocs: TKMPointArray): Byte;
   const
     BEST_PLANS_CNT = 5;
  
positive.code:       end
        else
          RemovePlan(aHT, I);
    if (BestBid <> MAX_BID) then
    begin
      aLoc := fPlannedHouses[aHT,BestIdx].Loc;
      aIdx := BestIdx;
      Output := True;
    end;
  
negative.code:   begin
      // Snap to no-build areas (1 tile from house)
      if (tpBuild in gTerrain.Land[aToY,aToX].Passability) then
        Inc(Result, 10);
      //Building roads over fields is discouraged unless unavoidable
      case AvoidBuilding of
        AVOID_BUILDING_HOUSE_OUTSIDE_LOCK: begin Result := 0; end; // 1 tile from future house
        AVOID_BUILDING_NODE_LOCK_FIELD: Inc(Result, 40); // Corn / wine field
        //AVOID_BUILDING_HOUSE_INSIDE_LOCK: begin end; // Tiles inside future house (forbiden)
        //AVOID_BUILDING_NODE_LOCK_ROAD: begin end; // This will not occur
        else
          Inc(Result, 20); // Forest or mines etc.
      end;
    end;
  end;
  
  