anchor.diff:  
          invalidForeignTilesCnt:=MaxInt;
          invalidNativeTilesCnt:=0;
  +       centerPosValid := false;
   
           for i := 0 to rect.FWidth - 1 do
           begin
  
positive.code:   nativeTestStrongOk: Boolean;
    dirtTestOk: Boolean;
    sandTestOK: Boolean;
  begin
    Result.result:=false;
    Result.flip:=0;
  
negative.code:             if TestTile.TerType <> centerTile.TerType then
              begin
                TestTile.TerType:=centerTile.TerType;
                FOutQueue.Delete(TestTile);
                FOutQueue.Insert(TestTile);
  
                testTiles := GetInvalidTiles(TestTile);
  
                nativeTilesCntNorm:=ifthen(testTiles.NativeTiles.IsEmpty, MaxInt, testTiles.NativeTiles.Size);
  
      					putSuitableTile  := false;
      					addToSuitableTiles := false;
  
                if testTiles.centerPosValid then
                begin
                  if not centerPosValid then
                  begin
                    centerPosValid := true;
                    putSuitableTile := true;
                  end
                  else
                  begin
                    if testTiles.ForeignTiles.Size < invalidForeignTilesCnt then
                    begin
                      putSuitableTile := true;
                    end
                    else
                    begin
                      addToSuitableTiles := true;
                    end;
                  end;
                end
                else if not centerPosValid then
                begin
                   if (nativeTilesCntNorm > invalidNativeTilesCnt)
                     or ((nativeTilesCntNorm = invalidNativeTilesCnt) and (tiles.ForeignTiles.Size < invalidForeignTilesCnt)) then
                   begin
                     putSuitableTile := true;
                   end
                   else if (nativeTilesCntNorm = invalidNativeTilesCnt) and (tiles.ForeignTiles.Size = invalidForeignTilesCnt) then
                   begin
                     addToSuitableTiles := true;
                   end;
                end;
  
                if putSuitableTile then
                begin
                  invalidNativeTilesCnt:=nativeTilesCntNorm;
                  invalidForeignTilesCnt:=tiles.ForeignTiles.Size;
                  SuitableTiles.Free;
                  SuitableTiles := TTileSet.Create;
                  addToSuitableTiles := true;
                end;
  
                if addToSuitableTiles then
                begin
                  SuitableTiles.Insert(TestTile);
                end;
  
                FreeAndNil(testTiles);
                FOutQueue.Delete(TestTile);
              end;
            end;
          end;
  
          if SuitableTiles.Size = 1 then
          begin
            UpdateTerrain(SuitableTiles.NMin^.Data);
          end
          else
          begin
  