Prolog代写 | Two Questions

Question 1

 

The sliding-tile puzzle consists of 3 black tiles, 3 white tiles, and 1 empty spaces in the configuration shown below:

 

B B  B   W W W

A tile may move into an adjacent empty location. This has a cost of 1.

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.

The goal is to have all the white tiles to the left of all the black tiles. The position of the blank should be in the middle.

Propose a heuristic for solving this problem. Show part of the search space to the goal and the cost to the goal.

Solve the problem using PROLOG.

 

 

 

 

 

Question 2

 

  1. a) Write a program in Prolog to solve the 8-puzzle problem:

 

2 8 3
1 6 4
7   5

 

 

assume that the initial state is:

 

 

 

 

 

and the goal stat is:

1 2 3
8   4
7 6 5

 

 

 

 

 

 

 

  1. b) Define the State, Operators, Goal, Heuristic and show the path to the goal in the tree of search after applying the Heuristic.