Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C++ problems in creating the .h file of an already existing code

Lyt

Coder
Hi, I'm making a little game for a college project.
I was asked by the professor to implement a pathfinding system. He also recommended a site to get the code from https://www.redblobgames.com/pathfinding/a-star/implementation.html. So I took the code, adapted it, translated the comments into Italian (my language) and split it into two files AStar.cpp and Map.cpp. The problem is that in order for the code to work I need to create the respective .h files. I have been trying for several days but still have problems. Would anyone know how to give me a hand? it's my first time working on someone else's code.

this is the Map.cpp file
C++:
#include "librerie.h"

//Crea un tipo di dato GridLocation, che contiene la posizione sulla scacchiera
struct GridLocation {
    int x, y;
};

namespace std {
    //implementare la funzione hash in modo da poter inserire GridLocation in un unordered_set

    //I unordered_set sono contenitori che memorizzano elementi univoci in nessun ordine particolare
    // e che consentono il recupero rapido di singoli elementi in base al loro valore.
    template <> struct hash<GridLocation> {
        std::size_t operator()(const GridLocation& id) const noexcept {
            // NOTE: better to use something like boost hash_combine
            return std::hash<int>()(id.x ^ (id.y << 16));
        }
    };
}



struct SquareGrid {
    static std::array<GridLocation, 4> DIRS;

    int width, height;
    std::unordered_set<GridLocation> walls;

    SquareGrid(int width_, int height_)
            : width(width_), height(height_) {}

    bool in_bounds(GridLocation id) const {
        return 0 <= id.x && id.x < width
               && 0 <= id.y && id.y < height;
    }

    bool passable(GridLocation id) const {
        return walls.find(id) == walls.end();
    }

    std::vector<GridLocation> neighbors(GridLocation id) const {
        std::vector<GridLocation> results;

        for (GridLocation dir : DIRS) {
            GridLocation next{id.x + dir.x, id.y + dir.y};
            if (in_bounds(next) && passable(next)) {
                results.push_back(next);
            }
        }

        if ((id.x + id.y) % 2 == 0) {
            // see "Ugly paths" section for an explanation:
            std::reverse(results.begin(), results.end());
        }

        return results;
    }
};

std::array<GridLocation, 4> SquareGrid::DIRS = {
        //imposta le direzioni
        GridLocation{1, 0}, //East
        GridLocation{-1, 0}, //West
        GridLocation{0, -1}, //North
        GridLocation{0, 1} //South
};

// Funzioni che possono tornare utili a GridLocation
//Uguale
bool operator == (GridLocation a, GridLocation b) {
    return a.x == b.x && a.y == b.y;
}
//Diverso
bool operator != (GridLocation a, GridLocation b) {
    return !(a == b);
}
//Percorso
bool operator < (GridLocation a, GridLocation b) {
    return std::tie(a.x, a.y) < std::tie(b.x, b.y);
}

std::basic_iostream<char>::basic_ostream& operator<<(std::basic_iostream<char>::basic_ostream& out, const GridLocation& loc) {
    out << '(' << loc.x << ',' << loc.y << ')';
    return out;
}

//Aggiunge i muri, può essere modificata per generare gli spazzi occupati dai pezzi
void add_rect(SquareGrid& grid, int x1, int y1, int x2, int y2) {
    for (int x = x1; x < x2; ++x) {
        for (int y = y1; y < y2; ++y) {
            grid.walls.insert(GridLocation{x, y}); //genera effettivamente il "muro"
        }
    }
}

//crea la scacchiera e le mura al suo interno
//nel mio caso la scacchiera è 7x6, e non ha muri e aree difficili
//va modificato affinche aggiunga un muro per ogni pezzo che non sia quello mosso
SquareGrid MakeDiagram() {
    SquareGrid grid(7, 6);
    //add_rect(grid, 1, 1, 2, 2);
    typedef GridLocation L;
    return grid;
}



// Crea una classe generica, che viene usata per stampare il grafico della scacchiera
//non è necessaria al gioco, ma può essere utile durante lo sviluppo
template<class Graph>
void draw_grid(const Graph& graph,
               std::unordered_map<GridLocation, double>* distances=nullptr,
               std::unordered_map<GridLocation, GridLocation>* point_to=nullptr,
               std::vector<GridLocation>* path=nullptr,
               GridLocation* start=nullptr,
               GridLocation* goal=nullptr) {
    const int field_width = 3; //crea una costante per la quale alcuni simboli vengono stampati 3 volte
    std::cout << std::string(field_width * graph.width, '_') << '\n'; //stampa la parte alta del grafico ___
    for (int y = 0; y != graph.height; ++y) {
        for (int x = 0; x != graph.width; ++x) {
            GridLocation id {x, y};
            if (graph.walls.find(id) != graph.walls.end()) {
                std::cout << std::string(field_width, '#'); //stampa i muri nel grafico
            } else if (start && id == *start) {
                std::cout << " A "; //stampa start nel grafico
            } else if (goal && id == *goal) {
                std::cout << " Z "; //stampa l'obbiettivo nel grafico
            } else if (path != nullptr && find(path->begin(), path->end(), id) != path->end()) {
                std::cout << " @ "; //stampa il percorso nel grafico
            } else if (point_to != nullptr && point_to->count(id)) {
                GridLocation next = (*point_to)[id];
                if (next.x == x + 1) { std::cout << " > "; }      //stampano i "flussi"
                else if (next.x == x - 1) { std::cout << " < "; } //che partono da start
                else if (next.y == y + 1) { std::cout << " v "; } //e usati, per trovare
                else if (next.y == y - 1) { std::cout << " ^ "; } //il percorso migliore
                else { std::cout << " * "; }
            } else if (distances != nullptr && distances->count(id)) {
                std::cout << ' ' << std::left << std::setw(field_width - 1) << (*distances)[id];
            } else {
                std::cout << " . ";
            }
        }
        std::cout << '\n';
    }
    std::cout << std::string(field_width * graph.width, '~') << '\n'; //stampa la parte bassa del grafico ~~~
}

// Funzione per calcolare la distanza da un punto A ad un punto B
template<class Graph>
int DistanceCalculation(const Graph& graph,
               std::vector<GridLocation>* path=nullptr,
               GridLocation* start=nullptr,
               GridLocation* goal=nullptr) {
int distance=0;
    for (int y = 0; y != graph.height; ++y) {
        for (int x = 0; x != graph.width; ++x) {
            GridLocation id{x, y};
            if (find(path->begin(), path->end(), id) != path->end()) {
                if(find(path->begin(), path->end(), id) == path->begin()){
                }
                else{
                    distance++;
                }
                //std::cout<<"passa da "<< id.x << "-" << id.y <<"\n";
            }
        }
    }
    return distance;
}

this is the AStar.cpp file
C++:
#include "Map.cpp"

template<typename T, typename priority_t>
struct PriorityQueue {
    typedef std::pair<priority_t, T> PQElement;
    std::priority_queue<PQElement, std::vector<PQElement>,
            std::greater<PQElement>> elements;

    inline bool empty() const {
        return elements.empty();
    }

    inline void put(T item, priority_t priority) {
        elements.emplace(priority, item);
    }

    T get() {
        T best_item = elements.top().second;
        elements.pop();
        return best_item;
    }
};

template<typename Location>
std::vector<Location> reconstruct_path(
        Location start, Location goal,
        std::unordered_map<Location, Location> came_from) {
    std::vector<Location> path;
    int control=0;
    Location current = goal;
    while (current != start) {  // fallisce se non trova un percorso
        //std::cout<< "cos'e' current " << current <<"\n";//percorso al contrario
        path.push_back(current);
        current = came_from[current];
        control++;
        if(control==10){  //se non trova il percorso
            path[0].x=-1; //allora esce forzatamente
            path[0].y=-1; //e ritorna un path simbolico che
            return path;  //viene letto dal programma per capire cosa è successo
        }
    }
    //std::cout<< "cos'e' current " << current <<"\n";//percorso al contrario
    path.push_back(start); // opzionale
    std::reverse(path.begin(), path.end());
    return path;
}

inline double heuristic(GridLocation a, GridLocation b) {
    return std::abs(a.x - b.x) + std::abs(a.y - b.y);
}

template<typename Location, typename Graph>
void a_star_search
        (Graph graph,
         Location start,
         Location goal,
         std::unordered_map<Location, Location>& came_from,
         std::unordered_map<Location, double>& cost_so_far)
{
    PriorityQueue<Location, double> frontier;
    frontier.put(start, 0);

    came_from[start] = start;
    cost_so_far[start] = 0;

    while (!frontier.empty()) {
        Location current = frontier.get();

        if (current == goal) {
            break;
        }

        for (Location next : graph.neighbors(current)) {
            double new_cost = cost_so_far[current] + 1;
            if (cost_so_far.find(next) == cost_so_far.end()
                || new_cost < cost_so_far[next]) {
                cost_so_far[next] = new_cost;
                double priority = new_cost + heuristic(next, goal);
                frontier.put(next, priority);
                came_from[next] = current;
            }
        }
    }
}

