A SMALL MAP. A BETTER QUESTION.
The shortest route
isn’t always the cheapest.
Draw a maze. Change the terrain. Watch Dijkstra and A* find the same optimal cost — with different search footprints.
Your map, two algorithms.
Runs entirely in your browserReady. Try the weighted detour, or paint a cell.
A*
Cost + estimate · g + hClick or tap a cell to paint. Drag to paint walls or terrain. Use arrow keys to move between cells and Space/Enter to paint. Both panels edit the same map.
Export this map for Python / C
Select and copy the text below. Save it as a plain-text file, then run either CLI solver with that path. This stays up to date when you edit or reset the map.
متن نقشه را کپی و در فایل متنی ذخیره کن؛ همان فایل ورودی نسخهٔ Python و C است. این بخش فقط خروجی میدهد و اطلاعاتی ارسال نمیکند.
Four moves can cost 28.
In the default map, crossing three expensive cells takes four moves. Going around takes eight moves and costs only eight. We minimize entry cost, not the number of moves.
Same map. Same optimal cost.
A* uses Manhattan distance. Every move costs at least one. Both algorithms share the same tie rule: larger cost so far, then smaller cell index. Walls can weaken the heuristic.
Less search ≠ always faster.
Expanded cells count work done by the search. Animation speed is presentation only. This JavaScript demo is separate from the measured Python/C benchmarks in the repository.
فارسی — راهنمای کوتاه
یک نقشه را در هر دو پنل تغییر بده و «Run comparison» را بزن. S شروع و G مقصد است؛ # دیوار است و عدد هر خانه هزینهٔ ورود را نشان میدهد. هدف یافتن کمهزینهترین مسیر است، حتی اگر طولانیتر باشد.
با ابزار Start و Goal ابتدا و انتها را جابهجا کن؛ باید در دو خانهٔ جدا باشند. Pause مکث میکند و Reset نقشهٔ نمونه را برمیگرداند. با تغییر نقشه نتیجهٔ قبلی پاک میشود. تعداد گرههای Expanded معیار جستوجو است، نه بنچمارک سرعت Python و C.
140 cells versus 23.
Follow one map, see the heuristic, then try a case where it helps less. Read the illustrated walkthrough →
Three questions. Your experience.
What confused you, what helped, and what is missing? Choose a feedback form →
Was a second visit useful?
If you used the demo again, tell us why. Actual use matters more than a star. Share return-use feedback →
When should recovery stop?
Recover an incomplete tail, reject complete corruption: a measured Python/C storage experiment. Read the second field note →