small commit
This commit is contained in:
@@ -75,5 +75,6 @@ bool Explorer::move() {
|
|||||||
// A*
|
// A*
|
||||||
bool Explorer::plan(sf::Vector2i destination_) {
|
bool Explorer::plan(sf::Vector2i destination_) {
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ sf::Vector2i Pather::getEndNodePosition() {
|
|||||||
return end_node->xy;
|
return end_node->xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> Pather::pathTo(sf::Vector2i start, sf::Vector2i end) {
|
std::deque<int> Pather::pathTo(sf::Vector2i start, sf::Vector2i end) {
|
||||||
|
|
||||||
// Clear the visited map for erroneous data
|
// Clear the visited map for erroneous data
|
||||||
for (int i = 0; i < Map::CELLS_WIDTH; i++) {
|
for (int i = 0; i < Map::CELLS_WIDTH; i++) {
|
||||||
@@ -129,13 +129,13 @@ std::vector<int> Pather::pathTo(sf::Vector2i start, sf::Vector2i end) {
|
|||||||
openList.emplace(start_node, 0);
|
openList.emplace(start_node, 0);
|
||||||
|
|
||||||
early_exit = false;
|
early_exit = false;
|
||||||
//path_list = Loop();
|
path_list = loop();
|
||||||
|
|
||||||
return path_list;
|
return path_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> Pather::loop() {
|
std::deque<int> Pather::loop() {
|
||||||
while (!openList.empty() && !early_exit) {
|
while (!openList.empty() && !early_exit) {
|
||||||
// Early exit jankyness, need to change this
|
// Early exit jankyness, need to change this
|
||||||
if (closedList.size() > 3000) {
|
if (closedList.size() > 3000) {
|
||||||
@@ -172,17 +172,17 @@ std::vector<int> Pather::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> return_path = returnPath();
|
std::deque<int> return_path = returnPath();
|
||||||
if (no_path || return_path.empty()) {
|
if (no_path || return_path.empty()) {
|
||||||
return std::vector<int>(0, 0);
|
return std::deque<int>();
|
||||||
std::cout << " no return path " << std::endl;
|
std::cout << " no return path " << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return return_path;
|
return return_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> Pather::returnPath() {
|
std::deque<int> Pather::returnPath() {
|
||||||
std::vector<int> path;
|
std::deque<int> path;
|
||||||
|
|
||||||
while (active_node != nullptr) {
|
while (active_node != nullptr) {
|
||||||
path.push_back(active_node->cameFrom);
|
path.push_back(active_node->cameFrom);
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ public:
|
|||||||
std::unordered_map<node*, int> closedList;
|
std::unordered_map<node*, int> closedList;
|
||||||
int visitedMap[App::WINDOW_HEIGHT][App::WINDOW_WIDTH];
|
int visitedMap[App::WINDOW_HEIGHT][App::WINDOW_WIDTH];
|
||||||
|
|
||||||
std::vector<int> pathTo(sf::Vector2i start, sf::Vector2i end);
|
std::deque<int> pathTo(sf::Vector2i start, sf::Vector2i end);
|
||||||
std::vector<int> loop();
|
std::deque<int> loop();
|
||||||
std::vector<int> returnPath();
|
std::deque<int> returnPath();
|
||||||
|
|
||||||
sf::Vector2i getEndNodePosition();
|
sf::Vector2i getEndNodePosition();
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<int> path_list;
|
std::deque<int> path_list;
|
||||||
node* end_node;
|
node* end_node;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user