I've already made several attempts, but they don't work.
Obviously I don't expect you to make me create the .h files, but if possible would you help me understand what I'm doing wrong? My files are now:

AStar.cpp
C++:
#include "AStar.h"

template<typename Location>
std::vector<Location> reconstruct_path(
        Location start, Location goal,
        std::unordered_map<Location, Location> came_from) {
    std::vector<Location> path;
    int control=0;
    Location current = goal;
    while (current != start) {  // fallisce se non trova un percorso
        //std::cout<< "cos'e' current " << current <<"\n";//percorso al contrario
        path.push_back(current);
        current = came_from[current];
        control++;
        if(control==10){  //se non trova il percorso
            path[0].x=-1; //allora esce forzatamente
            path[0].y=-1; //e ritorna un path simbolico che
            return path;  //viene letto dal programma per capire cosa è successo
        }
    }
    //std::cout<< "cos'e' current " << current <<"\n";//percorso al contrario
    path.push_back(start); // opzionale
    std::reverse(path.begin(), path.end());
    return path;
}

inline double heuristic(GridLocation a, GridLocation b) {
    return std::abs(a.x - b.x) + std::abs(a.y - b.y);
}

template<typename Location, typename Graph>
void a_star_search
        (Graph graph,
         Location start,
         Location goal,
         std::unordered_map<Location, Location>& came_from,
         std::unordered_map<Location, double>& cost_so_far)
{
    PriorityQueue<Location, double> frontier;
    frontier.put(start, 0);

    came_from[start] = start;
    cost_so_far[start] = 0;

    while (!frontier.empty()) {
        Location current = frontier.get();

        if (current == goal) {
            break;
        }

        for (Location next : graph.neighbors(current)) {
            double new_cost = cost_so_far[current] + 1;
            if (cost_so_far.find(next) == cost_so_far.end()
                || new_cost < cost_so_far[next]) {
                cost_so_far[next] = new_cost;
                double priority = new_cost + heuristic(next, goal);
                frontier.put(next, priority);
                came_from[next] = current;
            }
        }
    }
}

Astar.h
C++:
#ifndef TURNSYSTEM_CPP_ASTAR_H
#define TURNSYSTEM_CPP_ASTAR_H

#include "Map.h"

template<typename T, typename priority_t>
struct PriorityQueue {
    typedef std::pair<priority_t, T> PQElement;
    std::priority_queue<PQElement, std::vector<PQElement>,
            std::greater<PQElement>> elements;

    inline bool empty() const {
        return elements.empty();
    }

    inline void put(T item, priority_t priority) {
        elements.emplace(priority, item);
    }

    T get() {
        T best_item = elements.top().second;
        elements.pop();
        return best_item;
    }
};


template<typename Location>
std::vector<Location> reconstruct_path(Location start, Location goal,std::unordered_map<Location, Location> came_from);

inline double heuristic(GridLocation a, GridLocation b);

template<typename Location, typename Graph>
void a_star_search(Graph graph, Location start, Location goal, std::unordered_map<Location, Location>& came_from, std::unordered_map<Location, double>& cost_so_far);

#endif //TURNSYSTEM_CPP_ASTAR_H

Map.cpp
C++:
#include "Map.h"

std::array<GridLocation, 4> SquareGrid::DIRS = {
        //imposta le direzioni
        GridLocation{1, 0}, //East
        GridLocation{-1, 0}, //West
        GridLocation{0, -1}, //North
        GridLocation{0, 1} //South
};

// Funzioni che possono tornare utili a GridLocation
//Uguale
bool operator == (GridLocation a, GridLocation b) {
    return a.x == b.x && a.y == b.y;
}
//Diverso
bool operator != (GridLocation a, GridLocation b) {
    return !(a == b);
}
//Percorso
bool operator < (GridLocation a, GridLocation b) {
    return std::tie(a.x, a.y) < std::tie(b.x, b.y);
}

std::basic_iostream<char>::basic_ostream& operator<<(std::basic_iostream<char>::basic_ostream& out, const GridLocation& loc) {
    out << '(' << loc.x << ',' << loc.y << ')';
    return out;
}

//Aggiunge i muri, può essere modificata per generare gli spazzi occupati dai pezzi
void add_rect(SquareGrid& grid, int x1, int y1, int x2, int y2) {
    for (int x = x1; x < x2; ++x) {
        for (int y = y1; y < y2; ++y) {
            grid.walls.insert(GridLocation{x, y}); //genera effettivamente il "muro"
        }
    }
}

//crea la scacchiera e le mura al suo interno
//nel mio caso la scacchiera è 7x6, e non ha muri e aree difficili
//va modificato affinche aggiunga un muro per ogni pezzo che non sia quello mosso
SquareGrid MakeDiagram() {
    SquareGrid grid(7, 6);
    //add_rect(grid, 1, 1, 2, 2);
    typedef GridLocation L;
    return grid;
}



// Crea una classe generica, che viene usata per stampare il grafico della scacchiera
//non è necessaria al gioco, ma può essere utile durante lo sviluppo
template<class Graph>
void draw_grid(const Graph& graph,
               std::unordered_map<GridLocation, double>* distances,
               std::unordered_map<GridLocation, GridLocation>* point_to,
               std::vector<GridLocation>* path,
               GridLocation* start,
               GridLocation* goal) {
    const int field_width = 3; //crea una costante per la quale alcuni simboli vengono stampati 3 volte
    std::cout << std::string(field_width * graph.width, '_') << '\n'; //stampa la parte alta del grafico ___
    for (int y = 0; y != graph.height; ++y) {
        for (int x = 0; x != graph.width; ++x) {
            GridLocation id {x, y};
            if (graph.walls.find(id) != graph.walls.end()) {
                std::cout << std::string(field_width, '#'); //stampa i muri nel grafico
            } else if (start && id == *start) {
                std::cout << " A "; //stampa start nel grafico
            } else if (goal && id == *goal) {
                std::cout << " Z "; //stampa l'obbiettivo nel grafico
            } else if (path != nullptr && find(path->begin(), path->end(), id) != path->end()) {
                std::cout << " @ "; //stampa il percorso nel grafico
            } else if (point_to != nullptr && point_to->count(id)) {
                GridLocation next = (*point_to)[id];
                if (next.x == x + 1) { std::cout << " > "; }      //stampano i "flussi"
                else if (next.x == x - 1) { std::cout << " < "; } //che partono da start
                else if (next.y == y + 1) { std::cout << " v "; } //e usati, per trovare
                else if (next.y == y - 1) { std::cout << " ^ "; } //il percorso migliore
                else { std::cout << " * "; }
            } else if (distances != nullptr && distances->count(id)) {
                std::cout << ' ' << std::left << std::setw(field_width - 1) << (*distances)[id];
            } else {
                std::cout << " . ";
            }
        }
        std::cout << '\n';
    }
    std::cout << std::string(field_width * graph.width, '~') << '\n'; //stampa la parte bassa del grafico ~~~
}

// Funzione per calcolare la distanza da un punto A ad un punto B
template<class Graph>
int DistanceCalculation(const Graph& graph,
               std::vector<GridLocation>* path,
               GridLocation* start,
               GridLocation* goal) {
int distance=0;
    for (int y = 0; y != graph.height; ++y) {
        for (int x = 0; x != graph.width; ++x) {
            GridLocation id{x, y};
            if (find(path->begin(), path->end(), id) != path->end()) {
                if(find(path->begin(), path->end(), id) == path->begin()){
                }
                else{
                    distance++;
                }
                //std::cout<<"passa da "<< id.x << "-" << id.y <<"\n";
            }
        }
    }
    return distance;
}

Map.h
C++:
struct GridLocation {
    int x, y;
};


namespace std {
    //implementare la funzione hash in modo da poter inserire GridLocation in un unordered_set

    //I unordered_set sono contenitori che memorizzano elementi univoci in nessun ordine particolare
    // e che consentono il recupero rapido di singoli elementi in base al loro valore.
    template <> struct hash<GridLocation> {
        std::size_t operator()(const GridLocation& id) const noexcept {
            // NOTE: better to use something like boost hash_combine
            return std::hash<int>()(id.x ^ (id.y << 16));
        }
    };
}


struct SquareGrid {
    static std::array<GridLocation, 4> DIRS;

