From 47fee51b085a7cb8ae3f06ee313f874c3da5005d Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Sat, 22 Aug 2015 06:55:28 -0700 Subject: [PATCH] small commit --- aStar/Explorer.cpp | 1 + aStar/Pather.cpp | 14 +++++++------- aStar/Pather.h | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/aStar/Explorer.cpp b/aStar/Explorer.cpp index d26cd51..f6c2028 100644 --- a/aStar/Explorer.cpp +++ b/aStar/Explorer.cpp @@ -75,5 +75,6 @@ bool Explorer::move() { // A* bool Explorer::plan(sf::Vector2i destination_) { + return true; } diff --git a/aStar/Pather.cpp b/aStar/Pather.cpp index dab7527..a2e09e0 100644 --- a/aStar/Pather.cpp +++ b/aStar/Pather.cpp @@ -107,7 +107,7 @@ sf::Vector2i Pather::getEndNodePosition() { return end_node->xy; } -std::vector Pather::pathTo(sf::Vector2i start, sf::Vector2i end) { +std::deque Pather::pathTo(sf::Vector2i start, sf::Vector2i end) { // Clear the visited map for erroneous data for (int i = 0; i < Map::CELLS_WIDTH; i++) { @@ -129,13 +129,13 @@ std::vector Pather::pathTo(sf::Vector2i start, sf::Vector2i end) { openList.emplace(start_node, 0); early_exit = false; - //path_list = Loop(); + path_list = loop(); return path_list; } -std::vector Pather::loop() { +std::deque Pather::loop() { while (!openList.empty() && !early_exit) { // Early exit jankyness, need to change this if (closedList.size() > 3000) { @@ -172,17 +172,17 @@ std::vector Pather::loop() { } } - std::vector return_path = returnPath(); + std::deque return_path = returnPath(); if (no_path || return_path.empty()) { - return std::vector(0, 0); + return std::deque(); std::cout << " no return path " << std::endl; } return return_path; } -std::vector Pather::returnPath() { - std::vector path; +std::deque Pather::returnPath() { + std::deque path; while (active_node != nullptr) { path.push_back(active_node->cameFrom); diff --git a/aStar/Pather.h b/aStar/Pather.h index 37913dc..ab2a681 100644 --- a/aStar/Pather.h +++ b/aStar/Pather.h @@ -37,9 +37,9 @@ public: std::unordered_map closedList; int visitedMap[App::WINDOW_HEIGHT][App::WINDOW_WIDTH]; - std::vector pathTo(sf::Vector2i start, sf::Vector2i end); - std::vector loop(); - std::vector returnPath(); + std::deque pathTo(sf::Vector2i start, sf::Vector2i end); + std::deque loop(); + std::deque returnPath(); sf::Vector2i getEndNodePosition(); @@ -51,7 +51,7 @@ public: private: - std::vector path_list; + std::deque path_list; node* end_node; };