Hi all, I'm writing a program to solve sliding block puzzles like these and while I think I've more or less figured it out, I have one problem before I start coding it.
During execution, the program will take the possible moves that can be performed on an board position, perform them, and add the new boards to a HashSet if they aren't in there already until a board that satisifies a solution is found. The trouble is I've never used a HashSet before so I'm not exactly sure how to go about this. Now with HashMaps, when you're putting something in it you clearly pass it a key and a value, but looking at HashSet on the API, you just pass it one object. So, what do you do when adding something to a HashSet? I plan on having it so a move in the HashSet will be a key to the board it generates. What would my HashSet.add() call look like?
Also, when I'm retrieving the solution I'm going to need the series of moves taken to arrive at it... this is also a bit confusing. I'm not entirely sure, but I think I would do this by looking at the key to the solution, but the problem is how do I go from that key (move) to the value (board) that it was executed on? I.e. how do I work my way backwards? Please, if you can help with this, only tell me in pseudo-code or English, I wouldn't want to commit any academic offenses.
Thanks much!