    int width, height;
    std::unordered_set<GridLocation> walls;

    SquareGrid(int width_, int height_)
            : width(width_), height(height_) {}

    bool in_bounds(GridLocation id) const {
        return 0 <= id.x && id.x < width
               && 0 <= id.y && id.y < height;
    }

    bool passable(GridLocation id) const {
        return walls.find(id) == walls.end(); //Here it gives me error to "find ()"
    }

    std::vector<GridLocation> neighbors(GridLocation id) const {
        std::vector<GridLocation> results;

        for (GridLocation dir : DIRS) {
            GridLocation next{id.x + dir.x, id.y + dir.y};
            if (in_bounds(next) && passable(next)) {
                results.push_back(next);
            }
        }

        if ((id.x + id.y) % 2 == 0) {
            // see "Ugly paths" section for an explanation:
            std::reverse(results.begin(), results.end());
        }

        return results;
    }
};


void add_rect(SquareGrid& grid, int x1, int y1, int x2, int y2);
SquareGrid MakeDiagram();

template<class Graph>
void draw_grid(const Graph& graph,std::unordered_map<GridLocation, double>* distances=nullptr,std::unordered_map<GridLocation, GridLocation>* point_to=nullptr,std::vector<GridLocation>* path=nullptr,GridLocation* start=nullptr,GridLocation* goal=nullptr);

template<class Graph>
int DistanceCalculation(const Graph& graph,
                        std::vector<GridLocation>* path=nullptr,
                        GridLocation* start=nullptr,
                        GridLocation* goal=nullptr);


#endif //TURNSYSTEM_CPP_MAP_H
Here it gives me error to "find ()". But it only started after the CLion update, I don't understand why.
Thanks in advance everyone, and sorry if I made some grammatical errors, as I mentioned this is not my mother tongue
 
Solution
The code works. I also created the header pretty quickly. I'll put the code here in case anyone ever needs it
Code.h
C++:
#ifndef MAIN_CPP_IMPLEMENTATION_H
#define MAIN_CPP_IMPLEMENTATION_H

#include <bits/stdc++.h>

using namespace std;

#define ROW 9
#define COL 10

// Creating a shortcut for int, int pair type
typedef pair<int, int> Pair;

// Creating a shortcut for pair<int, pair<int, int>> type
typedef pair<double, pair<int, int> > pPair;

// A structure to hold the necessary parameters
struct cell {
    // Row and Column index of its parent
    // Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
    int parent_i, parent_j;
    // f = g + h
    double f, g, h;
};

