Pathing in either diagonal or simple motion works.

This commit is contained in:
Zed A. Shaw 2025-08-31 00:17:47 -04:00
parent e92fd2b6f3
commit fc678c6b42
3 changed files with 34 additions and 20 deletions

View file

@ -8,6 +8,7 @@
#include "game_level.hpp"
#include <chrono>
#include <thread>
#include "rand.hpp"
using namespace fmt;
using namespace nlohmann;
@ -46,25 +47,25 @@ TEST_CASE("multiple targets can path", "[pathing]") {
});
paths.compute_paths(walls_copy);
bool diag = Random::uniform<int>(0, 1);
auto pos = GameDB::player_position().location;
auto found = paths.find_path(pos, PATHING_TOWARD, false);
auto found = paths.find_path(pos, PATHING_TOWARD, diag);
while(found == PathingResult::CONTINUE) {
fmt::println("\033[2J\033[1;1H");
matrix::dump("failed paths", paths.$paths, pos.x, pos.y);
// fmt::println("\033[2J\033[1;1H");
// matrix::dump(diag ? "diag" : "simple", paths.$paths, pos.x, pos.y);
std::this_thread::sleep_for(200ms);
found = paths.find_path(pos, PATHING_TOWARD, false);
found = paths.find_path(pos, PATHING_TOWARD, diag);
}
fmt::println("\033[2J\033[1;1H");
matrix::dump("failed paths", paths.$paths, pos.x, pos.y);
// fmt::println("\033[2J\033[1;1H");
// matrix::dump(diag ? "diag" : "simple", paths.$paths, pos.x, pos.y);
if(found == PathingResult::FOUND) {
fmt::println("FOUND!");
} else if(found == PathingResult::FAIL) {
fmt::println("FAILED!");
std::this_thread::sleep_for(20000ms);
} else if(found == PathingResult::FAIL && !diag) {
REQUIRE(found != PathingResult::FAIL);
}
}