]> pd.if.org Git - hexagon/blobdiff - hexmap.h
Improved astar api. Added doc file.
[hexagon] / hexmap.h
index 10586538067fca7ed15d34bd8b4badd551276c9d..50665d058f87c05faaa42e11838688892485d86c 100644 (file)
--- a/hexmap.h
+++ b/hexmap.h
@@ -79,6 +79,10 @@ int HL_hexcenter(int cantor, double *x, double *y);
 /* how far is it on the hex grid */
 int HL_distance(int from_cantor, int to_cantor);
 
+/* returns 0 for <0 or >5 */
+int HL_adjacent_hex(int start, int dir);
+
+/* module direction */
 int HL_adjhex(int start, int dir);
 int HL_hexes_at_range(int hex, int range, int *list, int size);
 int HL_hexes_within_range(int hex, int range, int *list, int size);
@@ -105,4 +109,37 @@ struct HL_hex {
        int x,y; /* hmm.  would be nice to be able to just point to a generic */
 };
 
+/*
+ * Pathfinding
+ */
+
+struct HL_astar_hex {
+       int hex;
+       double f, g, h;
+       struct HL_astar_hex *parent;
+       int     open;
+       struct HL_astar_hex *next;
+       struct HL_astar_hex *prev;
+};
+
+struct HL_astar {
+       int start, goal;
+       int pathlen;
+       double (*metric)(int,int);
+       double (*heuristic)(int,int);
+       int (*neighbor)(int,int);
+       int nodes, allocated;
+       struct HL_astar_hex *sets;
+       struct HL_astar_hex *open;
+       struct HL_astar_hex *closed;
+       struct HL_astar_hex *from, *to;
+       int known, index;
+       int error, malloced;
+};
+
+int HL_findpath(struct HL_astar *s, int loops);
+void HL_astar_free(struct HL_astar *s);
+struct HL_astar *HL_astar_clear(struct HL_astar *s);
+struct HL_astar *HL_astar_init(struct HL_astar *s);
+
 #endif