我开始刷新我的知识,所以我实现了一些路径查找算法来解决8-Puzzle.
我想知道为什么我的IDA*实现有更长的路径.它应该像A*一样最佳.
% python puzzle8.py -a idastar -d hard
IDASTAR - RESULT in 161.6099:
1 | 2 | 3
4 | 5 | 6
7 | 8 | N
cost: 0 total_cost: 121
...
nodes 28
% python puzzle8.py -a astar -d hard
Max nodes 665 loops 1085
ASTAR - RESULT in 0.3148:
1 | 2 | 3
4 | 5 | 6
7 | 8 | N
cost: 0 total_cost: 115
...
nodes 24
Run Code Online (Sandbox Code Playgroud)
代码在gist …