Está en la página 1de 3

15’s Game

Problem description

The game of 15 is represented by a 4x4 matrix where there are 15 numbered cells and
one blank cell. Variations of this game may contain part of an image in each cell. The
problem consists of starting from a shuffled initial configuration of cells and arriving
at a final configuration with a determined ordering of numbers (in the case of the
array of numbers) or of images (in the case of the array where cells represent parts of
an image). The possible movements / operators to get from one configuration to
another are: 1) move the blank cell up, 2) move the blank cell down, 3) move the
blank cell to the right, and 4) move the cell to the left.

Implementation

Implement search strategies:

- iterative in depth(IDFS)
- A*
- greedy with heuristics
- Depth-First Search – DFS
- Breadth-First Search - BFS

The first 3 are the most important ones.

Apply these strategies to the game problem of 15. In the case of implementing A *
and greedy strategies, use two heuristics: (a) sum of the number of parts out of place
and (b) manhattan distance (sum of the distances of each part to its place in the final
configuration).

Given the initial and final settings (which are input arguments to the program), you
must print the operators used in the path that leads to the solution, number of steps,
runtime, and amount of memory used (counted as maximum number of nodes stored
simultaneously in memory during execution).
For each strategy, consider:

- time to reach a solution,


- amount of space spent (number of nodes generated and stored),
- completeness (can the algorithm find a solution?) and
-optimality (What is the depth of the solution found?
Does the solution match the fewer steps to get from the initial configuration to the
final or lower cost using little time and low memory?)

Use the following initial test configurations:

Use the following final test configuration:

The first configuration has optimum solution in depth 12 (the least number of
possible moves to get from the initial configuration to the final configuration).

The second initial configuration does not lead to the proposed final configuration.
Explain why.

Do not forget that your program must be prepared to receive any initial or final
configuration in an online format. For example,

1 2 3 4 5 6 8 12 13 9 0 7 14 11 10 15
1 2 3 4 5 6 7 8 9 10 11 12 13 1 4 15 0

where the first configuration corresponds to the first initial configuration suggested
above and the second configuration corresponds to the test configuration also
suggested above.

Your code should check for a solution to arrive from the initial state to the final state
before starting the search, and should issue an error message if there is no path
between the initial and the final solution.

Use the following algorithm as a basis to implement all searches (this is the general
search algorithm, but with a specific initial test for game type 15 games):

This algorithm, besides receiving the initial and final configurations, also receives as
a parameter a queuing function that will be used to sort the list of open (not yet
explored) nodes.

También podría gustarte