New topic: 

Tower of Hanoi and Solutions:  Anyone for Sharing Code?

<http://forums.realsoftware.com/viewtopic.php?t=46599>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        barrytraver          Post subject: Tower of Hanoi and Solutions: 
 Anyone for Sharing Code?Posted: Thu Jan 17, 2013 6:47 pm                       
  
Joined: Fri Sep 30, 2005 1:53 pm
Posts: 780
Location: Philadelphia, PA                Last night I wrote an RB program to 
calculate the moves needed for the Tower of Hanoi, the object of which is to 
transfer all of the disks of different sizes on one peg or pole to another.  
(There are three pegs, two of which start out empty.)

There are essentially only two rules: (1) you can move only one disk at at 
time.  (2) No disk may be placed on top of a smaller disk.  

Important:  I did not write the game program itself.  (I'm hoping to find 
someone here who may be interested enough to work with me on that.) What I 
wrote was a program which shows the minimum moves, step-by-step, required to 
solve the puzzle.

Here's where you can find the source code for my program:

http://traver.org/RB2013/Hanoi.rbp

Here's the Web page that inspired me:

http://britton.disted.camosun.bc.ca/jbhanoi.htm

And here's a sample of what my program does:
_____

SOLUTION FOR 10 DISKS
(1023 moves minimum required)

1 (Move 1):  Move disk 1 onto empty peg.
10 (Move 2):  Move disk 2 onto empty peg.
11 (Move 3):  Move disk 1 onto disk 2.
100 (Move 4):  Move disk 3 onto empty peg.
101 (Move 5):  Move disk 1 but NOT onto disk 3.
...
_____

My program was written in Windows, which uses Chr (13) as an end-of-line marker 
for text inside a TextArea.  That will have to be changed for the program to 
work properly on the Mac or on Linux.

What I'm looking for from people on the Forum is suggestions for improvement of 
my program.  (If someone wants to write, say, something that will allow people 
to play the game on their own computer, that would be great!)  If you prefer to 
send me a private email rather than posting a note, that would be okay, but 
posting on the Forum would enable others here to benefit from the discussion.  
My objective here is to encourage sharing of code.

Barry Traver

P.S. I'm actually hoping that I may find here at least a few hobbyist 
programmers who have an interest in working together on logic-type games, such 
as those discussed by Martin Gardner in his "Mathematical Games" column in 
Scientific American in years past.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to