A* Pathfinding Algorithm in C++

Overview

This repository contains a C++ implementation of the A* pathfinding algorithm. A* is a widely used algorithm for finding the shortest path between two points on a graph, considering both the cost to reach the point and a heuristic that estimates the cost from the point to the goal.

Features

  • Efficient Pathfinding:

    A* ensures an efficient and optimal pathfinding algorithm.
  • Configurable Heuristics:

    Users can easily customize the heuristic function according to the specific requirements of their application.
  • Flexible Graph Representation:

    The implementation supports various graph representations, allowing users to adapt it to different scenarios.

Getting Started

Prerequisites

C++ compiler (supporting C++11 or later)


Usage

Clone the repository:
git clone https://github.com/amandeepsirohi/A-Star-CPP.git
cd A-Star-CPP
Compile the code:
g++ a_star.cpp -o astar
Run the executable:
./astar

Configuration

Heuristic Function

To customize the heuristic function, modify the heuristic function(calcHVal) located in a_star.cpp.

double calcHVal(int row, int col, Pair dest)
{
    return ((double)sqrt((row - dest.first) * (row - dest.first) +
                         (col - dest.second) * (col - dest.second)));
}