anchor.diff:  interface
   uses
     Classes, Graphics, KromUtils, Math, SysUtils, TypInfo,
  -  KM_Defaults, KM_Points, KM_CommonClasses;
  +  KM_Defaults, KM_Points, KM_CommonClasses, KM_PerfLog;
   
   
   type
  
positive.code: end;
  
  
  function TKMCityPlanner.NextToOre(aHouse: THouseType; aOreType: TResourceType; out aLoc: TKMPoint): Boolean;
  var
    S: TKMHouse;
    I, K: Integer;
    Bid, BestBid: Single;
    P: TKMPoint;
    FoundOre: Boolean;
    CoalLoc: TKMPoint;
    StoreLoc: TKMPoint;
  begin
    Result := False;
  
    S := fPlayers[fOwner].Houses.FindHouse(ht_Store, 0, 0, 1, True);
    if S = nil then Exit;
  
    StoreLoc := S.GetPosition;
  
    FoundOre := False;
    for I := -1 to 1 do
    for K := -1 to 1 do
    begin
      //Look for coal within 8+7 tiles
      P := fTerrain.EnsureTileInMapCoords(StoreLoc.X - K * 12, StoreLoc.Y + I * 12);
      FoundOre := FoundOre or fTerrain.FindOre(P, aOreType, CoalLoc);
    end;
  
    BestBid := MaxSingle;
  
    for I := Max(CoalLoc.Y - 3, 1) to Min(CoalLoc.Y + 3, fTerrain.MapY - 1) do
    for K := Max(CoalLoc.X - 4, 1) to Min(CoalLoc.X + 4, fTerrain.MapX - 1) do
      if fPlayers[fOwner].CanAddHousePlanAI(KMPoint(K,I), aHouse, True) then
      begin
        Bid := GetLength(KMPoint(K,I), StoreLoc) + KaMRandom * 4;
        if Bid < BestBid then
        begin
          aLoc := KMPoint(K,I);
          BestBid := Bid;
          Result := True;
        end;
      end;
  end;
  
  
  
negative.code:   TKMCityPlanner = class
    private
      fOwner: TPlayerIndex;
      fPerfLog: TKMPerfLog;
  
      function FindNearest(aStart: TKMPoint; aMaxRange: Byte; aFunc: TKMPointFunction; out aEnd: TKMPoint): Boolean;
      function NextToOre(aHouse: THouseType; aOreType: TResourceType; out aLoc: TKMPoint): Boolean;
      function NextToHouse(aTarget, aHouse: THouseType; out aLoc: TKMPoint): Boolean;
      function NextToStone(aHouse: THouseType; out aLoc: TKMPoint): Boolean;
      function NextToTrees(aHouse: THouseType; out aLoc: TKMPoint): Boolean;
      //function NextToGrass(aHouse: THouseType; out aLoc: TKMPoint): Boolean;
      function CoalTest(aPoint: TKMPoint): Boolean;
      function IronTest(aPoint: TKMPoint): Boolean;
      function GoldTest(aPoint: TKMPoint): Boolean;
    public
      //Stone, Wood, Farm, Wine, Coal,
      //InfluenceMap: array of array of array [TCityInfluence] of Byte;
  
      constructor Create(aPlayer: TPlayerIndex);
      destructor Destroy; override;
  
      function FindPlaceForHouse(aHouse: THouseType; out aLoc: TKMPoint): Boolean;
      procedure OwnerUpdate(aPlayer:TPlayerIndex);
      procedure UpdateInfluence;
      procedure Save(SaveStream: TKMemoryStream);
      procedure Load(LoadStream: TKMemoryStream);
  