微分启发式
Differential Heuristics

原始链接: https://www.redblobgames.com/blog/2026-08-08-differential-heuristics/

受谷歌地图实时路线规划效率的启发,作者花了十多年时间试图揭开“差分启发式算法”(differential heuristics)的神秘面纱——这是一种用于 A* 寻路的优化技术。虽然起初由于理解不够深入而难以撰写教程,但作者最终将重心从教学转向了严谨的实验与学习。 通过转向交互式可视化,作者找到了一种更清晰的方式来解释这些启发式算法如何提高性能:利用箭头来表示方向对齐,并使用图表来映射有效区域。经过十年的反复打磨,作者终于发布了一份关于该主题的综合指南。这一资源虽然仍在不断完善中,但它代表了一个长期项目的圆满成功,标志着作者已掌握并能解释这一复杂的寻路优化技术。

抱歉。
相关文章

原文

In 2005 Google showed off Google Maps, which lets you drag the map around instead of reloading the page like MapQuest and others used. That’s the feature that got everyone’s attention. But what got my attention was a feature they added in 2007 where you could drag the start/end points on a route[1], and it would recalculate the shortest path as you dragged. That means they had fast A* pathfinding[2] on the entire world, which had millions of roads. How did they do it?

I had already studied A* and the common optimizations, but Google Maps was using optimizations I hadn’t learned about. I started reading papers. My reaction to almost all of them was “this complexity isn’t worth it unless your map is very large”. There was one technique however that was relatively simple, and I wanted to explore it further.

A better heuristic reduces how much of the map A* explores

In 2014 I wrote my interactive guide to A* pathfinding. I made a list of additional topics I wanted to cover, including graphs, heuristics, optimizations, data structures, and so on. One of these topics was the optimization I had learned about in 2007: differential heuristics (although it didn’t get that name until later).

I tried writing a tutorial about it in 2015 but I couldn’t find an explanation I liked. I tried again in 2016, 2018, 2019, 2022, 2024. I finally realized that I needed to stop trying to write a tutorial. Although I understood the algorithm, I didn’t understand it well enough to teach it.

I needed to understand it better. So I switched to learning and experimentation mode. I learned a lot. I went through some ups and downs. I learned that there’s still more to learn. Along the way I found an explanation I was happier with, and I rewrote the page again.

  1. I had previously shown the heuristic as lots of numbers. I switched to using two arrows. One is the direction the heuristic suggests and one is the correct direction. When they are in alignment, the heuristic makes A* run faster.

    Arrows showing heuristic mismatches
  2. I added visualizations showing the regions in which the optimization was effective, combined with an interactive diagram where I can move the points around to see how those regions change.

    Visualizing the improved areas

Here’s my new page about Differential Heuristics. I started over ten years ago so there are remnants of old text and code still there. I think there’s still plenty of room for improvement, but this is the first version I’m considering “released”.

联系我们 contact @ memedata.com