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
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).
Step by Step Solution
3.45 Rating (177 Votes )
There are 3 Steps involved in it
Step: 1
Source code 1 C implementation of above approach using System using SystemCollections using SystemCollectionsGeneric class GFG graph static List graphnew List map to store cost of edges static Diction...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started