I recently completed a small Android project called jigsaw puzzle. The project is not complex, but it is also a complete project, which involves a wealth of knowledge points.
The following is a summary as follows:
Requirement definition:
1. Select an image and go to the tile page. You can select a default image or custom image, that is, select an image from the image library or take a photo from the camera.
2. You can set the difficulty of the game, that is, select the NXN structure for the puzzle.
3. Automatically disrupt the order of the puzzle, and use the inversion and algorithm to ensure that the generated data is resolved.
4. You can view the source image during the puzzle process.
5. The puzzle has the functions of timing and recording steps.
6. After the puzzle is completed, all the images are displayed and the puzzle is successfully upgraded.
7. You can view the history.
* 8. The ida star algorithm can be used to automatically solve problems.
Basically, the above functions can be implemented. The automatic problem solving algorithm has not yet been implemented. It seems that it can only be reserved for the second edition---, alas, please advise.
In international practice, first look at the effect:
Figure 1. Is the initial interface slightly fresh? haha
Figure 2. Select the game difficulty option in the upper right corner. Ignore the option 2. for debugging purposes, change the option to 5X5.
Figure 3. Selecting images and difficulty
Figure 4. Go to the main puzzle page and click the corresponding square to move it with the blank square. It is the same as the actual puzzle.
Figure 5. Click the source image button to display the source image, which has an animation effect.
Figure 6. Complete the puzzle
Figure 7. Click the Add Custom button to select a local atlas or camera
Figure 8. Mobile phone Atlas. Ignore the photo. Xiaomi System
Figure 9. Take a photo of the camera. Please confirm the license.
Figure 10. Take a photo with the camera and go to the tile page
Basically, these functions are described above. Next, we will explain the implementation process of this project.