bool isValid(int row, int col);
bool isUnBlocked(int grid[][COL], int...
Sorry for the text walls, but I don't think the problem is in a specific spot, so I didn't know what to share. In addition, the comment to the code remained in Italian, sorry for that

The libraries used (saved in the Librerie.cpp file) are:
C++:
#include <iostream>
#include <time.h>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <vector>
#include <utility>
#include <queue>
#include <tuple>
#include <algorithm>
#include <string>
 
Last edited:
Hello there, @Lyt.

Despite my rusty C skills, I'll do my best to help. But first, could you perhaps share some of the errors you're getting? I've had a lot of problems with .c/.h files and trying to get them to work together in the past, but that is because I keep including all of the headers in the .c files and when I go to include them in another .c file, it begins causing errors and I often have to create one big .h file just to avoid the issue as best I can. Any error codes or other possible solutions you've tried and their results would be handy to know.

Thank you.
 
yes
From last post I made some changes to the code. I essentially moved a few things between Map.h and Map.cpp. Now Clion no longer marks me any errors. But...

Map.h
C++:
#ifndef TURNSYSTEM_CPP_MAP_H
#define TURNSYSTEM_CPP_MAP_H

#include "librerie.h"

struct GridLocation {
    int x, y;
};

struct SquareGrid;


void add_rect(SquareGrid& grid, int x1, int y1, int x2, int y2);
SquareGrid MakeDiagram();

template<class Graph>
void draw_grid(const Graph& graph,std::unordered_map<GridLocation, double>* distances=nullptr,std::unordered_map<GridLocation, GridLocation>* point_to=nullptr,std::vector<GridLocation>* path=nullptr,GridLocation* start=nullptr,GridLocation* goal=nullptr);

template<class Graph>
int DistanceCalculation(const Graph& graph,
                        std::vector<GridLocation>* path=nullptr,
                        GridLocation* start=nullptr,
                        GridLocation* goal=nullptr);


#endif //TURNSYSTEM_CPP_MAP_H

Map.cpp
C++:
#include "Map.h"

namespace std {
    //implementare la funzione hash in modo da poter inserire GridLocation in un unordered_set

    //I unordered_set sono contenitori che memorizzano elementi univoci in nessun ordine particolare
    // e che consentono il recupero rapido di singoli elementi in base al loro valore.
    template <> struct hash<GridLocation> {
        std::size_t operator()(const GridLocation& id) const noexcept {
            // NOTE: better to use something like boost hash_combine
            return std::hash<int>()(id.x ^ (id.y << 16));
        }
    };
}

struct SquareGrid {
    static std::array<GridLocation, 4> DIRS;

    int width, height;
    std::unordered_set<GridLocation> walls;

    SquareGrid(int width_, int height_)
            : width(width_), height(height_) {}

    bool in_bounds(GridLocation id) const {
        return 0 <= id.x && id.x < width
               && 0 <= id.y && id.y < height;
    }

    bool passable(GridLocation id) const {
        return walls.find(id) == walls.end();
    }

    std::vector<GridLocation> neighbors(GridLocation id) const {
        std::vector<GridLocation> results;

        for (GridLocation dir : DIRS) {
            GridLocation next{id.x + dir.x, id.y + dir.y};
            if (in_bounds(next) && passable(next)) {
                results.push_back(next);
            }
        }

        if ((id.x + id.y) % 2 == 0) {
            // see "Ugly paths" section for an explanation:
            std::reverse(results.begin(), results.end());
        }

        return results;
    }
};

std::array<GridLocation, 4> SquareGrid::DIRS = {
        //imposta le direzioni
        GridLocation{1, 0}, //East
        GridLocation{-1, 0}, //West
        GridLocation{0, -1}, //North
        GridLocation{0, 1} //South
};

// Funzioni che possono tornare utili a GridLocation
//Uguale
bool operator == (GridLocation a, GridLocation b) {
    return a.x == b.x && a.y == b.y;
}
//Diverso
bool operator != (GridLocation a, GridLocation b) {
    return !(a == b);
}
//Percorso
bool operator < (GridLocation a, GridLocation b) {
    return std::tie(a.x, a.y) < std::tie(b.x, b.y);
}

std::basic_iostream<char>::basic_ostream& operator<<(std::basic_iostream<char>::basic_ostream& out, const GridLocation& loc) {
    out << '(' << loc.x << ',' << loc.y << ')';
    return out;
}

//Aggiunge i muri, può essere modificata per generare gli spazzi occupati dai pezzi
void add_rect(SquareGrid& grid, int x1, int y1, int x2, int y2) {
    for (int x = x1; x < x2; ++x) {
        for (int y = y1; y < y2; ++y) {
            grid.walls.insert(GridLocation{x, y}); //genera effettivamente il "muro"
        }
    }
}

//crea la scacchiera e le mura al suo interno
//nel mio caso la scacchiera è 7x6, e non ha muri e aree difficili
//va modificato affinche aggiunga un muro per ogni pezzo che non sia quello mosso
SquareGrid MakeDiagram() {
    SquareGrid grid(7, 6);
    //add_rect(grid, 1, 1, 2, 2);
    typedef GridLocation L;
    return grid;
}



// Crea una classe generica, che viene usata per stampare il grafico della scacchiera
//non è necessaria al gioco, ma può essere utile durante lo sviluppo
template<class Graph>
void draw_grid(const Graph& graph,
               std::unordered_map<GridLocation, double>* distances,
               std::unordered_map<GridLocation, GridLocation>* point_to,
               std::vector<GridLocation>* path,
               GridLocation* start,
               GridLocation* goal) {
    const int field_width = 3; //crea una costante per la quale alcuni simboli vengono stampati 3 volte
    std::cout << std::string(field_width * graph.width, '_') << '\n'; //stampa la parte alta del grafico ___
    for (int y = 0; y != graph.height; ++y) {
        for (int x = 0; x != graph.width; ++x) {
            GridLocation id {x, y};
            if (graph.walls.find(id) != graph.walls.end()) {
                std::cout << std::string(field_width, '#'); //stampa i muri nel grafico
            } else if (start && id == *start) {
                std::cout << " A "; //stampa start nel grafico
            } else if (goal && id == *goal) {
                std::cout << " Z "; //stampa l'obbiettivo nel grafico
            } else if (path != nullptr && find(path->begin(), path->end(), id) != path->end()) {
                std::cout << " @ "; //stampa il percorso nel grafico
            } else if (point_to != nullptr && point_to->count(id)) {
                GridLocation next = (*point_to)[id];
                if (next.x == x + 1) { std::cout << " > "; }      //stampano i "flussi"
                else if (next.x == x - 1) { std::cout << " < "; } //che partono da start
                else if (next.y == y + 1) { std::cout << " v "; } //e usati, per trovare
                else if (next.y == y - 1) { std::cout << " ^ "; } //il percorso migliore
                else { std::cout << " * "; }
            } else if (distances != nullptr && distances->count(id)) {
                std::cout << ' ' << std::left << std::setw(field_width - 1) << (*distances)[id];
            } else {
                std::cout << " . ";
            }
        }
        std::cout << '\n';
    }
    std::cout << std::string(field_width * graph.width, '~') << '\n'; //stampa la parte bassa del grafico ~~~
}

// Funzione per calcolare la distanza da un punto A ad un punto B
template<class Graph>
int DistanceCalculation(const Graph& graph,
               std::vector<GridLocation>* path,
               GridLocation* start,
               GridLocation* goal) {
int distance=0;
    for (int y = 0; y != graph.height; ++y) {
        for (int x = 0; x != graph.width; ++x) {
            GridLocation id{x, y};
            if (find(path->begin(), path->end(), id) != path->end()) {
                if(find(path->begin(), path->end(), id) == path->begin()){
                }
                else{
                    distance++;
                }
                //std::cout<<"passa da "<< id.x << "-" << id.y <<"\n";
            }
        }
    }
    return distance;
}

AStar.h

C++:
#ifndef TURNSYSTEM_CPP_ASTAR_H

#define TURNSYSTEM_CPP_ASTAR_H



#include "Map.h"



template<typename T, typename priority_t>

struct PriorityQueue {

    typedef std::pair<priority_t, T> PQElement;

    std::priority_queue<PQElement, std::vector<PQElement>,

            std::greater<PQElement>> elements;



    inline bool empty() const {

        return elements.empty();

    }



    inline void put(T item, priority_t priority) {

        elements.emplace(priority, item);

    }



    T get() {

        T best_item = elements.top().second;

        elements.pop();

        return best_item;

    }

};





template<typename Location>

std::vector<Location> reconstruct_path(Location start, Location goal,std::unordered_map<Location, Location> came_from);



inline double heuristic(GridLocation a, GridLocation b);



template<typename Location, typename Graph>

void a_star_search(Graph graph, Location start, Location goal, std::unordered_map<Location, Location>& came_from, std::unordered_map<Location, double>& cost_so_far);

#endif //TURNSYSTEM_CPP_ASTAR_H

AStar.cpp
C++:
#include "AStar.h"

template<typename Location>
std::vector<Location> reconstruct_path(
        Location start, Location goal,
        std::unordered_map<Location, Location> came_from) {
    std::vector<Location> path;
    int control=0;
    Location current = goal;
    while (current != start) {  // fallisce se non trova un percorso
        //std::cout<< "cos'e' current " << current <<"\n";//percorso al contrario
        path.push_back(current);
        current = came_from[current];
        control++;
        if(control==10){  //se non trova il percorso
            path[0].x=-1; //allora esce forzatamente
            path[0].y=-1; //e ritorna un path simbolico che
            return path;  //viene letto dal programma per capire cosa è successo
        }
    }
    //std::cout<< "cos'e' current " << current <<"\n";//percorso al contrario
    path.push_back(start); // opzionale
    std::reverse(path.begin(), path.end());
    return path;
}

inline double heuristic(GridLocation a, GridLocation b) {
    return std::abs(a.x - b.x) + std::abs(a.y - b.y);
}

template<typename Location, typename Graph>
void a_star_search
        (Graph graph,
         Location start,
         Location goal,
         std::unordered_map<Location, Location>& came_from,
         std::unordered_map<Location, double>& cost_so_far)
{
    PriorityQueue<Location, double> frontier;
    frontier.put(start, 0);

    came_from[start] = start;
    cost_so_far[start] = 0;

    while (!frontier.empty()) {
        Location current = frontier.get();

        if (current == goal) {
            break;
        }

        for (Location next : graph.neighbors(current)) {
            double new_cost = cost_so_far[current] + 1;
            if (cost_so_far.find(next) == cost_so_far.end()
                || new_cost < cost_so_far[next]) {
                cost_so_far[next] = new_cost;
                double priority = new_cost + heuristic(next, goal);
                frontier.put(next, priority);
                came_from[next] = current;
            }
        }
    }
}

Now I no longer report any errors, but in the TurnSystem.cpp file (file in which I use the two files) I get an error:
C++:
void TurnSystem::WhereItMove(sf::Vector2i &mousePos) {
    if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
        if(mouseHeld==false){
            mouseHeld=true;

            destinazione[0]=MouseOnTheBoard(mousePos);

            SquareGrid grid = MakeDiagram(); //ERROR HERE

            for(int i=0;i<p;i++){
                if(token[i]->GetOwner()!=1)
                    add_rect(grid, token[i]->GetPosX(), token[i]->GetPosY(),token[i]->GetPosX()+1, token[i]->GetPosY()+1);
            }

            GridLocation start{attacker->GetPosX(), attacker->GetPosY()}, goal{destinazione[0].x, destinazione[0].y};

            std::unordered_map<GridLocation, GridLocation> came_from;//ERROR HERE
            std::unordered_map<GridLocation, double> cost_so_far;//And error here
            a_star_search(grid, start, goal, came_from, cost_so_far);
            std::vector<GridLocation> path = reconstruct_path(start, goal, came_from);

            distanza=DistanceCalculation(grid, &path, &start, &goal);

            if((PositionCheck()==true) && (distanza <= attacker->GetSpeed()))
            {
                for(int i=0;i<=distanza;i++){
                    std::cout<< "il percorso e' " << path[i].x << " - "<< path[i].y <<"\n";
                    destinazione[i].x=path[i].x;
                    destinazione[i].y=path[i].y;
                }

                phase=PHASE::motionAnimation;
                std::cout << '\n' << "perfetto \n";
            }
            else{
                std::cout << '\n' << "il personaggio non puo' muoversi li, cambia destinazione \n";
            }
        }
    }
    else
        mouseHeld=false;
}
It gives me similar errors elsewhere in the file
And that is when I call the function code, if I compile I get:

