瘟38说的我怎么看不懂,难道有比A*还要高效的算法?
如果你的A*效率低,有太多的回溯,就是你估值函数没有设计好。
A General Graph-Searching Algorithm
1. Create search tree Tr consisting only of the start node (root) n0. Put n0 on an ordered list called OPEN.
2. Create empty list called CLOSED.
3. If OPEN is empty, exit with failure.
4. Move the first node from OPEN, called n, to CLOSED.
5. If n is a goal node, exit with success; the solution is the path from n to n0 along the edges in Tr.
6. Expand node n by generating a set M of successors and connect them to n. Also put the members of M on OPEN.
7. Reorder the list OPEN according to a specific rule.
8. Go to step 3.
这是通用搜索模式,在第七步中:
1 如果把新open的节点放在open表前面就是DFS
2 如果把新open的节点放在open表后面就是BFS
3 如果把新open的节点按其h(n)+g(n)值大小按递增序插入open表就是best-first search,也叫A*。
8数码问题的A*算法应该这样设置估值函数:
f’(n) = depth of n in the tree + number of digits in the puzzle in incorrect position.