Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write scheme functions that uses breadth - first search to solve the 8 - puzzle problem: Eight tiles ( numbered 1 through 8 ) are

Write scheme functions that uses breadth-first search to solve the 8-puzzle problem: Eight tiles (numbered 1 through 8) are fitted into a 3X3 matrix. One space is left blank so that tiles can be moved around to change the configuration of the matrix. The objective is to find a sequence of moves of the tiles into blank space that change the matrix from the initial state to the goal state. For example: Initial state 12345786 Intermediate State 12345786 Goal state 12345678 Each problem state can be represented by a list containing the 9 symbols (numbers 18 and B for blank) in row-major order. For example, the goal state is represented by (12345678 B). Part I. Move operators (40 points) It is much easier to describe the change of matrix in terms of moving the blank tile, instead of moving a number tile. For example, we can describe the change from intermediate state to the goal state as moving the blank tile down by one row. Write 4 functions named up, down, left, right that each accept a list argument describing the state of the matrix and return the new state of the matrix generated by moving the blank tile in the direction indicated by the function name. The function should return () if the movement will cause the blank tile to go out of bound. For example, (up (12345 B 786))(12 B 453786)(up (12 B 453786))() Part II. Bread-first Search (40 points) Write a function named 8-puzzle that accept two list arguments: the 1st describing the initial state and the 2nd describing the goal state. The function returns a list of states describing a path from initial state to the goal state using breadth-first search. For example: (8-puzzle '(12385647 B)'(12345678 B))((12385647 B)(12385 B 476)(1238 B 5476)(123 B 85476)(123485 B 76)(1234857 B 6)(1234 B 5786)(12345 B 786)(12345678 B)) At any point during the search, we can change the current state to a new state by calling one of the 4 functions: up, down, left, right. For example, (up (12345 B 786))(12 B 453786)^^|||| current state new state Before a new path contain the new state is added to the end of the search queue (i.e., the node-list in the fwgc program), it must satisfy the following two conditions: The new state has NOT been generated previously, i.e., it is not in any of the paths of the queue. The new state is not empty. Part III print8puzzle (20 points) If we wish to see the path as actual matrices, we would need to define print8puzzle function We can call print8puzzle the solution to get the actual step-by-step solution. For example: (print8puzzle (8puzzle '(12385647 B)'(12345678 B)))->1238564712385476123854761238547612348576123485761234578612345786123456789

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

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions