summaryrefslogtreecommitdiff
path: root/digital/io-hub/src/guybrush/path.c
diff options
context:
space:
mode:
authorNicolas Schodet2012-06-02 00:17:44 +0200
committerNicolas Schodet2012-06-02 00:17:44 +0200
commit263fa4fa5472cd013f2ac2993e6cee0f8d73a2fb (patch)
treef88ba0820df3b45ceb7081ef6d01fab04065f228 /digital/io-hub/src/guybrush/path.c
parent1ef63de6558685e4b49cf1155423f24293d0bb88 (diff)
digital/io-hub/src/guybrush: use faster algorithms for decision
Diffstat (limited to 'digital/io-hub/src/guybrush/path.c')
-rw-r--r--digital/io-hub/src/guybrush/path.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/digital/io-hub/src/guybrush/path.c b/digital/io-hub/src/guybrush/path.c
index 639e9472..a1bc94e1 100644
--- a/digital/io-hub/src/guybrush/path.c
+++ b/digital/io-hub/src/guybrush/path.c
@@ -486,13 +486,23 @@ path_get_next (vect_t *p)
return 0;
}
+void
+path_prepare_score (void)
+{
+ path_blocked_update ();
+ astar_dijkstra_prepare (path.astar_nodes, PATH_NODES_NB,
+ PATH_SRC_NODE_INDEX, PATH_DST_NODE_INDEX);
+ path.escape_factor = 0;
+}
+
uint16_t
-path_get_score ()
+path_get_score (void)
{
- if (path.found)
- return path.astar_nodes[PATH_SRC_NODE_INDEX].score;
- else
- return (uint16_t) -1;
+ uint16_t score;
+ score = astar_dijkstra_finish (path.astar_nodes, PATH_NODES_NB,
+ PATH_DST_NODE_INDEX);
+ path.escape_factor = 0;
+ return score;
}
/** Neighbors callback for nodes in grid. */
@@ -582,7 +592,8 @@ path_astar_neighbor_callback_other (uint8_t node,
}
}
/* Check if direct path OK. */
- if (!path_blocking (node, PATH_SRC_NODE_INDEX, &d))
+ if (node != PATH_SRC_NODE_INDEX
+ && !path_blocking (node, PATH_SRC_NODE_INDEX, &d))
{
/* Add this neighbor. */
neighbors[neighbors_nb].node = PATH_SRC_NODE_INDEX;