Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

OK so im trying so solve this problem, and it has to be done with A* search algorithm. Im getting issues with the sliding puzzle

image text in transcribed

OK so im trying so solve this problem, and it has to be done with A* search algorithm. Im getting issues with the sliding puzzle and understanding how the a* algorithm works with this context of switching the empty space with the tiles. From my understanding, if the empty tile is in the middle, then there are a possibility of 6 child states where the empty tile can switch with tiles up to 2 away on either side. For my heuristic, i have selected the number of white tiles to the right of the first black tile, and i believe this is a correct assumption. (please correct me if im wrong but it always underestimates i do know that)

Everywhere i look for the a* algo, I see pseudocode or real code that references each neighbor of the current node being evaluated (see the wikipedia snippet below).

image text in transcribed

i have been able to program this and gather correct g, f, and h scores but my program is not eliminating cycles and such. I think it is because i'm not understanding what neighbors are. how would i go about gathering the neighbors and what are the neighbors? I am coding this in java so it would be helpful if it were explained in terms of that or psueudocode if nothing else. I have tried generating the up to 6 child nodes from the current node, and was unsuccessful. I have also tried generating children from the parent of the current node, but that also creates cycles. Is a neighbor coming from different paths as well? how would I go about programming that?

Consider a sliding block puzzle with the following initial configuration: There are three black tiles (B), three white tiles (W), and an empty cell (E). The puzzle has the following moves A tile may move into an adjacent empty cell with unit cost. b. a. A tile may hop over at most two other tiles into an empty cell with a cost equal to the num ber of tiles ho pped over Initial BBBWWEW BBBWWEW BBBWWEW Cost Next BBBWEWW BBBEwww BBEWWBW The goal of the puzzle is to have all of the white tiles to the left of all of the black tiles (regardless of the position of the blank cell) Consider a sliding block puzzle with the following initial configuration: There are three black tiles (B), three white tiles (W), and an empty cell (E). The puzzle has the following moves A tile may move into an adjacent empty cell with unit cost. b. a. A tile may hop over at most two other tiles into an empty cell with a cost equal to the num ber of tiles ho pped over Initial BBBWWEW BBBWWEW BBBWWEW Cost Next BBBWEWW BBBEwww BBEWWBW The goal of the puzzle is to have all of the white tiles to the left of all of the black tiles (regardless of the position of the blank cell)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

Identify five strategies to prevent workplace bullying.

Answered: 1 week ago