<commit_before>unit KM_PathFindingAStarNew;
{$I KaM_Remake.inc}
interface
uses
  SysUtils, Math, KromUtils, KM_PathFinding,
  KM_CommonClasses, KM_Defaults, KM_Terrain, KM_Points, BinaryHeap;


type
  TANode = class
             X,Y: SmallInt;
             CostTo: Word;
             Estim: Word;
             Parent: TANode;
           end;

  //This is a helper class for TTerrain
  //Here should be pathfinding and all associated stuff
  //I think we should refactor this unit and move some TTerrain methods here
  TPathFindingAStarNew = class(TPathFinding)
  private
    fHeap: TBinaryHeap;
    fMinN: TANode;
    fOpenRef: array of array of TANode; //References to OpenList, Sized as map
    fUsedNodes: array of TANode; //Used to make Reset more efficient
    fUsedNodeCount: Integer;
    function HeapCmp(A,B: Pointer): Boolean;
    function GetNodeAt(X,Y: SmallInt): TANode;
    procedure Flush;
  protected
    function MakeRoute: Boolean; override;
    procedure ReturnRoute(NodeList: TKMPointList); override;
  public
    constructor Create;
    destructor Destroy; override;
  end;


implementation


{ TPathFindingAStarNew }
constructor TPathFindingAStarNew.Create;
begin
  inherited;

  fHeap := TBinaryHeap.Create(High(Word));
  fHeap.Cmp := HeapCmp;
end;


destructor TPathFindingAStarNew.Destroy;
begin
  Flush;
  fHeap.Free;<commit_msg>Compile fix - GetNodeAt protected fcn<commit_after>unit KM_PathFindingAStarNew;
{$I KaM_Remake.inc}
interface
uses
  SysUtils, Math, KromUtils, KM_PathFinding,
  KM_CommonClasses, KM_Defaults, KM_Terrain, KM_Points, BinaryHeap;


type
  TANode = class
             X,Y: SmallInt;
             CostTo: Word;
             Estim: Word;
             Parent: TANode;
           end;

  //This is a helper class for TTerrain
  //Here should be pathfinding and all associated stuff
  //I think we should refactor this unit and move some TTerrain methods here
  TPathFindingAStarNew = class(TPathFinding)
  private
    fHeap: TBinaryHeap;
    fMinN: TANode;
    fOpenRef: array of array of TANode; //References to OpenList, Sized as map
    fUsedNodes: array of TANode; //Used to make Reset more efficient
    fUsedNodeCount: Integer;
    function HeapCmp(A,B: Pointer): Boolean;
    procedure Flush;
  protected
    function GetNodeAt(X,Y: SmallInt): TANode;
    function MakeRoute: Boolean; override;
    procedure ReturnRoute(NodeList: TKMPointList); override;
  public
    constructor Create;
    destructor Destroy; override;
  end;


implementation


{ TPathFindingAStarNew }
constructor TPathFindingAStarNew.Create;
begin
  inherited;

  fHeap := TBinaryHeap.Create(High(Word));
  fHeap.Cmp := HeapCmp;
end;


destructor TPathFindingAStarNew.Destroy;
begin
  Flush;
  fHeap.Free;
{'fraction_non_alphanumeric': 0.07357247437774524, 'fraction_numerical': 0.0, 'mean_word_length': 3.4729950900163664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5889294', 'n_tokens_mistral': 922, 'n_tokens_neox': 883, 'n_words': 259}