Description: Need explanation is: This paper sample figure in the target state is the most efficient in calculation, the first number is very convenient, generally view the targets in the I position on the value, requires access to an array of goal[i], where goal[i]==i, therefore no need to access the array; second, to know the digital n the position of the target, you need to find goal[i]==n, row=i/3 and col=i%3., but here, row=n/3, col=n%3. when we use 8 bit unsigned integer to the digital value (0~8), n/3 and n%3 operations are very fast, faster than accessing array.
Program also provides a play game mode, that is, users themselves through W, S, A, D, four keys, respectively, control space, up, down, left, right four directions move a step, the function is very simple, the interface part is done with OpenCV. The interface section is completely separate from the search section, and the main function section in the demo file shows how to combine them.
To Search:
File list (Check if you may need any files):
8数码
8数码\8数码.exe
8数码\Astar.cpp
8数码\Astar.h
8数码\demo.cpp
8数码\puzzle8.cpp
8数码\puzzle8.h
8数码\puzzle_game.cpp
8数码\puzzle_game.h