Tower Of Hanoi Flash Game
Code this classic puzzle game, "Tower of Hanoi" amongst Flash AS3 inwards 2011.
The Tower of Hanoi or Towers of Hanoi is a mathematical game or puzzle. It consists of 3 rods, as well as a position out of disks of dissimilar sizes which tin slide onto whatever rod. The puzzle starts amongst the disks inwards a cracking stack inwards ascending lodge of size on 1 rod, the smallest at the top, therefore making a conical shape. The objective of the puzzle is to motion the entire stack to roughly other rod.
Game rules
The game showtime amongst 3 rods, A,B as well as C. Initially, all disks are stack on rod A, as well as you lot accept to motion all the disk inwards ascending lodge on rod C to win.There are few criteria when moving the disk around.
- Only 1 disk tin live on motion at a time.
- Only the altitude nearly disk tin live on move.
- Disk tin exclusively live on placed on altitude of a larger disk.
Gameplay Programming
To code this game, nosotros tin purpose 3 arrays to correspond the 3 rods, which incorporate listing of values that correspond all the disks. The bigger the disk, the larger the position out (or the other manner round, depend on how you lot create the status disceptation later).Then, purpose array PUSH as well as POP business office to "move the disk around". In this case, the PUSH as well as POP business office function just similar what nosotros want, removing as well as adding items from the altitude of the array/stack.
Last, purpose a status disceptation to cheque to run across if a disk tin live on motion on to roughly other rod base of operations on target rod altitude nearly disk size. To cheque the altitude nearly disk size, only POP it.
Recursive Solution
The puzzle tin live on solve automatically past times using a recursive business office too, which you lot tin read to a greater extent than inwards this page, "Writing a Towers of Hanoi program".Play The Game
You tin play "Tower of Hanoi" inwards my deviantart. I accept include the recursive puzzle solving business office every bit well.Reference
Tower of Hanoi WikipediaWriting a Towers of Hanoi program
Tower of Hanoi Game Deviantart
Belum ada Komentar untuk "Tower Of Hanoi Flash Game"
Posting Komentar