|
Tower of Hanoi
|
The Tower of Hanoi is a mathematical game or puzzle. The board consists of three rods and a number of disks of different sizes, which can slide onto any rod. At the beginning, all disks are placed on the left rod in ascending order of their size, the smallest disk at the top.
The objective of the puzzle is to move the entire stack of disks from the left to the right rod, obeying the following rules:
The minimal number of moves required to solve a Tower of Hanoi puzzle is 2n − 1, where n is the number of disks. (source: Wikipedia)
In this assignment the recursiver solver for the Tower of Hanoi puzzle shall be implemented together with the required Abstract Data Types.
Abstract Data Types for single disks (toh_disc.*) and the 'Tower of Hanoi' board (toh_board.*) are required. The 'Tower of Hanoi' solver (toh_solver.*) is not an ADT but a function library.
Configuration
A configurable number of disk instances shall be available, this number is configered in config.c MAX_DISKS. There shall be exactly one instance of a board available.
Other configuration options affects the visualization only, but has no effect on the game.
Setup and Execution
The solver shall initialize the board with a given number of disks. This number must be less the configured maximum number of disks. Whereas the MAX_DISKS defines the number of avialable disk instances, the number of disks applied to the initialization function of the solver defines the number of disks for the next game.
After the board is initialized via solver, the solver shall solve that game using the following recursive algorithm:
Visualization
The solver uses the ready-to-use Tower of Hanoi visualizer (toh_visualizer.h) to present the ANSI graphic of the game. A printout using function toh_visualize(...) is required
toh_disk.h and toh_board.h as well as in toh_solver.h.<type> within header and source files or may be omitted completely. Replace <type> with the correct type and complete missing types.toh_main_driver.c methods-std=gnu11 becuase timer functions, please don't change. gnu11 extends c11 and is expected not to cause an troubles or differences in implementationmake clean followed by make to start a clean build. This approach is also recommended after everthing is done, because some compiler warning appears only in clean builds.
1.8.18