简体   繁体   English

15拼图启发式

[英]15 Puzzle Heuristic

The 15 Puzzle is a classical problem for modelling algorithms involving heuristics. 15 Puzzle是涉及启发式的建模算法的经典问题。 Commonly used heuristics for this problem include counting the number of misplaced tiles and finding the sum of the Manhattan distances between each block and its position in the goal configuration. 针对此问题的常用启发式方法包括计算错放的磁贴的数量,并找出每个块与其在目标配置中的位置之间的曼哈顿距离的总和。 Note that both are admissible, ie, they never overestimate the number of moves left, which ensures optimality for certain search algorithms such as A*. 请注意,两者都是可接受的,即它们永远不会高估剩余的移动次数,这可确保某些搜索算法(如A *)的最佳性。

  • What Heuristic do you think is proper, A* seems to work nice, do you have an example, maybe in c or java ? 您觉得哪种Heuristic是正确的, A*似乎很好用,你有一个例子,可能是cjava吗?

Heuristic 启发式

My heuristic of choice is to find if the sum of all inversions in a permutation is odd or even - if it is even, then the 15Puzzle is solvable. 我的选择启发式是找出排列中所有倒置的总和是奇数还是偶数 - 如果是偶数,那么15Puzzle是可解的。

The number of inversions in a permutation is equal to that of its inverse permutation (Skiena 1990, p. 29; Knuth 1998). 置换中的倒置数等于其逆置换的倒数(Skiena 1990,p.29; Knuth 1998)。

Only if I know it can be solved does it make sense to solve it. 只有我知道它可以解决才有意义解决它。 The task then is to reduce inverses and - viola problem solved. 那么任务就是减少逆,并解决中提问题。 To find a solution should be no more then 80 moves. 要找到解决方案,应该不超过80步。

Even more help 更多的帮助

The equation for permutation is: 置换方程为:

在此输入图像描述

Factorials in range of 0 to 16 are {1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000}. 在0到16范围内的因子是{1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368000,20922789888000}。 If you need more of them, search WolframAlpha for Range[1,20]! 如果你需要更多它们,请搜索WolframAlpha for Range [1,20]!

If you want to learn more about it read: 15Puzzle . 如果你想了解更多关于它的信息,请阅读: 15Puzzle

使用A * algorihtm在C ++中进行十五个拼图实现https://gist.github.com/sunloverz/7338003

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM