
-----------------------------------
Silent Avenger
Sun Nov 26, 2006 10:21 pm

I need some help with functions.
-----------------------------------
Okay I'm making a program that will solve the tower of hanoi game. I think I've got the proper function to solve it but I'm not quite sure how to output information on how to solve the game eg. move disk 1 to peg 2, move disk 2 to peg 3, move disk 1 to peg 3, etc. 

if no one knows what I'm talking about here's a website with the game: http://www.cut-the-knot.org/recurrence/hanoi.shtml

Help with this would be greatly appreciated.

-----------------------------------
wtd
Sun Nov 26, 2006 11:55 pm


-----------------------------------
Care to show us the code you have, thus far?

-----------------------------------
Silent Avenger
Mon Nov 27, 2006 8:08 am


-----------------------------------
Oh right, sorry I forgot to post it. Okay here's the code I have so far: Private Function MoveTower(Disk As Integer, Source As Integer, Dest As Integer, Spare As Integer)
    If Disk = 0 Then
      MoveDisks Disk, Source, Dest
    Else
      MoveTower Disk - 1, Source, Spare, Dest
      MoveDisks Disk, Source, Dest
      MoveTower Disk - 1, Spare, Dest, Source
    End If
End Function

Private Sub Command1_Click()
MoveTower text1.Text
End Sub

-----------------------------------
wtd
Mon Nov 27, 2006 8:35 am


-----------------------------------
Cannot MoveDisks and/or MoveTower affect the value of some text field?

-----------------------------------
Silent Avenger
Tue Nov 28, 2006 5:36 pm


-----------------------------------
The value of the text field should not be affected though because it's the number of disks in the game.

-----------------------------------
cool dude
Sun Dec 03, 2006 4:45 pm


-----------------------------------
umm, i'm not to sure on what you were asking for help with. but i think this might help you quite a bit. (Scroll to the very bottom) http://www.ecoo.org/jketelaars/java2/java1.html

-----------------------------------
Silent Avenger
Sun Dec 03, 2006 10:36 pm


-----------------------------------
Okay thanks cool dude.

-----------------------------------
cool dude
Sun Dec 03, 2006 11:09 pm


-----------------------------------
Okay thanks cool dude.

haha i've been doing java all day and got mixed up with forums. sorry i gave you a link to your solution in java code. If you need any help translating the code just ask. 

P.S. i had to write the pseudo code for Hanoi for one of my assignments just recently.

-----------------------------------
Silent Avenger
Mon Dec 04, 2006 6:45 pm


-----------------------------------
It's okay cool dude, I managed to figure it out with the help of the website.