FAILED: CMakeFiles/Reisende.dir/TurnSystem.cpp.obj
C:\PROGRA~1\JETBRA~1\CLION2~1.3\bin\mingw\bin\G__~1.EXE -DSFML_STATIC -isystem C:/SFML/include -g -std=gnu++14 -MD -MT CMakeFiles/Reisende.dir/TurnSystem.cpp.obj -MF CMakeFiles\Reisende.dir\TurnSystem.cpp.obj.d -o CMakeFiles/Reisende.dir/TurnSystem.cpp.obj -c C:/Users/franc/Desktop/Reisende/TurnSystem.cpp
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp: In member function 'void TurnSystem::WhereItMove(sf::Vector2i&)':
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:105:24: error: variable 'SquareGrid grid' has initializer but incomplete type
105 | SquareGrid grid = MakeDiagram();
| ^~~~
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:105:42: error: invalid use of incomplete type 'struct SquareGrid'
105 | SquareGrid grid = MakeDiagram();
| ~~~~~~~~~~~^~
In file included from C:/Users/franc/Desktop/Reisende/AStar.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:9,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/Users/franc/Desktop/Reisende/Map.h:28:8: note: forward declaration of 'struct SquareGrid'
28 | struct SquareGrid;
| ^~~~~~~~~~
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:115:60: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = GridLocation; _Tp = GridLocation; _Hash = std::hash<GridLocation>; _Pred = std::equal_to<GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, GridLocation> >]'
115 | std::unordered_map<GridLocation, GridLocation> came_from;
| ^~~~~~~~~
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:47,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/unordered_map.h:141:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = GridLocation; _Tp = GridLocation; _Hash = std::hash<GridLocation>; _Pred = std::equal_to<GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, GridLocation> >]' is implicitly deleted because the default definition would be ill-formed:
141 | unordered_map() = default;
| ^~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/unordered_map.h:141:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = GridLocation; _Value = std::pair<const GridLocation, GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, GridLocation> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:512:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = GridLocation; _Value = std::pair<const GridLocation, GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, GridLocation> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
512 | _Hashtable() = default;
| ^~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:512:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = GridLocation; _Value = std::pair<const GridLocation, GridLocation>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:35,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1602:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = GridLocation; _Value = std::pair<const GridLocation, GridLocation>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
1602 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1602:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = GridLocation; _Value = std::pair<const GridLocation, GridLocation>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1209:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = GridLocation; _Value = std::pair<const GridLocation, GridLocation>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
1209 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1209:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<GridLocation>]'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1126:7: note: 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<GridLocation>]' is implicitly deleted because the default definition would be ill-formed:
1126 | _Hashtable_ebo_helper() = default;
| ^~~~~~~~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1126:7: error: use of deleted function 'std::hash<GridLocation>::hash()'
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/basic_string.h:6859,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/string:55,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/locale_classes.h:40,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/ios_base.h:41,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/ios:42,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/ostream:38,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/iostream:39,
from C:/Users/franc/Desktop/Reisende/Librerie.h:1,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:102:12: note: 'std::hash<GridLocation>::hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<GridLocation, false>::__hash_enum()'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = GridLocation; bool <anonymous> = false]'
83 | __hash_enum(__hash_enum&&);
| ^~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = GridLocation; bool <anonymous> = false]' is private within this context
102 | struct hash : __hash_enum<_Tp>
| ^~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:35,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1126:7: error: use of deleted function 'std::hash<GridLocation>::~hash()'
1126 | _Hashtable_ebo_helper() = default;
| ^~~~~~~~~~~~~~~~~~~~~
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/basic_string.h:6859,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/string:55,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/locale_classes.h:40,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/ios_base.h:41,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/ios:42,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/ostream:38,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/iostream:39,
from C:/Users/franc/Desktop/Reisende/Librerie.h:1,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:102:12: note: 'std::hash<GridLocation>::~hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = GridLocation; bool <anonymous> = false]' is private within this context
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:35,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1209:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>::~_Hashtable_ebo_helper()'
1209 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1123:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
1123 | struct _Hashtable_ebo_helper<_Nm, _Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1123:12: error: use of deleted function 'std::hash<GridLocation>::~hash()'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1602:7: error: use of deleted function 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
1602 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1187:12: note: 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed:
1187 | struct _Hash_code_base
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1187:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>::~_Hashtable_ebo_helper()'
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:512:7: error: use of deleted function 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()'
512 | _Hashtable() = default;
| ^~~~~~~~~~
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:35,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1559:12: note: 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()' is implicitly deleted because the default definition would be ill-formed:
1559 | struct _Hashtable_base
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1559:12: error: use of deleted function 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:116:54: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = GridLocation; _Tp = double; _Hash = std::hash<GridLocation>; _Pred = std::equal_to<GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, double> >]'
116 | std::unordered_map<GridLocation, double> cost_so_far;
| ^~~~~~~~~~~
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:47,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/unordered_map.h:141:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = GridLocation; _Tp = double; _Hash = std::hash<GridLocation>; _Pred = std::equal_to<GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, double> >]' is implicitly deleted because the default definition would be ill-formed:
141 | unordered_map() = default;
| ^~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/unordered_map.h:141:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = GridLocation; _Value = std::pair<const GridLocation, double>; _Alloc = std::allocator<std::pair<const GridLocation, double> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:512:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = GridLocation; _Value = std::pair<const GridLocation, double>; _Alloc = std::allocator<std::pair<const GridLocation, double> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
512 | _Hashtable() = default;
| ^~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:512:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = GridLocation; _Value = std::pair<const GridLocation, double>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:35,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1602:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = GridLocation; _Value = std::pair<const GridLocation, double>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
1602 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1602:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = GridLocation; _Value = std::pair<const GridLocation, double>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1209:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = GridLocation; _Value = std::pair<const GridLocation, double>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
1209 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1209:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<GridLocation>]'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1209:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>::~_Hashtable_ebo_helper()'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1602:7: error: use of deleted function 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, double>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
1602 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1187:12: note: 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, double>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed:
1187 | struct _Hash_code_base
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1187:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>::~_Hashtable_ebo_helper()'
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:512:7: error: use of deleted function 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, double>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()'
512 | _Hashtable() = default;
| ^~~~~~~~~~
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:35,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1559:12: note: 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, double>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()' is implicitly deleted because the default definition would be ill-formed:
1559 | struct _Hashtable_base
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1559:12: error: use of deleted function 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, double>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp: In member function 'void TurnSystem::EnemyCalculation()':
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:216:16: error: variable 'SquareGrid grid' has initializer but incomplete type
216 | SquareGrid grid = MakeDiagram();
| ^~~~
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:216:34: error: invalid use of incomplete type 'struct SquareGrid'
216 | SquareGrid grid = MakeDiagram();
| ~~~~~~~~~~~^~
In file included from C:/Users/franc/Desktop/Reisende/AStar.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:9,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/Users/franc/Desktop/Reisende/Map.h:28:8: note: forward declaration of 'struct SquareGrid'
28 | struct SquareGrid;
| ^~~~~~~~~~
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:286:72: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = GridLocation; _Tp = GridLocation; _Hash = std::hash<GridLocation>; _Pred = std::equal_to<GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, GridLocation> >]'
286 | std::unordered_map<GridLocation, GridLocation> came_from;
| ^~~~~~~~~
C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:287:66: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = GridLocation; _Tp = double; _Hash = std::hash<GridLocation>; _Pred = std::equal_to<GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, double> >]'
287 | std::unordered_map<GridLocation, double> cost_so_far;
| ^~~~~~~~~~~
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h: In instantiation of 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::~_Hashtable() [with _Key = GridLocation; _Value = std::pair<const GridLocation, GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, GridLocation> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]':
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/unordered_map.h:102:11: required from here
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:1513:5: error: use of deleted function 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()'
1513 | }
| ^
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h: In instantiation of 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::~_Hashtable() [with _Key = GridLocation; _Value = std::pair<const GridLocation, double>; _Alloc = std::allocator<std::pair<const GridLocation, double> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]':
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/unordered_map.h:102:11: required from here
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:1513:5: error: use of deleted function 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, double>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h: In instantiation of 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable(const std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>&) [with _Key = GridLocation; _Value = std::pair<const GridLocation, GridLocation>; _Alloc = std::allocator<std::pair<const GridLocation, GridLocation> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<GridLocation>; _Hash = std::hash<GridLocation>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]':
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/unordered_map.h:181:7: required from here
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:1400:45: error: use of deleted function 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::_Hashtable_base(const std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >&)'
1400 | _M_rehash_policy(__ht._M_rehash_policy)
| ^
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:35,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1559:12: note: 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::_Hashtable_base(const std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >&)' is implicitly deleted because the default definition would be ill-formed:
1559 | struct _Hashtable_base
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1559:12: error: use of deleted function 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::_Hash_code_base(const std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>&)'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1187:12: note: 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::_Hash_code_base(const std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>&)' is implicitly deleted because the default definition would be ill-formed:
1187 | struct _Hash_code_base
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1187:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>::_Hashtable_ebo_helper(const std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>&)'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1123:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>::_Hashtable_ebo_helper(const std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>&)' is implicitly deleted because the default definition would be ill-formed:
1123 | struct _Hashtable_ebo_helper<_Nm, _Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1123:12: error: use of deleted function 'std::hash<GridLocation>::hash(const std::hash<GridLocation>&)'
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/basic_string.h:6859,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/string:55,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/locale_classes.h:40,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/ios_base.h:41,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/ios:42,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/ostream:38,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/iostream:39,
from C:/Users/franc/Desktop/Reisende/Librerie.h:1,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:102:12: note: 'std::hash<GridLocation>::hash(const std::hash<GridLocation>&)' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:102:12: error: use of deleted function 'constexpr std::__hash_enum<GridLocation, false>::__hash_enum(const std::__hash_enum<GridLocation, false>&)'
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:79:12: note: 'constexpr std::__hash_enum<GridLocation, false>::__hash_enum(const std::__hash_enum<GridLocation, false>&)' is implicitly declared as deleted because 'std::__hash_enum<GridLocation, false>' declares a move constructor or move assignment operator
79 | struct __hash_enum
| ^~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = GridLocation; bool <anonymous> = false]' is private within this context
102 | struct hash : __hash_enum<_Tp>
| ^~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:35,
from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1123:12: error: use of deleted function 'std::hash<GridLocation>::~hash()'
1123 | struct _Hashtable_ebo_helper<_Nm, _Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1187:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<GridLocation>, true>::~_Hashtable_ebo_helper()'
1187 | struct _Hash_code_base
| ^~~~~~~~~~~~~~~
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable_policy.h:1559:12: error: use of deleted function 'std::__detail::_Hash_code_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
1559 | struct _Hashtable_base
| ^~~~~~~~~~~~~~~
In file included from C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/unordered_map:46,
from C:/Users/franc/Desktop/Reisende/Librerie.h:6,
from C:/Users/franc/Desktop/Reisende/Token.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.h:8,
from C:/Users/franc/Desktop/Reisende/TurnSystem.cpp:5:
C:/PROGRA~1/JETBRA~1/CLION2~1.3/bin/mingw/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/bits/hashtable.h:1400:45: error: use of deleted function 'std::__detail::_Hashtable_base<GridLocation, std::pair<const GridLocation, GridLocation>, std::__detail::_Select1st, std::equal_to<GridLocation>, std::hash<GridLocation>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable_base()'
1400 | _M_rehash_policy(__ht._M_rehash_policy)
| ^
[2/8] Building CXX object CMakeFiles/Reisende.dir/main.cpp.obj
[3/8] Building CXX object CMakeFiles/Reisende.dir/Game.cpp.obj
ninja: build stopped: subcommand failed.
I honestly don't understand what's going on
When I select the error code on CLion, CLion warns me of the error by saying: Variable has incomplete type 'SquareGrid'
1658505997237.png
I hope I was clearer, thanks anyway in advance
 
