Prettied it up, comments, refactors

This commit is contained in:
2015-08-22 17:43:38 -07:00
parent 8fc8db2d78
commit ee6ea3442d
12 changed files with 258 additions and 237 deletions

View File

@@ -2,58 +2,54 @@
#include <map>
#include "App.h"
#include <unordered_map>
class Pather;
class node {
public:
node(sf::Vector2i XY, double h, int cF, int cL, node* p, Pather* pather_);
node();
~node();
sf::Vector2i xy;
// Ugh, pointers, ugh c++
node* parent;
double hueristic;
int cameFrom;
int closedList;
Pather* pather;
void neighbors();
private:
};
#include "node.h"
class Pather {
public:
// Constructor
Pather(Map* map_);
~Pather();
// Reference to the map data
Map* map;
std::unordered_map<node*, double> openList;
std::unordered_map<node*, double> closedList;
// Containers for the loop, probably inefficient as hell
std::unordered_map<node*, double> open_list;
std::unordered_map<node*, double> closed_list;
MultiArray<int, Map::CELLS_WIDTH , Map::CELLS_HEIGHT> visitedMap;
//int visitedMap[App::WINDOW_HEIGHT][App::WINDOW_WIDTH];
// A stack allocated 2d array from a template I stole from stackOverflow
MultiArray<int, Map::CELLS_WIDTH , Map::CELLS_HEIGHT> visited_map;
std::deque<int> pathTo(sf::Vector2i start, sf::Vector2i end);
std::deque<int> loop();
std::deque<int> returnPath();
// Return a deque with the movement info to path to the end position from the start position
std::deque<int> getPathTo(sf::Vector2i start, sf::Vector2i end);
// Returns the end node of the current path
sf::Vector2i getEndNodePosition();
node* start_node;
node* active_node;
bool no_path = false;
bool early_exit;
// Returns the current active node
node* getActiveNode();
private:
// Whether we couldn't find a path
bool no_path = false;
// If we found the path and can exit early
bool early_exit;
// Calculate the return path from back tracing the active nodes
std::deque<int> returnPath();
// The main iterative loop for a*
std::deque<int> loop();
// Movement list for the Explorer
std::deque<int> path_list;
// Start positions node
node* start_node;
// Current positions node
node* active_node;
// End positions node
node* end_node;
};