I tried my hand at this creating a scenario for this puzzle. I found I did not need recursion or iterating. I just used the current state along with the move count to determine the next move. And to determine when the puzzle was completed, the move count would be equal to '2^n-1', where 'n' is the number of disks.
@danpost The current state and move count to determine the next move? That sounds like an interesting algorithim, although it seems to be slightly more complex. One of the reasons I chose to do it this way was that earlier I had created a program in python that gave you instructions on how to solve the puzzle, and I became interested in creating graphics for it using Greenfoot. After some puzzling through, I ended up creating an arraylist of Instruction classes, each Instruction class composed of a destination rod and a current rod. I'm sure there are other ways of doing it, I simply chose to use that one. Also, yes, I forgot to mention in the description that it was 2^n - 1 moves, I was meaning to do that but forgot about it. Lastly, did that scenario you created like that always work? The way I check for completion is if all the instructions have been performed, though you could also do it by checking to see if the size of the destination stack is equal to the total number of rings.
@Kartoffelbrot I was thinking about doing that Kartoffelbrot, although detecting where you 'drop' a ring is slightly more difficult; however, I do plan on adding this, but I'll probably create a new scenario instead of adding to this one as I have to create a draggable ring.
@Super_Hippo Ah, thanks, I'll try and fix that. The Glider class I created for the glideTo(x, y) method still has some bugs in it, one of which is that sometimes it will glide towards the destination, then simply go right past it, which is what happens in step 32 (It displays step 31 because that was the last step performed). Anyways, Super_Hippo, did you plan on watching 19 rings? Because I'll tell you now, it takes a LOT of moves.
A new version of this scenario was uploaded on Mon Dec 09 15:17:41 UTC 2013
Fixed a bug that Super_Hippo pointed out. Still somewhat glitchy after 11 rings. Occasionally a ring will move to a tower and overlap over another ring without moving to the top. This can only happen with larger numbers of rings, I believe it only occurs after 11 rings, although I am not sure. This overlap affects the aesthetic of the model, but note, it does not affect the solution.
It'd take 524,287 steps. I haven't modified it so it goes faster the more rings you use. If you download it, you can use Greenfoot's speed control, but when you put that at the maximum, it's much more likely to make errors, and still takes a LONG time to do 19.
Amazing, on full speed, it is exactly what I expected here on the site. Good, that the speed graph is not linear.
Although I can only see the first five digits of the number.
Some errors occurred, which only affected, as you said, the aesthetic. Good work :)
By the way, the speed setting should not affect the amount of errors. It could lag, but for me, it does not lag at all. It is just very fast and even this half million does not take that long.
I did want to show the algorithm I used to effectively solve the puzzle; however, I did not want to upload the scenario and take anything (view/votes) from yours. I will supply a link to the new discussion thread with the code once it is started.
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/9
2013/12/10