PUZZLE HEURISTIC

Note:The screenshot of the code execution is attached herewith.
The sum of the number of white tiles to the right of each black tile is a measure of the ‘badness’ of a state, since it will take at least one move to move past each black tile. Thus the heuristic can be taken as this sum. However, this heuristic is not admissible since it's possible for a white tile to hop two black tiles in a single move. Dividing by half ensures that we never overestimate the path cost and thus we get an admissible heuristic. Thus the heuristic is taken as ℎ(𝑛)=1/2Σ𝑤𝑖 Where wi is the number of white tiles to the right of the ith black tile. Examining for monotonicity: 1. If a tile slides into the neighbouring blank space – the heuristic remains constant and path cost is 1. 2. If a tile hops over another tile into the space – the heuristic may change by 0.5 and path cost is 1. 3. If a tile hops over 2 tiles into the space – the heuristic may change by 1 and the path cost is 2. Thus, ℎ(𝑛𝑖)−ℎ(𝑛𝑗)≤𝑐(𝑛𝑖,𝑛𝑗) and thus the heuristic is monotonic as well.

The heuristic takes values between 0 and 4.5 and thus is more informed than simpler heuristics. More informed heuristics are possible which take into account the number of positions each tile must move but they are computationally difficult to calculate.

COMPARISON TO BREADTH FIRST SEARCH The max Branching Factor of this puzzle is 6 with average B = 4.3. Breadth First Search for a solution of path length 10 will search B+B2+B3+B4+…+B10 states whereas A* search using our heuristic searches NxB with path length N. Thus A* is vastly more efficient while still giving optimal results. RUNNING THE PROGRAM Load the program with [filename]. in the Prolog interpreter prompt. Type solve( StartState ). Where StartState is in the form x/x/x/x/x/x/x with

B/B/B/0/W/W/W 2. Since the average branching factor is ~4.3.B/W/B/B/0/W/W Thus we see that even the start states with the worst heuristic are solved within 10 moves. 1010 states would have been checked! . the total states checked will be approximately 43 in the worst case. In case of BFS.b = Black Tile w = White Tile 0 = Blank Space This will yield solution in the form of a list of moves to be taken in terms of moving the blank space. DEMO EXAMPLES: 1.

Sign up to vote on this title
UsefulNot useful