12-tower-of-hanoi/html/index.html
github-classroom[bot] 87dcb960bf
Initial commit
2025-01-14 11:07:40 +00:00

137 lines
7.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Tower of Hanoi: Main Page</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen_extra.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Tower of Hanoi
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Tower of Hanoi Documentation</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="intro"></a>
Introduction</h1>
<p>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.</p>
<p>The objective of the puzzle is to move the entire stack of disks from the left to the right rod, obeying the following rules:</p><ul>
<li>Only one disk can be moved at a time.</li>
<li>Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack or on an empty rod.</li>
<li>No larger disk may be placed on top of a smaller disk.</li>
</ul>
<p>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)</p>
<h1><a class="anchor" id="objective"></a>
Assignment Objective</h1>
<p>In this assignment the recursiver solver for the Tower of Hanoi puzzle shall be implemented together with the required Abstract Data Types.</p>
<p>Abstract Data Types for single disks (<code>toh_disc.*</code>) and the 'Tower of Hanoi' board (<code>toh_board.*</code>) are required. The 'Tower of Hanoi' solver (<code>toh_solver.*</code>) is not an ADT but a function library.</p>
<p><b>Configuration</b></p>
<p>A configurable number of disk instances shall be available, this number is configered in <code>config.c</code> <code>MAX_DISKS</code>. There shall be exactly one instance of a board available.</p>
<p>Other configuration options affects the visualization only, but has no effect on the game.</p>
<p><b>Setup and Execution</b></p>
<p>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 <code>MAX_DISKS</code> 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.</p>
<p>After the board is initialized via solver, the solver shall solve that game using the following recursive algorithm:</p><ol type="1">
<li>move (n-1) disks from source rod to intermediate rod using target rod as buffer</li>
<li>move remaining (1) disk from source rod to target rod</li>
<li>move (n-1) disks from intermediate rod to target rod using source rod as buffer until all disks are moved from the left to the right rod.</li>
</ol>
<p><b>Visualization</b></p>
<p>The solver uses the ready-to-use Tower of Hanoi visualizer (<code>toh_visualizer.h</code>) to present the ANSI graphic of the game. A printout using function <code>toh_visualize(...)</code> is required</p><ul>
<li>after the board is initialized</li>
<li>after the move of a single disk</li>
<li>after the game is completely solved, a message telling about success or error can be applied to this viusalization step.</li>
</ul>
<h1><a class="anchor" id="assignment"></a>
Assignment</h1>
<ol type="1">
<li>Complete forward declarations, types, and function for ADTs in <code>toh_disk.h</code> and <code>toh_board.h</code> as well as in <code>toh_solver.h</code>.<ul>
<li>Types in template files may be marked as <code>&lt;type&gt;</code> within header and source files or may be omitted completely. Replace <code>&lt;type&gt;</code> with the correct type and complete missing types.</li>
<li>Parameter lists of function in a template files may be missing or incomplete</li>
</ul>
</li>
<li>Make the program and tests compile: Implement all functions declared in the headers EMTPY (return nothing, 0, false as required)<ul>
<li>All unit tests shall run but FAIL after this step</li>
<li><b>&ndash;COMMIT&ndash;</b></li>
</ul>
</li>
<li>Implement the empty functions one by one to make the unit tests pass one by one.<ul>
<li>Proposed order: disk, board, solver.</li>
<li>The purpose of a function is specified as API documentation within the header files.</li>
<li>Obey comments in source files.</li>
<li><b>&ndash;COMMIT&ndash; after each implemented function.</b></li>
</ul>
</li>
<li>Implement the missing parts to run the game in <code>toh_main_driver.c</code> methods</li>
<li>Run the game and enjoy</li>
</ol>
<h1><a class="anchor" id="notes"></a>
Notes</h1>
<ol type="1">
<li>This program requires compile option <code>-std=gnu11</code> becuase timer functions, please don't change. gnu11 extends c11 and is expected not to cause an troubles or differences in implementation</li>
<li>Visualization is implemented for Linux shell, it will not work on Windows.</li>
<li>Sometimes changes are not properly detected by incremental builds. If something very strange happens during compilation, try to run <code>make clean</code> followed by <code>make</code> to start a clean build. This approach is also recommended after everthing is done, because some compiler warning appears only in clean builds. </li>
</ol>
</div></div><!-- PageDoc -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Dec 19 2020 12:38:17 for Tower of Hanoi by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>