perf(autohunt): avoid discarded A-star searches for attack sight lines
This commit is contained in:
@@ -42,5 +42,18 @@ int main() {
|
||||
assert(Distance(prev,{1000,0})<=450);
|
||||
auto around=FindPath({0,0},{1000,0},450,[&](Point p) { return lake(p) && wall(p); },3500,350);
|
||||
assert(around.size()>1 && Distance(around.back(),{1000,0})<=450);
|
||||
// A blocked combat sight line must not explore the room looking for a
|
||||
// detour that the caller immediately rejects. Simulate 240 crowded targets.
|
||||
int normalQueries=0, sightQueries=0;
|
||||
for (int i=0;i<240;++i) {
|
||||
auto full=FindPath({0,0},{1000,float(i%5)},0,[&](Point p){++normalQueries;return wall(p);});
|
||||
auto sight=FindPath({0,0},{1000,float(i%5)},0,[&](Point p){++sightQueries;return wall(p);},3500,0,true);
|
||||
assert((full.size()==1)==(sight.size()==1));
|
||||
}
|
||||
assert(sightQueries*10<normalQueries);
|
||||
assert(FindPath({0,0},{1000,0},0,free,3500,0,true).size()==1);
|
||||
assert(FindPath({0,0},{100,0},150,thin,3500,0,true).empty());
|
||||
assert(FindPath({0,0},{1000,0},450,lake,3500,350,true).size()==1);
|
||||
std::printf("crowd sight probes: %d -> %d (same direct-line decisions)\n",normalQueries,sightQueries);
|
||||
std::puts("autohunt navigation: direct, detour, sealed, thin wall, corners, budget, unloaded, coordinates and large targets passed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user