PDA

View Full Version : For fun's sake



fullmetalcoder
7th March 2007, 19:08
Here comes my first game in Qt : Hanoi Tower

It needs Qt 4.2 because QGraphicsView is used for rendering. First of all if you can't bear frustration and don't like playing with logic just forget about it or it might cause serious brain damage (and might even affect your computer ;))

Graphically speaking this app sucks a lot and any help would be welcome to improve this aspect. ATM user only automated resolution and user moves are supported (through D'n'D with proper checks to prevent invalid moves) and resolution is detected only when all disks are moved to the last peg but I plan to had more features to bring some more fun...

Get the sources (http://edyuk.tuxfamily.org/misc/hanoi-0.1.tar.bz2) and feed me back.

Hoping you'll like it. :)

maxpower
7th March 2007, 21:46
Well I got the program and it compiled but what is the purpose/rules of the game? Also the "Solve" feature seemed to error out as it was going along and then a message popped up about not putting a circle in the right place. Then it just sat there, unless of course the puzzle was solved but I couldn't tell.

mAx

fullmetalcoder
8th March 2007, 09:23
Well I got the program and it compiled but what is the purpose/rules of the game? Also the "Solve" feature seemed to error out as it was going along and then a message popped up about not putting a circle in the right place. Then it just sat there, unless of course the puzzle was solved but I couldn't tell.

mAx
Searching on the net will bring you the answer you need but I'd rather explain th rules here because any search will also lead you to the optimal solution algorithm (used in the solve function which shouldn't be able to cause error by the way, unless you already started to move disks around).

The rules are very simple :

n disks are on the first peg, biggest at the bottom and the goal is to move them to the last peg using the smallest possible number of moves
you can only move one disk at a time and only the one on top of each pegs
to move a disk to another peg it must be smaller than any other disk that may be present on the target peg already.FYI it has been proved that the optimal solution is 2^n - 1 moves. So the "default" game (if you don't use the spinbox to change the number of disks) is 15 moves. Good luck.