← All Docs

A* Documentation

A* Documentation Source Code

Astar Methods

b8.AStar.pathfind(start, goal, isWalkable, gridWidth, gridHeight)

A Pathfinding Algorithm for grid-based games.

The A algorithm is a popular pathfinding and graph traversal algorithm. It is widely used in games and other applications to find the shortest path between two points. The algorithm combines the benefits of Dijkstra’s algorithm and a heuristic approach to efficiently find the optimal path.

Key Concepts:

  • Open List: A priority queue of nodes to be explored, sorted by their total cost (f).
  • Closed List: A set of nodes that have already been explored.
  • Heuristic (h): An estimate of the cost to reach the goal from a given node.
  • Cost (g): The actual cost to reach a node from the start.
  • Total Cost (f): The sum of g and h (f = g + h).

This implementation assumes a grid-based game where movement is restricted to horizontal and vertical directions. The algorithm explores neighboring cells and calculates their costs to determine the optimal path.

Parameters

  • start (Object): The starting position with properties col and row.
  • goal (Object): The goal position with properties col and row.
  • isWalkable (Function): A function that takes col and row coordinates and returns true if the cell is walkable.
  • gridWidth (number): The width of the grid.
  • gridHeight (number): The height of the grid.

Returns

  • (Array<Object>|null): - The shortest path as an array of positions {col, row}, or null if no path is found.

More BeepMini Docs

A* Documentation

Actors Documentation

Animation Documentation

App Intro Documentation

Async Documentation

Cart API

Core Functions

ECS (Entity Component System) Documentation

Game Math Documentation

Game State

Image Processing

Input Documentation

Inventory API

Joystick Documentation

Menu Documentation

Music Documentation

Particle System Documentation

Passcodes Documentation

Path Documentation

Public API

Random Numbers Documentation

SFX Documentation

Scene Documentation

Text Renderer

Textmode

Tilemap Documentation

Utilities Documentation

Visual Effects Documentation

B8:// Make BeepMini Games