I honestly don't understand what's going on
When I select the error code on CLion, CLion warns me of the error by saying: Variable has incomplete type 'SquareGrid'
I don't know what would cause this. I've looked over the Map.* files to see if there is an error there and from my knowledge of C(not C++) it looks to have been declared and initialised correctly, so I don't see what the error could be there. It isn't exactly good practice but whenever I had problems with multiple header and .c files, I'd end up resorting to this quick hack that would work but doesn't exactly make for good code:
  • Import header in file1.c.
  • Import file1.c(not file1.h) into file2.c.
From my memory, this typically resolved some of the common and extremely annoying errors I faced with headers, but as I said, it isn't good practice and I highly recommend against doing it. I say it isn't good because I have yet to see an open-source project with serious programming going on to import the .c with the .h inside, rather than just directly including the .h.

Can I just check as well that you're importing the Map.h into TurnSystem.cpp and not Map.c?

Side-note: If you've done well and did not follow the quick hack that I done(again, please avoid from doing it if you want an easier life because it will most likely give you headaches later on), I found through a quick search this post on a C++ programming forum[/URL]. To save you clicking the link, two users responded to the OP's question with the following:
You need to give your 'sales' struct a body.
(code example)
To which another responded:
He did. In SalesNmSpce.cpp.

That's the problem. You need to do it within your header. In main.cpp the compiler doesn't know what SALES::sales is (it's only a forward declaration).

All the functions in SalesNmSpce.h act like member functions of sales. So why don't you turn in into a class with OOP?
My suggestion then, based on the second user's post in that thread, is to initialise your structure's members in the header rather than the C++ file. Try that and let me know how it goes.
 
Last edited:
Short update: talking to some of my classmates, I noticed how the code I got from the internet as a starting point is rather long and complicated. I found another one that should be simpler. Unfortunately, the .h file is also missing from this, I have created a second project on CLion, tomorrow I will try to create the .h file and if it works I replace it with the old one. the new code is:
C++:
// A C++ Program to implement A* Search Algorithm
#include <bits/stdc++.h>
using namespace std;

#define ROW 9
#define COL 10

// Creating a shortcut for int, int pair type
typedef pair<int, int> Pair;

// Creating a shortcut for pair<int, pair<int, int>> type
typedef pair<double, pair<int, int> > pPair;

// A structure to hold the necessary parameters
struct cell {
    // Row and Column index of its parent
    // Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
    int parent_i, parent_j;
    // f = g + h
    double f, g, h;
};

// A Utility Function to check whether given cell (row, col)
// is a valid cell or not.
bool isValid(int row, int col)
{
    // Returns true if row number and column number
    // is in range
    return (row >= 0) && (row < ROW) && (col >= 0)
           && (col < COL);
}

// A Utility Function to check whether the given cell is
// blocked or not
bool isUnBlocked(int grid[][COL], int row, int col)
{
    // Returns true if the cell is not blocked else false
    if (grid[row][col] == 1)
        return (true);
    else
        return (false);
}

// A Utility Function to check whether destination cell has
// been reached or not
bool isDestination(int row, int col, Pair dest)
{
    if (row == dest.first && col == dest.second)
        return (true);
    else
        return (false);
}

// A Utility Function to calculate the 'h' heuristics.
double calculateHValue(int row, int col, Pair dest)
{
    // Return using the distance formula
    return ((double)sqrt(
            (row - dest.first) * (row - dest.first)
            + (col - dest.second) * (col - dest.second)));
}

// A Utility Function to trace the path from the source
// to destination
void tracePath(cell cellDetails[][COL], Pair dest)
{
    printf("\nThe Path is ");
    int row = dest.first;
    int col = dest.second;

    stack<Pair> Path;

    while (!(cellDetails[row][col].parent_i == row
             && cellDetails[row][col].parent_j == col)) {
        Path.push(make_pair(row, col));
        int temp_row = cellDetails[row][col].parent_i;
        int temp_col = cellDetails[row][col].parent_j;
        row = temp_row;
        col = temp_col;
    }

    Path.push(make_pair(row, col));
    while (!Path.empty()) {
        pair<int, int> p = Path.top();
        Path.pop();
        printf("-> (%d,%d) ", p.first, p.second);
    }

    return;
}

// A Function to find the shortest path between
// a given source cell to a destination cell according
// to A* Search Algorithm
void aStarSearch(int grid[][COL], Pair src, Pair dest)
{
    // If the source is out of range
    if (isValid(src.first, src.second) == false) {
        printf("Source is invalid\n");
        return;
    }

    // If the destination is out of range
    if (isValid(dest.first, dest.second) == false) {
        printf("Destination is invalid\n");
        return;
    }

    // Either the source or the destination is blocked
    if (isUnBlocked(grid, src.first, src.second) == false
        || isUnBlocked(grid, dest.first, dest.second)
           == false) {
        printf("Source or the destination is blocked\n");
        return;
    }

    // If the destination cell is the same as source cell
    if (isDestination(src.first, src.second, dest)
        == true) {
        printf("We are already at the destination\n");
        return;
    }

    // Create a closed list and initialise it to false which
    // means that no cell has been included yet This closed
    // list is implemented as a boolean 2D array
    bool closedList[ROW][COL];
    memset(closedList, false, sizeof(closedList));

    // Declare a 2D array of structure to hold the details
    // of that cell
    cell cellDetails[ROW][COL];

    int i, j;

    for (i = 0; i < ROW; i++) {
        for (j = 0; j < COL; j++) {
            cellDetails[i][j].f = FLT_MAX;
            cellDetails[i][j].g = FLT_MAX;
            cellDetails[i][j].h = FLT_MAX;
            cellDetails[i][j].parent_i = -1;
            cellDetails[i][j].parent_j = -1;
        }
    }

    // Initialising the parameters of the starting node
    i = src.first, j = src.second;
    cellDetails[i][j].f = 0.0;
    cellDetails[i][j].g = 0.0;
    cellDetails[i][j].h = 0.0;
    cellDetails[i][j].parent_i = i;
    cellDetails[i][j].parent_j = j;

    /*
    Create an open list having information as-
    <f, <i, j>>
    where f = g + h,
    and i, j are the row and column index of that cell
    Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
    This open list is implemented as a set of pair of
    pair.*/
    set<pPair> openList;

    // Put the starting cell on the open list and set its
    // 'f' as 0
    openList.insert(make_pair(0.0, make_pair(i, j)));

    // We set this boolean value as false as initially
    // the destination is not reached.
    bool foundDest = false;

    while (!openList.empty()) {
        pPair p = *openList.begin();

        // Remove this vertex from the open list
        openList.erase(openList.begin());

        // Add this vertex to the closed list
        i = p.second.first;
        j = p.second.second;
        closedList[i][j] = true;

        /*
        Generating all the 8 successor of this cell

          N.W N N.E
            \ | /
             \|/
        W----Cell----E
             /|\
            / | \
          S.W S S.E

        Cell-->Popped Cell (i, j)
        N --> North     (i-1, j)
        S --> South     (i+1, j)
        E --> East     (i, j+1)
        W --> West     (i, j-1)*/

        // To store the 'g', 'h' and 'f' of the 8 successors
        double gNew, hNew, fNew;

        //----------- 1st Successor (North) ------------

        // Only process this cell if this is a valid one
        if (isValid(i - 1, j) == true) {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i - 1, j, dest) == true) {
                // Set the Parent of the destination cell
                cellDetails[i - 1][j].parent_i = i;
                cellDetails[i - 1][j].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }
                // If the successor is already on the closed
                // list or if it is blocked, then ignore it.
                // Else do the following
            else if (closedList[i - 1][j] == false
                     && isUnBlocked(grid, i - 1, j)
                        == true) {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i - 1, j, dest);
                fNew = gNew + hNew;

                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //             OR
                // If it is on the open list already, check
                // to see if this path to that square is
                // better, using 'f' cost as the measure.
                if (cellDetails[i - 1][j].f == FLT_MAX
                    || cellDetails[i - 1][j].f > fNew) {
                    openList.insert(make_pair(
                            fNew, make_pair(i - 1, j)));

                    // Update the details of this cell
                    cellDetails[i - 1][j].f = fNew;
                    cellDetails[i - 1][j].g = gNew;
                    cellDetails[i - 1][j].h = hNew;
                    cellDetails[i - 1][j].parent_i = i;
                    cellDetails[i - 1][j].parent_j = j;
                }
            }
        }

        //----------- 2nd Successor (South) ------------

        // Only process this cell if this is a valid one
        if (isValid(i + 1, j) == true) {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i + 1, j, dest) == true) {
                // Set the Parent of the destination cell
                cellDetails[i + 1][j].parent_i = i;
                cellDetails[i + 1][j].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }
                // If the successor is already on the closed
                // list or if it is blocked, then ignore it.
                // Else do the following
            else if (closedList[i + 1][j] == false
                     && isUnBlocked(grid, i + 1, j)
                        == true) {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i + 1, j, dest);
                fNew = gNew + hNew;

                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //             OR
                // If it is on the open list already, check
                // to see if this path to that square is
                // better, using 'f' cost as the measure.
                if (cellDetails[i + 1][j].f == FLT_MAX
                    || cellDetails[i + 1][j].f > fNew) {
                    openList.insert(make_pair(
                            fNew, make_pair(i + 1, j)));
                    // Update the details of this cell
                    cellDetails[i + 1][j].f = fNew;
                    cellDetails[i + 1][j].g = gNew;
                    cellDetails[i + 1][j].h = hNew;
                    cellDetails[i + 1][j].parent_i = i;
                    cellDetails[i + 1][j].parent_j = j;
                }
            }
        }

        //----------- 3rd Successor (East) ------------

        // Only process this cell if this is a valid one
        if (isValid(i, j + 1) == true) {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i, j + 1, dest) == true) {
                // Set the Parent of the destination cell
                cellDetails[i][j + 1].parent_i = i;
                cellDetails[i][j + 1].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }

                // If the successor is already on the closed
                // list or if it is blocked, then ignore it.
                // Else do the following
            else if (closedList[i][j + 1] == false
                     && isUnBlocked(grid, i, j + 1)
                        == true) {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i, j + 1, dest);
                fNew = gNew + hNew;

                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //             OR
                // If it is on the open list already, check
                // to see if this path to that square is
                // better, using 'f' cost as the measure.
                if (cellDetails[i][j + 1].f == FLT_MAX
                    || cellDetails[i][j + 1].f > fNew) {
                    openList.insert(make_pair(
                            fNew, make_pair(i, j + 1)));

                    // Update the details of this cell
                    cellDetails[i][j + 1].f = fNew;
                    cellDetails[i][j + 1].g = gNew;
                    cellDetails[i][j + 1].h = hNew;
                    cellDetails[i][j + 1].parent_i = i;
                    cellDetails[i][j + 1].parent_j = j;
                }
            }
        }

        //----------- 4th Successor (West) ------------

        // Only process this cell if this is a valid one
        if (isValid(i, j - 1) == true) {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i, j - 1, dest) == true) {
                // Set the Parent of the destination cell
                cellDetails[i][j - 1].parent_i = i;
                cellDetails[i][j - 1].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }

                // If the successor is already on the closed
                // list or if it is blocked, then ignore it.
                // Else do the following
            else if (closedList[i][j - 1] == false
                     && isUnBlocked(grid, i, j - 1)
                        == true) {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i, j - 1, dest);
                fNew = gNew + hNew;

                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //             OR
                // If it is on the open list already, check
                // to see if this path to that square is
                // better, using 'f' cost as the measure.
                if (cellDetails[i][j - 1].f == FLT_MAX
                    || cellDetails[i][j - 1].f > fNew) {
                    openList.insert(make_pair(
                            fNew, make_pair(i, j - 1)));

                    // Update the details of this cell
                    cellDetails[i][j - 1].f = fNew;
                    cellDetails[i][j - 1].g = gNew;
                    cellDetails[i][j - 1].h = hNew;
                    cellDetails[i][j - 1].parent_i = i;
                    cellDetails[i][j - 1].parent_j = j;
                }
            }
        }
    }
    // When the destination cell is not found and the open
    // list is empty, then we conclude that we failed to
    // reach the destination cell. This may happen when the
    // there is no way to destination cell (due to
    // blockages)
    if (foundDest == false)
        printf("Failed to find the Destination Cell\n");

    return;
}

