Extend pathfinding API with heuristics, multi-root Dijkstra, and FLEE primitives; refs #315
Phase A (Python surface): - New mcrfpy.Heuristic IntEnum: EUCLIDEAN, MANHATTAN, CHEBYSHEV, DIAGONAL, ZERO - Grid.find_path() accepts heuristic= and weight= kwargs (weighted A*) - Grid.get_dijkstra_map() accepts roots= (list of positions or DiscreteMap mask) Phase B (FLEE primitives): - DijkstraMap.invert() returns a new map with inverted distance field - DijkstraMap.descent_step(pos) returns steepest-descent neighbor or None DijkstraMap internally switched from the C++ TCODDijkstra wrapper to the C API (TCOD_dijkstra_*) because multi-root compute and invert/get_descent are not exposed on the wrapper. Single-root Dijkstra cache is preserved for backward compatibility; multi-root and mask paths bypass the cache since cache keys would be ill-defined. New tests: heuristic_enum_test, find_path_heuristic_test, multi_root_dijkstra_test, dijkstra_flee_test. Baseline JSONs for dijkstra_bench and gridview_render_bench refreshed against the new implementation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2086d25581
commit
767d0d4b0f
11 changed files with 860 additions and 98 deletions
|
|
@ -4,82 +4,82 @@
|
|||
"grid": "100x100",
|
||||
"kind": "multi_root",
|
||||
"roots": 1,
|
||||
"mean_ms": 0.7709094556048512
|
||||
"mean_ms": 0.6948539987206459
|
||||
},
|
||||
{
|
||||
"grid": "100x100",
|
||||
"kind": "multi_root",
|
||||
"roots": 2,
|
||||
"mean_ms": 0.7632468361407518
|
||||
"mean_ms": 0.8002225775271654
|
||||
},
|
||||
{
|
||||
"grid": "100x100",
|
||||
"kind": "multi_root",
|
||||
"roots": 5,
|
||||
"mean_ms": 1.200081780552864
|
||||
"mean_ms": 1.1821302119642496
|
||||
},
|
||||
{
|
||||
"grid": "100x100",
|
||||
"kind": "multi_root",
|
||||
"roots": 20,
|
||||
"mean_ms": 2.137616788968444
|
||||
"mean_ms": 2.0206935703754425
|
||||
},
|
||||
{
|
||||
"grid": "100x100",
|
||||
"kind": "mask",
|
||||
"roots": 500,
|
||||
"mean_ms": 30.424197972752154
|
||||
"mean_ms": 24.073211615905166
|
||||
},
|
||||
{
|
||||
"grid": "100x100",
|
||||
"kind": "invert",
|
||||
"mean_ms": 1.0323396185413003
|
||||
"mean_ms": 0.7887090090662241
|
||||
},
|
||||
{
|
||||
"grid": "100x100",
|
||||
"kind": "descent_step_per_call",
|
||||
"mean_us": 0.4075700417160988,
|
||||
"mean_us": 0.3262499812990427,
|
||||
"valid_per_trial": 100
|
||||
},
|
||||
{
|
||||
"grid": "500x500",
|
||||
"kind": "multi_root",
|
||||
"roots": 1,
|
||||
"mean_ms": 26.075413217768073
|
||||
"mean_ms": 20.39959062822163
|
||||
},
|
||||
{
|
||||
"grid": "500x500",
|
||||
"kind": "multi_root",
|
||||
"roots": 2,
|
||||
"mean_ms": 25.83242394030094
|
||||
"mean_ms": 22.81180394347757
|
||||
},
|
||||
{
|
||||
"grid": "500x500",
|
||||
"kind": "multi_root",
|
||||
"roots": 5,
|
||||
"mean_ms": 33.73005616012961
|
||||
"mean_ms": 29.194996040314436
|
||||
},
|
||||
{
|
||||
"grid": "500x500",
|
||||
"kind": "multi_root",
|
||||
"roots": 20,
|
||||
"mean_ms": 78.58918677084148
|
||||
"mean_ms": 67.84450197592378
|
||||
},
|
||||
{
|
||||
"grid": "500x500",
|
||||
"kind": "mask",
|
||||
"roots": 12500,
|
||||
"mean_ms": 18658.679087948985
|
||||
"mean_ms": 19711.241053813137
|
||||
},
|
||||
{
|
||||
"grid": "500x500",
|
||||
"kind": "invert",
|
||||
"mean_ms": 25.918347598053515
|
||||
"mean_ms": 27.875673002563417
|
||||
},
|
||||
{
|
||||
"grid": "500x500",
|
||||
"kind": "descent_step_per_call",
|
||||
"mean_us": 0.3717193566262722,
|
||||
"mean_us": 0.3495373670011759,
|
||||
"valid_per_trial": 2500
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,31 +4,31 @@
|
|||
"views": 1,
|
||||
"frames": 60,
|
||||
"warmup_frames": 5,
|
||||
"total_sec": 4.710599604761228,
|
||||
"mean_frame_ms": 78.50999341268714,
|
||||
"p95_frame_ms": 90.47448402270675,
|
||||
"implied_fps": 12.737231994702995,
|
||||
"per_view_frame_ms": 78.50999341268714
|
||||
"total_sec": 4.731390134897083,
|
||||
"mean_frame_ms": 78.85650224828473,
|
||||
"p95_frame_ms": 86.92639297805727,
|
||||
"implied_fps": 12.681262438593032,
|
||||
"per_view_frame_ms": 78.85650224828473
|
||||
},
|
||||
{
|
||||
"views": 2,
|
||||
"frames": 60,
|
||||
"warmup_frames": 5,
|
||||
"total_sec": 4.6525509969796985,
|
||||
"mean_frame_ms": 77.54251661632831,
|
||||
"p95_frame_ms": 91.92000096663833,
|
||||
"implied_fps": 12.896150958678424,
|
||||
"per_view_frame_ms": 38.77125830816416
|
||||
"total_sec": 4.975782633875497,
|
||||
"mean_frame_ms": 82.92971056459162,
|
||||
"p95_frame_ms": 91.40842803753912,
|
||||
"implied_fps": 12.058404559619538,
|
||||
"per_view_frame_ms": 41.46485528229581
|
||||
},
|
||||
{
|
||||
"views": 4,
|
||||
"frames": 60,
|
||||
"warmup_frames": 5,
|
||||
"total_sec": 4.727940998389386,
|
||||
"mean_frame_ms": 78.7990166398231,
|
||||
"p95_frame_ms": 99.88687501754612,
|
||||
"implied_fps": 12.690513697281654,
|
||||
"per_view_frame_ms": 19.699754159955774
|
||||
"total_sec": 4.861755113233812,
|
||||
"mean_frame_ms": 81.0292518872302,
|
||||
"p95_frame_ms": 90.46144201420248,
|
||||
"implied_fps": 12.341222172354708,
|
||||
"per_view_frame_ms": 20.25731297180755
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue