Skip to content

Commit

Permalink
- Code cleaning + minor optimizations.
Browse files Browse the repository at this point in the history
- Added documentation + HTML format (Doxygen).
- Update of the README.
- First release.
  • Loading branch information
Astropilot committed Apr 12, 2019
1 parent 9d882aa commit 99eae64
Show file tree
Hide file tree
Showing 177 changed files with 16,416 additions and 136 deletions.
70 changes: 68 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,68 @@
# Hexagones
Rewriting of a pedagogical program on graph path algorithms in C.
<h1><img src="https://www.codexus.fr/img/hexagones/logo_hexagones.png" height="96" alt="Hexagones Logo" /></h1>

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Astropilot/Hexagones/blob/master/LICENSE)
[![Version](https://img.shields.io/github/release/Astropilot/Hexagones.svg?label=version)](https://github.com/Snaipe/Hexagones/releases/latest)
![Made with love](https://img.shields.io/badge/Made%20with-%E2%9D%A4%EF%B8%8F-yellow.svg)

Rewriting in C of a pedagogical program allowing to understand the functioning of path-finding algorithms in graphs.

![Screencast](https://www.codexus.fr/img/hexagones/demo.gif)

## How to use it

Hexagons allows you to test path-finding algorithms on a 2D hexagonal map.

Algorithms should try to find a path from the starting point (the magenta-colored hexagon) to the ending point (the red colored hexagon). <br>
You can complicate their task by adding impassable or difficult to cross obstacles, you have walls (black), water (blue), grass (green) and sand (yellow).

The walls are totally impassable, but the others only slow down by having a higher cost to move from one neighbour to the other. The costs are as follows:

| Type of tile | Cost |
| :----------- | :--------: |
| Wall | impassable |
| Nothing | 1 |
| Water | 10 |
| Grass | 5 |
| Sand | 2 |

Here is the list of algorithms that have been implemented:

* [x] Depth-first search
* [x] Breadth-first search
* [x] Connected components (This algorithm is an exception, it only displays the connected components.)
* [x] Bellman-Ford
* [x] Dijkstra
* [x] A*

## Download & Install

### Prerequisites

To be able to compile the project, you must first have the GTK 3 graphics library.

On Debian/Unbuntu distributions you can install it via the command
```bash
$ sudo apt-get install libgtk-3-dev
```

### How to compile

First of all you have to recover the sources. To do this you can either download a release [from the release page](https://github.com/Astropilot/Hexagones/releases), or clone the repository via the command
```bash
$ git clone https://github.com/Astropilot/Hexagones.git
```

Once the sources are recovered, you can compile the project under UNIX with the make command:
```bash
$ cd Hexagones
$ make
```

Finally, all you have to do is launch Hexagons!
```bash
$ ./hexagones
```

## Credits

This project is a rewrite of an already existing project originally written in Python by [Mr. David Auger](https://www.david.uvsq.fr/?profile=auger-david), professor-researcher at the University Institute of Technology in Vélizy, France.
99 changes: 99 additions & 0 deletions docs/html/annotated.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!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.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hexagones: Data Structures</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="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</script>
<link href="doxygen.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">Hexagones
&#160;<span id="projectnumber">1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<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('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('annotated.html','');});
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">Data Structures</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock">Here are the data structures with brief descriptions:</div><div class="directory">
<table class="directory">
<tr id="row_0_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structarrow__id__t.html" target="_self">arrow_id_t</a></td><td class="desc">A structure representing a unique ID for tile arrows </td></tr>
<tr id="row_1_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structint__pair__t.html" target="_self">int_pair_t</a></td><td class="desc">A structure representing a pair of integers </td></tr>
<tr id="row_2_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structpriority__queue__node__t.html" target="_self">priority_queue_node_t</a></td><td class="desc">Represents a node in a priority queue </td></tr>
<tr id="row_3_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structpriority__queue__t.html" target="_self">priority_queue_t</a></td><td class="desc">Represents a priority queue </td></tr>
<tr id="row_4_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structqueue__node__t.html" target="_self">queue_node_t</a></td><td class="desc">Represents a node in a queue </td></tr>
<tr id="row_5_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structqueue__t.html" target="_self">queue_t</a></td><td class="desc">Represents a queue </td></tr>
<tr id="row_6_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structrgba__color__t.html" target="_self">rgba_color_t</a></td><td class="desc">Structure representing a RGBA color </td></tr>
<tr id="row_7_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="struct_t_controller.html" target="_self">TController</a></td><td class="desc">An class representing the controller </td></tr>
<tr id="row_8_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structtext__id__t.html" target="_self">text_id_t</a></td><td class="desc">A structure representing a unique ID for tile labels </td></tr>
<tr id="row_9_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="struct_t_grid_model.html" target="_self">TGridModel</a></td><td class="desc">An class representing the model of the hexagonal map </td></tr>
<tr id="row_10_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="struct_t_hex.html" target="_self">THex</a></td><td class="desc">An class representing the model of a hexagonal tile </td></tr>
<tr id="row_11_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="struct_t_main_window.html" target="_self">TMainWindow</a></td><td class="desc">An class representing the main window </td></tr>
<tr id="row_12_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="struct_t_map.html" target="_self">TMap</a></td><td class="desc">An class representing the view of the hexagonal map </td></tr>
<tr id="row_13_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="struct_t_palette.html" target="_self">TPalette</a></td><td class="desc">An class representing the palette of tile types </td></tr>
</table>
</div><!-- directory -->
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li>
</ul>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions docs/html/annotated_dup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var annotated_dup =
[
[ "arrow_id_t", "structarrow__id__t.html", "structarrow__id__t" ],
[ "int_pair_t", "structint__pair__t.html", "structint__pair__t" ],
[ "priority_queue_node_t", "structpriority__queue__node__t.html", "structpriority__queue__node__t" ],
[ "priority_queue_t", "structpriority__queue__t.html", "structpriority__queue__t" ],
[ "queue_node_t", "structqueue__node__t.html", "structqueue__node__t" ],
[ "queue_t", "structqueue__t.html", "structqueue__t" ],
[ "rgba_color_t", "structrgba__color__t.html", "structrgba__color__t" ],
[ "TController", "struct_t_controller.html", "struct_t_controller" ],
[ "text_id_t", "structtext__id__t.html", "structtext__id__t" ],
[ "TGridModel", "struct_t_grid_model.html", "struct_t_grid_model" ],
[ "THex", "struct_t_hex.html", "struct_t_hex" ],
[ "TMainWindow", "struct_t_main_window.html", "struct_t_main_window" ],
[ "TMap", "struct_t_map.html", "struct_t_map" ],
[ "TPalette", "struct_t_palette.html", "struct_t_palette" ]
];
132 changes: 132 additions & 0 deletions docs/html/astar_8h.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<!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.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hexagones: includes/pathfinding/astar.h File Reference</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="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(initResizable);
/* @license-end */</script>
<link href="doxygen.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">Hexagones
&#160;<span id="projectnumber">1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<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('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('astar_8h.html','');});
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
<div class="summary">
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">astar.h File Reference</div> </div>
</div><!--header-->
<div class="contents">

<p>The A* algorithm.
<a href="#details">More...</a></p>

<p><a href="astar_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a60f96f2fcd3a5f559066a4ef1937a2b3"><td class="memItemLeft" align="right" valign="top"><a id="a60f96f2fcd3a5f559066a4ef1937a2b3"></a>
typedef struct <a class="el" href="struct_t_grid_model.html">TGridModel</a>&#160;</td><td class="memItemRight" valign="bottom"><b>TGridModel</b></td></tr>
<tr class="separator:a60f96f2fcd3a5f559066a4ef1937a2b3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ac3d94f8ed0a3330e27f040e756085037"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="astar_8h.html#ac3d94f8ed0a3330e27f040e756085037">astar</a> (<a class="el" href="struct_t_grid_model.html">TGridModel</a> *model)</td></tr>
<tr class="memdesc:ac3d94f8ed0a3330e27f040e756085037"><td class="mdescLeft">&#160;</td><td class="mdescRight">Function that triggers the A* algorithm from the model. <a href="#ac3d94f8ed0a3330e27f040e756085037">More...</a><br /></td></tr>
<tr class="separator:ac3d94f8ed0a3330e27f040e756085037"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The A* algorithm. </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ac3d94f8ed0a3330e27f040e756085037"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac3d94f8ed0a3330e27f040e756085037">&#9670;&nbsp;</a></span>astar()</h2>

<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void astar </td>
<td>(</td>
<td class="paramtype"><a class="el" href="struct_t_grid_model.html">TGridModel</a> *&#160;</td>
<td class="paramname"><em>model</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">

<p>Function that triggers the A* algorithm from the model. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">model</td><td>A pointer to the model instance. </td></tr>
</table>
</dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_09e761304027c904456130627fd4dcf5.html">includes</a></li><li class="navelem"><a class="el" href="dir_1db1fefbbe548b20628f542f68011f8a.html">pathfinding</a></li><li class="navelem"><a class="el" href="astar_8h.html">astar.h</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li>
</ul>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions docs/html/astar_8h.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var astar_8h =
[
[ "TGridModel", "astar_8h.html#a60f96f2fcd3a5f559066a4ef1937a2b3", null ],
[ "astar", "astar_8h.html#ac3d94f8ed0a3330e27f040e756085037", null ]
];
Loading

0 comments on commit 99eae64

Please sign in to comment.