diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-24 14:44:20 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-24 14:44:20 +0200 |
commit | afc66d3013b7d47c6c22d6a99809bc3e7d1ff0dc (patch) | |
tree | de50baa5d2f87cc8a416cbd321f7c7f430b03613 /Pathfinder.cpp | |
parent | 1e0a52b03fe655d7073ef20703dbb2e7646f74d3 (diff) |
implement breadth-first search pathfinding
Diffstat (limited to 'Pathfinder.cpp')
-rw-r--r-- | Pathfinder.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Pathfinder.cpp b/Pathfinder.cpp new file mode 100644 index 0000000..deb6040 --- /dev/null +++ b/Pathfinder.cpp @@ -0,0 +1,26 @@ +#include <algorithm> + +#include "Pathfinder.h" +#include "Museum.h" + +using namespace std; + +Pathfinder::Pathfinder(Museum & m) : museum(m) { +} + +void Pathfinder::set_visited(const XY & point) { + this->visisted[point.y * this->museum.canvas.data.columns + point.x] = true; +} + +bool Pathfinder::is_visited(const XY & point) { + size_t idx = point.y * this->museum.canvas.data.columns + point.x; + if (idx >= this->visisted.size()) return false; + return this->visisted[idx]; +} + +void Pathfinder::clear() { + CanvasData & canvas = this->museum.canvas.data; + this->visisted.resize(canvas.columns * canvas.rows); + fill(this->visisted.begin(), this->visisted.end(), false); +} + |