From 263fa4fa5472cd013f2ac2993e6cee0f8d73a2fb Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 2 Jun 2012 00:17:44 +0200 Subject: digital/io-hub/src/guybrush: use faster algorithms for decision --- digital/io-hub/src/guybrush/path.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'digital/io-hub/src/guybrush/path.c') 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; -- cgit v1.2.3