Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/tests/test_HierPathfinder.h
Show All 36 Lines | public: | ||||
const pass_class_t PASS_2 = 2; | const pass_class_t PASS_2 = 2; | ||||
const pass_class_t NON_PASS_1 = 4; | const pass_class_t NON_PASS_1 = 4; | ||||
const u16 mapSize = 240; | const u16 mapSize = 240; | ||||
std::map<std::string, pass_class_t> pathClassMask; | std::map<std::string, pass_class_t> pathClassMask; | ||||
std::map<std::string, pass_class_t> nonPathClassMask; | std::map<std::string, pass_class_t> nonPathClassMask; | ||||
void debug_grid(Grid<NavcellData>& grid) { | void debug_grid(Grid<NavcellData>& grid) { | ||||
Itms: Can you use this patch opportunity to fix the unusual bracket here on function definitions? | |||||
for (size_t i = 0; i < grid.m_W; ++i) | for (size_t i = 0; i < grid.m_W; ++i) | ||||
{ | { | ||||
for (size_t j = 0; j < grid.m_H; ++j) | for (size_t j = 0; j < grid.m_H; ++j) | ||||
printf("%i", grid.get(i,j)); | printf("%i", grid.get(i,j)); | ||||
printf("\n"); | printf("\n"); | ||||
} | } | ||||
} | } | ||||
Show All 33 Lines | void assert_blank(HierarchicalPathfinder& hierPath) | ||||
TS_ASSERT(reachables.size() == 9); | TS_ASSERT(reachables.size() == 9); | ||||
reachables.clear(); | reachables.clear(); | ||||
hierPath.FindReachableRegions(hierPath.Get(20, 20, PASS_1), reachables, PASS_1); | hierPath.FindReachableRegions(hierPath.Get(20, 20, PASS_1), reachables, PASS_1); | ||||
TS_ASSERT(reachables.size() == 9); | TS_ASSERT(reachables.size() == 9); | ||||
} | } | ||||
void test_reachability_and_update() | void test_reachability_and_update() | ||||
{ | { | ||||
pathClassMask = { | pathClassMask = std::map<std::string, pass_class_t>{ | ||||
ItmsUnsubmitted Done Inline ActionsI think using the brackets like this is good for the maps though. Itms: I think using the brackets like this is good for the maps though. | |||||
{ "1", 1 }, | { "1", 1 }, | ||||
{ "2", 2 }, | { "2", 2 }, | ||||
}; | }; | ||||
nonPathClassMask = { | nonPathClassMask = std::map<std::string, pass_class_t>{ | ||||
{ "3", 4 } | { "3", 4 } | ||||
}; | }; | ||||
HierarchicalPathfinder hierPath; | HierarchicalPathfinder hierPath; | ||||
Grid<NavcellData> grid(mapSize, mapSize); | Grid<NavcellData> grid(mapSize, mapSize); | ||||
Grid<u8> dirtyGrid(mapSize, mapSize); | Grid<u8> dirtyGrid(mapSize, mapSize); | ||||
// Entirely passable for PASS_1, not for others; | // Entirely passable for PASS_1, not for others; | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | u16 manhattan(u16 i, u16 j, u16 gi, u16 gj) { | ||||
return abs(i - gi) + abs(j - gj); | return abs(i - gi) + abs(j - gj); | ||||
} | } | ||||
double euclidian(u16 i, u16 j, u16 gi, u16 gj) { | double euclidian(u16 i, u16 j, u16 gi, u16 gj) { | ||||
return sqrt((i - gi)*(i - gi) + (j - gj)*(j - gj)); | return sqrt((i - gi)*(i - gi) + (j - gj)*(j - gj)); | ||||
} | } | ||||
void test_passability() | void test_passability() | ||||
{ | { | ||||
pathClassMask = { | pathClassMask = std::map<std::string, pass_class_t>{ | ||||
{ "1", 1 }, | { "1", 1 }, | ||||
{ "2", 2 }, | { "2", 2 }, | ||||
}; | }; | ||||
nonPathClassMask = { | nonPathClassMask = std::map<std::string, pass_class_t>{ | ||||
{ "3", 4 } | { "3", 4 } | ||||
}; | }; | ||||
// 0 is passable, 1 is not. | // 0 is passable, 1 is not. | ||||
// i is vertical, j is horizontal; | // i is vertical, j is horizontal; | ||||
#define _ 0 | #define _ 0 | ||||
#define X 1 | #define X 1 | ||||
NavcellData gridDef[40][40] = { | NavcellData gridDef[40][40] = { | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Can you use this patch opportunity to fix the unusual bracket here on function definitions? There is a few of them.