anchor.diff:  
     while (fMinN <> nil) and not DestinationReached(fMinN.X, fMinN.Y) do
     begin
  -
       fMinN.Estim := c_closed;
   
       //Check all surrounding cells and issue costs to them
  -    for Y := Math.max(fMinN.Y-1,1) to Math.min(fMinN.Y+1, gTerrain.MapY-1) do
  -    for X := Math.max(fMinN.X-1,1) to Math.min(fMinN.X+1, gTerrain.MapX-1) do
  +    for Y := Max(fMinN.Y-1,1) to Min(fMinN.Y+1, gTerrain.MapY-1) do
  +    for X := Max(fMinN.X-1,1) to Min(fMinN.X+1, gTerrain.MapX-1) do
       begin
         N := @fOpenRef[Y,X];
         if N.RouteID <> fRouteID then //Cell is new
  
positive.code: 
  
  type
    TANodeRec = record
                  RouteID: Cardinal;
                  X,Y: SmallInt;
                  CostTo: Word;
                  Estim: Word;
                  Parent: Pointer; //PANodeRec
                end;
    PANodeRec = ^TANodeRec;
  
    //This is a helper class for TTerrain
    //Here should be pathfinding and all associated stuff
  
negative.code:       fOpenRef[Y, X].X := X;
        fOpenRef[Y, X].Y := Y;
      end;
  end;
  
  
  