Solving The 8 Puzzle With A* Algorithm

后端 未结 3 1467
忘了有多久
忘了有多久 2021-02-03 11:11

I would like to solve/implement the 8 puzzle problem using the A* algorithm in Java. Am asking if someone can help me by explaining to me the steps i must follow to solve it. I

3条回答
  •  情话喂你
    2021-02-03 11:33

    A* is a lot like Djikstra's algorithm except it includes a heuristic. You might want to read that wiki or read about single-source shortest path algorithms in general.

    A lot of the basic stuff is important but obvious. You'll need to represent the board and create a method for generating the possible next states.

    The base score for any position will obviously be the minimum number of actual moves to arrive at it. For A* to work, you need a heuristic that can help you pick the best option of possible next states. One heuristic might be the number of pieces in the correct position.

提交回复
热议问题