Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / the tower

Author
Message
Nic
20
Years of Service
User Offline
Joined: 26th Jun 2004
Location:
Posted: 22nd Nov 2004 19:15
I dont suppose any body has managed to code the towers of hanoi have they? im having trouble (im also trying it in macromedia director) when i say trouble i dont even know where to start .
Nic
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 23rd Nov 2004 02:50
I haven't but it shouldn't be too hard.
Make an array like this:
dim towers(numberoftowers,heightoftowers)
and in it store what blocks are on which section of it.
Then if a peice is moved check the peice below it.
If it doesn't exist then move the peice down.
Sorry if I'm just babbling.

Realms Of Tutopia: Rise Of Evil
http://www.freewebs.com/elbsoftware/index.htm
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 23rd Nov 2004 04:42
I havent coded it to work itself out but have done one that the user plays, its only three pegs and five discs though
Nic
20
Years of Service
User Offline
Joined: 26th Jun 2004
Location:
Posted: 27th Nov 2004 13:10
Andrew thats kinda vague. Does any one know somewone who can help me, i think it would be a good exercise and makes a good tutorial.
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 27th Nov 2004 20:09
NUMPAD 4 = move to left peg

NUMPAD 5 = move to centre peg

NUMPAD 6 = move to right peg

NUMPAD 8 = pick up disc

NUMPAD 2 = drop disc (once dropped score goes up by 1)

Ctrl (right) = reset everything
Nic
20
Years of Service
User Offline
Joined: 26th Jun 2004
Location:
Posted: 27th Nov 2004 22:55
i like the idea. but that dosent get round the problem of finding out if there is a disk already in the bottom slot of the peg or if the disc below the one your holding is smaller\bigger.
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 28th Nov 2004 22:33
did you click the source button?
Nic
20
Years of Service
User Offline
Joined: 26th Jun 2004
Location:
Posted: 29th Nov 2004 13:05
oops
Nic
20
Years of Service
User Offline
Joined: 26th Jun 2004
Location:
Posted: 4th Dec 2004 13:53
looks pretty spectacular but unforutnately on the first move made i get an error saying that the object dosent exist! looks cool though.
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 5th Dec 2004 21:09 Edited at: 5th Dec 2004 21:15
do you mean SOUND does not exist cos I just tried the exact same code without using any SOUND commands and it worked, I have taken out the SOUND options now, please try again and let me know how you get on
I cannot take credit for the swirly cloud in the background and cannot remember who actually did it
Do you know of a computer called SAM COUPE, well I used to get a magazine for it and in one edition there is code for THE TOWERS OF HANOI and it does complete itself, if you like I could post the listing but it will need converting to DB, I may have a go at converting it myself.
Nic
20
Years of Service
User Offline
Joined: 26th Jun 2004
Location:
Posted: 6th Dec 2004 13:12
no its not the sounds coz i copied the sounds from the windows media directory so that was all tiket-boo, it was some error with the objects...ill try again and let you know, but yeah post the other code and ill have a look. tah
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 11th Dec 2004 22:29 Edited at: 11th Dec 2004 22:34
click the source button.
as you can see it is from the days of line numbers, but it does actually work, if you download SIMCOUPE (do a GOOGLE for it) and type in the code you can see it in action.
as for Andrews suggestion, its not as simple as that as it needs to do it it in as few moves as possible so there are more checks to do than just see if there is a disc below.
obviously it will need converting for DB but anyway, here it is..
P.S
formula for calculating the least number of moves is n^2-1, n being the number of discs not pegs/towers

Login to post a reply

Server time is: 2025-05-24 08:26:23
Your offset time is: 2025-05-24 08:26:23