anchor.diff:  end;
   
   
  -{ TKMPointCntList }
  +{ TKMPointAppearenceList }
   procedure TKMPointAppearenceList.Add(const aLoc: TKMPoint);
   var
     Ind: Integer;
  
positive.code:     function GetItem(aIndex: Integer): TKMPointDir;
    public
      procedure Clear;
      procedure Add(const aLoc: TKMPointDir);
      property Count: Integer read fCount;
      property Items[aIndex: Integer]: TKMPointDir read GetItem; default;
      function GetRandom(out Point: TKMPointDir): Boolean;
      procedure ToPointList(aList: TKMPointList; aUnique: Boolean);
      procedure LoadFromStream(LoadStream: TKMemoryStream); virtual;
      procedure SaveToStream(SaveStream: TKMemoryStream); virtual;
    end;
  
  
  
negative.code:   SetLength(fItems, fCount);
    if fCount > 0 then
      LoadStream.Read(fItems[0], SizeOf(fItems[0]) * fCount);
  end;
  
  
  { TKMPointCenteredList }
  constructor TKMPointCenteredList.Create(aCenter: TKMPoint);
  begin
    inherited Create;
    fCenter := aCenter;
  end;
  
  
  procedure TKMPointCenteredList.Add(const aLoc: TKMPoint);
  begin
    inherited;
  
    if fCount >= Length(fWeight) then
      SetLength(fWeight, fCount + 32);
  
    fWeight[fCount - 1] := 1000 / KMLengthSqr(fCenter, aLoc); //smaller weight for distant locs
  end;
  
  
  function TKMPointCenteredList.GetWeightedRandom(out Point: TKMPoint): Boolean;
  var
    I: Integer;
    WeightsSum, Rnd: Extended;
  begin
    Result := False;
  
    if Count = 0 then
      Exit;
  
    WeightsSum := 0;
    for I := 0 to fCount - 1 do
      WeightsSum := WeightsSum + fWeight[I];
  
    Rnd := KaMRandomS1(WeightsSum, 'TKMPointCenteredList.GetWeightedRandom');
  
    for I := 0 to fCount - 1 do
    begin
      if Rnd < fWeight[I] then
      begin
        Point := fItems[I];
        Exit(True);
      end;
      Rnd := Rnd - fWeight[I];
    end;
    Assert(False, 'Error getting weighted random');
  end;
  
  
  