// Driver program to test above function
int main()
{
    /* Description of the Grid-
    1--> The cell is not blocked
    0--> The cell is blocked */
    int grid[ROW][COL]
            = { { 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } };

    grid[2][0]=0;

    // Source is the left-most bottom-most corner
    Pair src = make_pair(8, 0);

    // Destination is the left-most top-most corner
    Pair dest = make_pair(0, 0);

    aStarSearch(grid, src, dest);

    return (0);
}

It sounds very long, but the truth for the most part are the author's comments. I try to do so and let you know. Otherwise I will try as you advised me @HadASpook
 
The code works. I also created the header pretty quickly. I'll put the code here in case anyone ever needs it
Code.h
C++:
#ifndef MAIN_CPP_IMPLEMENTATION_H
#define MAIN_CPP_IMPLEMENTATION_H

#include <bits/stdc++.h>

using namespace std;

#define ROW 9
#define COL 10

// Creating a shortcut for int, int pair type
typedef pair<int, int> Pair;

// Creating a shortcut for pair<int, pair<int, int>> type
typedef pair<double, pair<int, int> > pPair;

// A structure to hold the necessary parameters
struct cell {
    // Row and Column index of its parent
    // Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
    int parent_i, parent_j;
    // f = g + h
    double f, g, h;
};

bool isValid(int row, int col);
bool isUnBlocked(int grid[][COL], int row, int col);
bool isDestination(int row, int col, Pair dest);
double calculateHValue(int row, int col, Pair dest);
void tracePath(cell cellDetails[][COL], Pair dest);
void aStarSearch(int grid[][COL], Pair src, Pair dest);

#endif //MAIN_CPP_IMPLEMENTATION_H

Code.cpp
C++:
#include "Code.h"
using namespace std;

// A Utility Function to check whether given cell (row, col)
// is a valid cell or not.
bool isValid(int row, int col)
{
    // Returns true if row number and column number
    // is in range
    return (row >= 0) && (row < ROW) && (col >= 0)
           && (col < COL);
}

// A Utility Function to check whether the given cell is
// blocked or not
bool isUnBlocked(int grid[][COL], int row, int col)
{
    // Returns true if the cell is not blocked else false
    if (grid[row][col] == 1)
        return (true);
    else
        return (false);
}

// A Utility Function to check whether destination cell has
// been reached or not
bool isDestination(int row, int col, Pair dest)
{
    if (row == dest.first && col == dest.second)
        return (true);
    else
        return (false);
}

// A Utility Function to calculate the 'h' heuristics.
double calculateHValue(int row, int col, Pair dest)
{
    // Return using the distance formula
    return ((double)sqrt(
            (row - dest.first) * (row - dest.first)
            + (col - dest.second) * (col - dest.second)));
}

// A Utility Function to trace the path from the source
// to destination
void tracePath(cell cellDetails[][COL], Pair dest)
{
    printf("\nThe Path is ");
    int row = dest.first;
    int col = dest.second;

    stack<Pair> Path;

    while (!(cellDetails[row][col].parent_i == row
             && cellDetails[row][col].parent_j == col)) {
        Path.push(make_pair(row, col));
        int temp_row = cellDetails[row][col].parent_i;
        int temp_col = cellDetails[row][col].parent_j;
        row = temp_row;
        col = temp_col;
    }

    Path.push(make_pair(row, col));
    while (!Path.empty()) {
        pair<int, int> p = Path.top();
        Path.pop();
        printf("-> (%d,%d) ", p.first, p.second);
    }

    return;
}

// A Function to find the shortest path between
// a given source cell to a destination cell according
// to A* Search Algorithm
void aStarSearch(int grid[][COL], Pair src, Pair dest)
{
    // If the source is out of range
    if (isValid(src.first, src.second) == false) {
        printf("Source is invalid\n");
        return;
    }

    // If the destination is out of range
    if (isValid(dest.first, dest.second) == false) {
        printf("Destination is invalid\n");
        return;
    }

    // Either the source or the destination is blocked
    if (isUnBlocked(grid, src.first, src.second) == false
        || isUnBlocked(grid, dest.first, dest.second)
           == false) {
        printf("Source or the destination is blocked\n");
        return;
    }

    // If the destination cell is the same as source cell
    if (isDestination(src.first, src.second, dest)
        == true) {
        printf("We are already at the destination\n");
        return;
    }

    // Create a closed list and initialise it to false which
    // means that no cell has been included yet This closed
    // list is implemented as a boolean 2D array
    bool closedList[ROW][COL];
    memset(closedList, false, sizeof(closedList));

    // Declare a 2D array of structure to hold the details
    // of that cell
    cell cellDetails[ROW][COL];

    int i, j;

    for (i = 0; i < ROW; i++) {
        for (j = 0; j < COL; j++) {
            cellDetails[i][j].f = FLT_MAX;
            cellDetails[i][j].g = FLT_MAX;
            cellDetails[i][j].h = FLT_MAX;
            cellDetails[i][j].parent_i = -1;
            cellDetails[i][j].parent_j = -1;
        }
    }

    // Initialising the parameters of the starting node
    i = src.first, j = src.second;
    cellDetails[i][j].f = 0.0;
    cellDetails[i][j].g = 0.0;
    cellDetails[i][j].h = 0.0;
    cellDetails[i][j].parent_i = i;
    cellDetails[i][j].parent_j = j;

    /*
    Create an open list having information as-
    <f, <i, j>>
    where f = g + h,
    and i, j are the row and column index of that cell
    Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
    This open list is implemented as a set of pair of
    pair.*/
    set<pPair> openList;

    // Put the starting cell on the open list and set its
    // 'f' as 0
    openList.insert(make_pair(0.0, make_pair(i, j)));

    // We set this boolean value as false as initially
    // the destination is not reached.
    bool foundDest = false;

    while (!openList.empty()) {
        pPair p = *openList.begin();

        // Remove this vertex from the open list
        openList.erase(openList.begin());

        // Add this vertex to the closed list
        i = p.second.first;
        j = p.second.second;
        closedList[i][j] = true;

        /*
        Generating all the 8 successor of this cell

          N.W N N.E
            \ | /
             \|/
        W----Cell----E
             /|\
            / | \
          S.W S S.E

        Cell-->Popped Cell (i, j)
        N --> North     (i-1, j)
        S --> South     (i+1, j)
        E --> East     (i, j+1)
        W --> West     (i, j-1)*/

        // To store the 'g', 'h' and 'f' of the 8 successors
        double gNew, hNew, fNew;

        //----------- 1st Successor (North) ------------

        // Only process this cell if this is a valid one
        if (isValid(i - 1, j) == true) {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i - 1, j, dest) == true) {
                // Set the Parent of the destination cell
                cellDetails[i - 1][j].parent_i = i;
                cellDetails[i - 1][j].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }
                // If the successor is already on the closed
                // list or if it is blocked, then ignore it.
                // Else do the following
            else if (closedList[i - 1][j] == false
                     && isUnBlocked(grid, i - 1, j)
                        == true) {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i - 1, j, dest);
                fNew = gNew + hNew;

                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //             OR
                // If it is on the open list already, check
                // to see if this path to that square is
                // better, using 'f' cost as the measure.
                if (cellDetails[i - 1][j].f == FLT_MAX
                    || cellDetails[i - 1][j].f > fNew) {
                    openList.insert(make_pair(
                            fNew, make_pair(i - 1, j)));

                    // Update the details of this cell
                    cellDetails[i - 1][j].f = fNew;
                    cellDetails[i - 1][j].g = gNew;
                    cellDetails[i - 1][j].h = hNew;
                    cellDetails[i - 1][j].parent_i = i;
                    cellDetails[i - 1][j].parent_j = j;
                }
            }
        }

        //----------- 2nd Successor (South) ------------

        // Only process this cell if this is a valid one
        if (isValid(i + 1, j) == true) {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i + 1, j, dest) == true) {
                // Set the Parent of the destination cell
                cellDetails[i + 1][j].parent_i = i;
                cellDetails[i + 1][j].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }
                // If the successor is already on the closed
                // list or if it is blocked, then ignore it.
                // Else do the following
            else if (closedList[i + 1][j] == false
                     && isUnBlocked(grid, i + 1, j)
                        == true) {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i + 1, j, dest);
                fNew = gNew + hNew;

                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //             OR
                // If it is on the open list already, check
                // to see if this path to that square is
                // better, using 'f' cost as the measure.
                if (cellDetails[i + 1][j].f == FLT_MAX
                    || cellDetails[i + 1][j].f > fNew) {
                    openList.insert(make_pair(
                            fNew, make_pair(i + 1, j)));
                    // Update the details of this cell
                    cellDetails[i + 1][j].f = fNew;
                    cellDetails[i + 1][j].g = gNew;
                    cellDetails[i + 1][j].h = hNew;
                    cellDetails[i + 1][j].parent_i = i;
                    cellDetails[i + 1][j].parent_j = j;
                }
            }
        }

        //----------- 3rd Successor (East) ------------

        // Only process this cell if this is a valid one
        if (isValid(i, j + 1) == true) {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i, j + 1, dest) == true) {
                // Set the Parent of the destination cell
                cellDetails[i][j + 1].parent_i = i;
                cellDetails[i][j + 1].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }

                // If the successor is already on the closed
                // list or if it is blocked, then ignore it.
                // Else do the following
            else if (closedList[i][j + 1] == false
                     && isUnBlocked(grid, i, j + 1)
                        == true) {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i, j + 1, dest);
                fNew = gNew + hNew;

                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //             OR
                // If it is on the open list already, check
                // to see if this path to that square is
                // better, using 'f' cost as the measure.
                if (cellDetails[i][j + 1].f == FLT_MAX
                    || cellDetails[i][j + 1].f > fNew) {
                    openList.insert(make_pair(
                            fNew, make_pair(i, j + 1)));

                    // Update the details of this cell
                    cellDetails[i][j + 1].f = fNew;
                    cellDetails[i][j + 1].g = gNew;
                    cellDetails[i][j + 1].h = hNew;
                    cellDetails[i][j + 1].parent_i = i;
                    cellDetails[i][j + 1].parent_j = j;
                }
            }
        }

        //----------- 4th Successor (West) ------------

        // Only process this cell if this is a valid one
        if (isValid(i, j - 1) == true) {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i, j - 1, dest) == true) {
                // Set the Parent of the destination cell
                cellDetails[i][j - 1].parent_i = i;
                cellDetails[i][j - 1].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }

                // If the successor is already on the closed
                // list or if it is blocked, then ignore it.
                // Else do the following
            else if (closedList[i][j - 1] == false
                     && isUnBlocked(grid, i, j - 1)
                        == true) {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i, j - 1, dest);
                fNew = gNew + hNew;

                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //             OR
                // If it is on the open list already, check
                // to see if this path to that square is
                // better, using 'f' cost as the measure.
                if (cellDetails[i][j - 1].f == FLT_MAX
                    || cellDetails[i][j - 1].f > fNew) {
                    openList.insert(make_pair(
                            fNew, make_pair(i, j - 1)));

                    // Update the details of this cell
                    cellDetails[i][j - 1].f = fNew;
                    cellDetails[i][j - 1].g = gNew;
                    cellDetails[i][j - 1].h = hNew;
                    cellDetails[i][j - 1].parent_i = i;
                    cellDetails[i][j - 1].parent_j = j;
                }
            }
        }
    }
    // When the destination cell is not found and the open
    // list is empty, then we conclude that we failed to
    // reach the destination cell. This may happen when the
    // there is no way to destination cell (due to
    // blockages)
    if (foundDest == false)
        printf("Failed to find the Destination Cell\n");

    return;
}

Main.cpp
C++:
#include "Code.h"
// Driver program to test above function
int main()
{
    /* Description of the Grid-
    1--> The cell is not blocked
    0--> The cell is blocked */
    int grid[ROW][COL]
            = { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 },
                { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } };

    grid[2][0]=0;

    // Source is the left-most bottom-most corner
    Pair src = make_pair(8, 0);

    // Destination is the left-most top-most corner
    Pair dest = make_pair(0, 0);

    aStarSearch(grid, src, dest);

    return (0);
}

thanks again for the help
 
Solution
Back
Top Bottom