I need some help with functions.
Author |
Message |
Silent Avenger
![](http://compsci.ca/v3/uploads/user_avatars/15799977747577a0b762ca.jpg)
|
Posted: Sun Nov 26, 2006 10:21 pm Post subject: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
wtd
|
Posted: Sun Nov 26, 2006 11:55 pm Post subject: (No subject) |
|
|
Care to show us the code you have, thus far? |
|
|
|
|
![](images/spacer.gif) |
Silent Avenger
![](http://compsci.ca/v3/uploads/user_avatars/15799977747577a0b762ca.jpg)
|
Posted: Mon Nov 27, 2006 8:08 am Post subject: (No subject) |
|
|
Oh right, sorry I forgot to post it. Okay here's the code I have so far: code: | 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 |
|
|
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Mon Nov 27, 2006 8:35 am Post subject: (No subject) |
|
|
Cannot MoveDisks and/or MoveTower affect the value of some text field? |
|
|
|
|
![](images/spacer.gif) |
Silent Avenger
![](http://compsci.ca/v3/uploads/user_avatars/15799977747577a0b762ca.jpg)
|
Posted: Tue Nov 28, 2006 5:36 pm Post subject: (No subject) |
|
|
The value of the text field should not be affected though because it's the number of disks in the game. |
|
|
|
|
![](images/spacer.gif) |
cool dude
![](http://www.taylorstrategicmarketing.com/images/king.jpg)
|
Posted: Sun Dec 03, 2006 4:45 pm Post subject: (No subject) |
|
|
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 |
|
|
|
|
![](images/spacer.gif) |
Silent Avenger
![](http://compsci.ca/v3/uploads/user_avatars/15799977747577a0b762ca.jpg)
|
Posted: Sun Dec 03, 2006 10:36 pm Post subject: (No subject) |
|
|
Okay thanks cool dude. |
|
|
|
|
![](images/spacer.gif) |
cool dude
![](http://www.taylorstrategicmarketing.com/images/king.jpg)
|
Posted: Sun Dec 03, 2006 11:09 pm Post subject: (No subject) |
|
|
Silent Avenger wrote: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Silent Avenger
![](http://compsci.ca/v3/uploads/user_avatars/15799977747577a0b762ca.jpg)
|
Posted: Mon Dec 04, 2006 6:45 pm Post subject: (No subject) |
|
|
It's okay cool dude, I managed to figure it out with the help of the website. |
|
|
|
|
![](images/spacer.gif) |
|
|