CSC8501_Advanced_Programming_For_Games / MazeGeneration / AStar.h
AStar.h
Raw
#pragma once
#include <vector>
#include <array>
#include <iostream>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>

#include "MazeGenerator.h"
#include "PathGenerator.h"

class AStar : public PathGenerator
{
public:
    static constexpr uint32_t Maze_Char_Space = PathGenerator::Maze_Char_Space; // " " 
    static constexpr uint32_t Maze_Char_Wall = PathGenerator::Maze_Char_Wall; // X 
    static constexpr uint32_t Maze_Char_Path = PathGenerator::Maze_Char_Path; // o 

    static constexpr uint32_t Maze_Char_Exit = PathGenerator::Maze_Char_Exit; // E
    static constexpr uint32_t Maze_Char_Start = PathGenerator::Maze_Char_Start; // S


#define ROW 13
#define COL 31 

    typedef std::pair<int, int> Pair;
    typedef std::pair<double, std::pair<int, int>> pPair;

    struct solution {
        int parent_i, parent_j;
        double f, g, h;
    };


    bool isValid(int row, int col);
    bool isUnBlocked(char** grid, int row, int col);
    bool isDestination(int row, int col, Pair dest);
    double calculateHValue(int row, int col, Pair dest);
    void tracePath(solution solutionDetails[][COL], Pair dest, int* &aStarTrace, int &aStarTraceCount);

    void aStarSearch(char** grid, Pair src, Pair dest, int* &aStarTrace, int &aStarTraceCount);

};