![]() The MoveCalculator class takes in the amount of disks that the user wants Here follows five snippets from the application: After executing all the moves in the list, all the disks should be on the 'end pole'. In the start state of the game all the disks will be on the 'start pole'. In the function each move gets add to a list. The algorithm used to solve the puzzle is a very simple recursive function. I also added drop and drag functionality to make the game more enjoyable. The Disk PictureBox got the responsibility to move itself around. The Pole PictureBox had to keep track of the disks on itself, by maintainingĪ sorted list of disks. I wanted to use the PictureBox control as the base objectįor the disks and poles, but needed more, so I extended the PictureBox control. The GameForm contains all the graphical components and servers as the driver for the application. ![]() The MoveCalculator would returnĪ list of moves and the GameState would make them. GameState, so the Move class was introduced. I wanted the MoveCalculator to return something useful to the GameForm would drive the front end, with the help of a few controls. The GameState class would handle the game mechanics and the MoveCalculator class with the sole purpose of working on the solution. ![]() I wanted a clear separation between the UI and the backend. ** The term pole is used to describe the pegs, containing the disks. * The term disk is used throughout the article to describe the movable parts of the puzzle.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |