| OkashiiKen 2006-10-21, 3:44 pm |
| I havent coded in java for about 5 months, so I decided to pull out an old school project and try and make some improvements.
I am working on rebuilding a user interface for a 15-puzzle game. Currently, the gameboard is created using formatted JButtons each with a title string reading "1" to "15" and a " " for the empty box. In order to "move" the boxes i wrote a method that swaps the titles of the boxes and then repaints the frame. In retrospect, I am wondering if this was a bad way to implement the game pieces. I could have done it by drawing shapes onto the JFrame, but that seemed much more difficult at the time. Any suggestions on how to do this better? Especially since I was planning to look into changing the game board into a picture as opposed to numbered buttons.
I am still working on debugging the heuristic i am using to automatically solve the puzzle. The puzzle was initially supposed to be solved using a DBS, but I never got that to work properly as i couldnt avoid all the cyclic traps. If anyone would like to explain how to implement a DBS to solve a 15-puzzle, or even about various heuristics for solving the 15-puzzle, Id be interested.
Thanks. |