summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/path-search-dijkstra.cpp11
-rw-r--r--src/path-search-result.hpp2
-rw-r--r--src/path-search.hpp14
-rw-r--r--test/dijkstra.cpp3
-rw-r--r--test/path-search.cpp6
5 files changed, 20 insertions, 16 deletions
diff --git a/src/path-search-dijkstra.cpp b/src/path-search-dijkstra.cpp
index bb29e402..5e7b7e79 100644
--- a/src/path-search-dijkstra.cpp
+++ b/src/path-search-dijkstra.cpp
@@ -73,6 +73,13 @@ constexpr bbox<T> bbox_from_pos(Math::Vector<2, T> pos, Vector2b offset, Vector2
return bb;
}
+bool add_start_node(std::vector<astar::visited>& nodes,
+ tsl::robin_map<point, uint32_t, astar::point_hash>& indexes,
+ std::vector<uint32_t>& Q)
+{
+
+}
+
} // namespace
bool astar::edge::operator==(const floormat::astar::edge& other) const = default;
@@ -148,10 +155,6 @@ path_search_result astar::Dijkstra(world& w, Vector2ub own_size, const object_id
Q.push_back(idx++);
std::push_heap(Q.begin(), Q.end(), heap_comparator);
}
- else
- {
-
- }
}
diff --git a/src/path-search-result.hpp b/src/path-search-result.hpp
index c7dde85e..90a4ba3d 100644
--- a/src/path-search-result.hpp
+++ b/src/path-search-result.hpp
@@ -9,7 +9,7 @@ namespace floormat {
struct path_search_result final
{
friend class path_search;
- friend class astar;
+ friend struct astar;
friend struct test_app;
struct pair { global_coords pos; Vector2 offset; };
diff --git a/src/path-search.hpp b/src/path-search.hpp
index a78d67c3..1ad1120d 100644
--- a/src/path-search.hpp
+++ b/src/path-search.hpp
@@ -54,7 +54,7 @@ public:
static bool is_passable(world& w, chunk_coords_ ch0, const bbox<float>& bb, object_id own_id, const pred& p = never_continue());
};
-class astar
+struct astar
{
struct visited
{
@@ -96,15 +96,9 @@ class astar
struct point_hash { size_t operator()(point pt) const; };
struct edge_hash { size_t operator()(const edge& e) const; };
- std::vector<visited> nodes;
- tsl::robin_map<edge, edge_status, edge_hash> edges;
- tsl::robin_map<point, uint32_t, point_hash> indexes;
- std::vector<uint32_t> Q;
-
using pred = path_search::pred;
template<typename T> using bbox = path_search::bbox<T>;
-public:
fm_DECLARE_DELETED_COPY_ASSIGNMENT(astar);
static edge make_edge(const point& a, const point& b)
@@ -151,6 +145,12 @@ public:
static constexpr auto div_factor = path_search::div_factor;
static constexpr auto initial_capacity = TILE_COUNT * 16 * div_factor*div_factor;
+
+private:
+ std::vector<visited> nodes;
+ tsl::robin_map<edge, edge_status, edge_hash> edges;
+ tsl::robin_map<point, uint32_t, point_hash> indexes;
+ std::vector<uint32_t> Q;
};
} // namespace floormat
diff --git a/test/dijkstra.cpp b/test/dijkstra.cpp
index 817f944a..afd2a85a 100644
--- a/test/dijkstra.cpp
+++ b/test/dijkstra.cpp
@@ -13,8 +13,9 @@ void bench_run(StringView name, F&& fun)
{
using namespace std::chrono;
using clock = high_resolution_clock;
+ for (int i = 0; i < 20; i++)
+ fun();
const auto t0 = clock::now();
- fun();
for (int i = 0; i < 1000; i++)
fun();
const auto tm = clock::now() - t0;
diff --git a/test/path-search.cpp b/test/path-search.cpp
index 20645c63..7e594b2d 100644
--- a/test/path-search.cpp
+++ b/test/path-search.cpp
@@ -13,7 +13,7 @@ namespace {
template<typename T> using bbox = path_search::bbox<T>;
using pred = path_search::pred;
-constexpr auto div = path_search::div_factor;
+constexpr auto div_factor = path_search::div_factor;
constexpr auto min_size = path_search::min_size;
constexpr bbox<int> get_value(Vector2ub sz, Vector2ub div, rotation r)
@@ -90,7 +90,7 @@ constexpr bool test_offsets2()
constexpr auto sz = Vector2ub(8, 16);
{
- constexpr auto bb = get_value(sz, Vector2ub(div), N);
+ constexpr auto bb = get_value(sz, Vector2ub(div_factor), N);
constexpr auto min = tile_start + bb.min, max = tile_start + bb.max;
static_assert(min.x() == -32 - sz.x()/2);
static_assert(max.x() == -32 + sz.x()/2);
@@ -98,7 +98,7 @@ constexpr bool test_offsets2()
static_assert(max.y() == -32 + sz.y()/2);
}
{
- constexpr auto bb = get_value(sz, Vector2ub(div), W);
+ constexpr auto bb = get_value(sz, Vector2ub(div_factor), W);
constexpr auto min = tile_start + bb.min, max = tile_start + bb.max;
static_assert(min.x() == -32 - 16 - sz.x()/2);
static_assert(max.x() == -32 + sz.x()/2);