(20s) Tower of Hanoi puzzle game

07022021, 02:37 AM
Post: #1




(20s) Tower of Hanoi puzzle game
Although the 20s cannot graphically display discs for the Tower of Hanoi puzzle game, I found another posting by Archilog where a numerical representation (for the 34C) is used.
An elegant, but step intensive method of moving discs can be used. Registers 1, 2 and 3 are used to store piles of discs (up to 4 discs). Register 1 initially stores the number 4321. If moving a disc from pile 1 to pile 2, we do the following: 1. Divide register 1 by 10. 2. Add the fraction part of register 1 to register 2. 3. Multiply register 2 by 10. 4. Take the integer part of register 1 and store it in register 1. The same steps would be used for the other 5 possible move combinations (these 4 steps take 12 programming steps, and since there's 6 move combinations, that's 72 steps). To start the program, XEQ A. 432,100,000,000 is displayed (this means pile 1 is 4321, pile 2 is 0000 and pile 3 is 0000). If you focus on the middle comma as being in the center of the 2nd pile, it might help the display be a little less confusing. There is no way to remove the commas and using another number base, like octal decimal would require more programming steps. To save programming steps, the user is required to "interpret" the moving of discs. To move from pile 1 to pile 2 or 3, do XEQ 2 or XEQ 3 To move from pile 2 to pile 1 or 3, do XEQ 4 or XEQ 6 To move from pile 3 to pile 1 or 2, do XEQ 7 or XEQ 8 Basically, the 3 rows of numbers on the calculator represent the starting pile (bottom row is pile 1, middle row is pile 2 and top row is pile 3), and each column represents the ending pile (left column is pile 1, middle column is pile 2 and right column is pile 3). Obviously, we don't use XEQ 1, XEQ 5 or XEQ 9, since we do not move from pile 1 to 1, pile 2 to 2, or pile 3 to 3. After each move of a disc, the new configuration of discs is displayed. For example, if our first move is pile 1 to 2 (XEQ 2), we see: 43,200,010,000 (this means pile 1 is 432, pile 2 is 0001 and pile 3 is 0000) The program takes exactly 99 steps, and no steps are available to check the validity of the move, so unexpected results may happen if an invalid move is made (like moving pile 2 to 1 at the beginning of the game (XEQ 4) results in 4.321E12). But undoing the invalid move by moving from pile 1 to 2 (XEQ 2) restores us to the correct original configuration. Code:


« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)