Hierarchy

  • AStar

Constructors

Methods

  • Finds the shortest path in a 2D grid using A* algorithm

    Parameters

    • grid: number[][]

      2D array where 0 is walkable and 1 is obstacle

    • start: Point

      starting point

    • goal: Point

      goal point

    • allowDiagonal: boolean = false

      whether diagonal movement is allowed

    Returns null | Point[]

    array of points representing the path, or null if no path exists

  • Gets valid neighbors of a point in the grid

    Parameters

    • grid: number[][]
    • point: Point
    • allowDiagonal: boolean

    Returns Point[]

  • Heuristic function (Manhattan distance)

    Parameters

    • a: Point
    • b: Point

    Returns number

  • Checks if a point is valid in the grid

    Parameters

    • grid: number[][]
    • point: Point

    Returns boolean

  • Reconstructs the path from start to goal

    Parameters

    • node: Node

    Returns Point[]

Generated using TypeDoc