How do you solve the 15-puzzle with A-Star or Dijkstra's Algorithm?

后端 未结 9 951
春和景丽
春和景丽 2021-02-02 15:35

I\'ve read in one of my AI books that popular algorithms (A-Star, Dijkstra) for path-finding in simulation or games is also used to solve the well-known \"15-puzzle\".

C

相关标签:
9条回答
  • 2021-02-02 15:37

    For my current experience, on how to solve an 8 puzzle. it is required to create nodes. keep track of each step taken and get the manhattan distance from each following steps, taking/going to the one with the shortest distance. update the nodes, and continue until reaches the goal

    0 讨论(0)
  • 2021-02-02 15:39

    Here you go http://www.heyes-jones.com/astar.html

    0 讨论(0)
  • 2021-02-02 15:46

    The graph theoretic way to solve the problem is to imagine every configuration of the board as a vertex of the graph and then use a breath-first search with pruning based on something like the Manhatten Distance of the board to derive a shortest path from the starting configuration to the solution.

    One problem with this approach is that for any n x n board where n > 3 the game space becomes so large that it is not clear how you can efficiently mark the visited vertices. In other words there is no obvious way to assess if the current configuration of the board is identical to one that has previously been discovered through traversing some other path. Another problem is that the graph size grows so quickly with n (it's approximately (n^2)!) that it is just not suitable for a brue-force attack as the number of paths becomes computationally infeasible to traverse.

    This paper by Ian Parberry A Real-Time Algorithm for the (n^2 − 1) - Puzzle describes a simple greedy algorithm that iteritively arrives at a solution by completing the first row, then the first column, then the second row... It arrives at a solution almost immediately, however the solution is far from optimal; essentially it solves the problem the way a human would without leveraging any computational muscle.

    This problem is closely related to that of solving the Rubik's cube. The graph of all game states it too large to solve by brue force, but there is a fairly simple 7 step method that can be used to solve any cube in about 1 ~ 2 minutes by a dextrous human. This path is of course non-optimal. By learning to recognise patterns that define sequences of moves the speed can be brought down to 17 seconds. However, this feat by Jiri is somewhat superhuman!

    The method Parberry describes moves only one tile at a time; one imagines that the algorithm could be made better up by employing Jiri's dexterity and moving multiple tiles at one time. This would not, as Parberry proves, reduce the path length from n^3, but it would reduce the coefficient of the leading term.

    0 讨论(0)
  • 2021-02-02 15:53

    Remember that A* will search through the problem space proceeding down the most likely path to goal as defined by your heurestic.

    Only in the worst case will it end up having to flood fill the entire problem space, this tends to happen when there is no actual solution to your problem.

    0 讨论(0)
  • 2021-02-02 15:54

    A quick Google search turns up a couple papers that cover this in some detail: one on Parallel Combinatorial Search, and one on External-Memory Graph Search

    General rule of thumb when it comes to algorithmic problems: someone has likely done it before you, and published their findings.

    0 讨论(0)
  • 2021-02-02 15:54

    This is an assignment for the 8-puzzle problem talked about using the A* algorithm in some detail, but also fairly straightforward:

    http://www.cs.princeton.edu/courses/archive/spring09/cos226/assignments/8puzzle.html

    0 讨论(0)
提交回复
热议问题