/*____________________________________________________________________________
pathfinding
par Martin Robinson
virtual class that solve pathfinding
for two project
Introduction réseau , tp3 finding route accross network
Structure de donnée, tp3 find path through a labyrinth
______________________________________________________________________________
preprocesseur
____________________________________________________________________________*/
#pragma once
#ifndef _PATH
#define _PATH

#include <stack>
#include <vector>
using namespace std;

#define DEBUG
#include "debug.h"

/*____________________________________________________________________________
struct
____________________________________________________________________________*/

struct node{
    int index,                                  //were we are
        parent,                                 //were we come from
        cost,                                   //cost till there
        dist;                                   //distance estimated
};

/*____________________________________________________________________________
class
____________________________________________________________________________*/

class pathfind{

    vector<node> _open;                         //open list, all possible path
    vector<node> _closed;                       //closed list, best possible path
    bool _found;
    int findInOpen(int, int);                   //find in open list
    int findBestRoute(int);                     //find best in open list
    bool addToOpen(node & nu);                  //try to add a node to open list
    void recursif(int, int, int);               //the pathfinding algo
protected:
    virtual stack<node> * getAllNeighbor(int); //all direction from a given point
    void init();                                //initialise les variables
public:
    pathfind();                                 //constructor
    const node & at(int i)const;                //get path at ith step
    int size()const;                            //get count of step
    bool found()const;                          //if path found
    void fromTo(int, int);                      //call path finding
};

/*____________________________________________________________________________
end
____________________________________________________________________________*/
#endif
