Quickjump to: -Source Code- -Rules- -Controls- -Revision History- -Contact-
This is a little game I made while tying to learn how to develop for the
BeOS. I played around with the Drag&Drop-features of the OS and with
the messaging stuff this implies.
As I saw that nobody released a 'Tower of Hanoi'-game, I chose to
release mine.
After I added quite some features, found and removed some bugs and did a
lot of cleaning up, I decided to publish the source code including the R4
x86 project file from V1.6 on.
I commented a lot and it took me four hours to do that. Every
newcomer developer is invited to have a look at the source code. Perhaps
he may find something usefull. I put notes to some facts that I found
remarkable. Mostly, these are facts, that I stumbled across and that cost
my a lot of debugging time.
Developers, please feel free to drop me a line by eMail (marco.zinn@gmx.de).
When you're interested in the code, start reading with Towers.h.
Note on V 1.6: The code parts which spawn and control the solver
thread are not commmented too much. See the corresponding chapters in the
BeBook for same good explanation.
In case you're unfamiliar with it... (if you know the rules, read about
the controls).
You see a tower made of 'discs' of different sizes on the left side
of the so-called 'tower window'. (In my original game, these are wooden
discs, but as we are looking at a 2D-tower from the side, they will look a
bit like bars to you. Just take a quik look at the screenshot below.)
The goal is to move the discs and to pile all of them up to a
form tower at the (now empty) location to the right, which is named 'C'.
(Remark: as for V 1.7, the game will also let you win, when you build the
tower onto 'B' instead of 'C')
There are two rules:
A screenshot from within the game might make things a bit clearer:
You see three piles, each consisting of two discs at the moment. The
largest disc (named '5' and '6') are lying on the left pile. This pile is
named tower 'A', as indicated by the'A' above the discs (unbelievable, I
know). tower 'B', the pile in the center, contains discs 2 and 3, while
the rightmost pile, tower 'C' has discs 1 and 4 on it.
You'll notice that the discs on each tower are ordered by size (and number, which only displays the size): the biggest disc with the highest number always is 'at the buttom' of the tower, while the smallest is on top.
From this position with the game, you might try the follwing moves:
What follow is a documentation of the control items of the game one by one.
As all controls are quite straight forward, you might just skip this and fiddle around with the game a bit. I tried to make the UI intutive and user-friendly. It's not perfect, but it should not present any surprises to you (as long as you know how to bring up a window, which you have accidentially hidden).
You move the discs by just dragging them from one tower and dropping them onto another. When dragging, you will get the uppermost disc of the tower, which always will be the smallest on that tower. When dropping, the disc will be stacked on top of the tower or will start a new tower, if there was not a single disc on that tower (well, just try it, you'll see what i mean). Don't forget, that you are not allowed to put a bigger disc on a smaller one.
The menus in the tower window let you perfom some more or less spectacular action:
|
|
|
![]() |
If you don't believe the task can be done at all, you
may watch the game solve itself. Just press the friendly button named 'Start
Auto-Solve' or select the corresponding item in the game menu.
This will start solving the game from the given position. While watching, you can speed up or slow down things a bit with the slider. You may also just stop (or pause) the solving process with that same button in the window, which will change to 'Stop Auto-Solve'. BTW: Auto Solve will need 15 moves with the 4 discs, so you now know what to aim at. Another BTW: This is not linear! With 5 discs, you will need 31 moves. Guess the rest..... |
![]() |
The history window sadly doesn't let you control
anything usefull, but I'll tell you a bit about it anyway.
The idea is to provide information about the moves that have been made up to now. This is done in the list, which scrolls down and shows the latest move at the top. The number of moves is noted and displayed in the first line. This should be useful for competetive reasons. The number of discs in play and the minimum number of moves (in order to solve the game with that number of discs) is shown in the second text line. When you have solved a game and the number of 'moves done' is equal to the minimum number shown in the second line, you have done a very good job! Additionally to that, the history window will mark moves that undo a previously made move by printing it in braces. The undone move will be 'embraced', too. |
![]() |
Please contact me, if you have some thoughts about this game, which you would like to share with me.
You can reach me by eMail to marco.zinn@gmx.de or via ICQ. My UIN is 1158139 (Nickname Merlin). Feel free to send me a message or chat with me, if you find me online.
The latest version of this game can be found at the BeOS section of my private homepage (http://www.marco-zinn.de/beos/beos.htm)