The sliding-tile puzzle consists of one line with 2N+1 cells (1 to 2N+1) : N white tiles(W)
Question:
The "sliding-tile puzzle" consists of one line with 2N+1 cells (1 to 2N+1) : N white tiles(W) and N black tiles (N) each of them in one cell and one empty cell (E). The goal is to have all the black tiles to the left of all the white tiles. The position of the blank is not important. The puzzle has two legal moves with associated costs:
(a) A tile may move into an adjacent empty location. This has a cost of 1.
(b) A tile can hop over one or two other tiles into the empty position. This has a cost equal to the number of tiles jumped over but the cost must be lesser than or equals N (cost<=N).
e g. for N=3 an initial state is AMAEMMA and a goal state is MMMAAEA.
Write the source code
1) using UCS and
2)using A* with the most admissible heuristic h(n).
Introduction to Probability
ISBN: 978-0716771098
1st edition
Authors: Mark Daniel Ward, Ellen Gundlach