-static void clockwise_path(char ** path_ptr);
-
-/* Return dir char (north = "N" etc.) to enemy nearest to "origin" (beeline). */
-static char nearest_enemy_dir(struct yx_uint16 origin);
+static void get_neighbor_scores(char * dirs, uint8_t len_dirs,
+ uint8_t * score_map, struct yx_uint16 pos_yx,
+ uint32_t pos_i, uint8_t max_score,
+ uint8_t * neighbor_scores)
+{
+ memset(neighbor_scores, max_score, len_dirs);
+ uint8_t i_dirs;
+ for (i_dirs = 0; i_dirs < len_dirs; i_dirs++)
+ {
+ if ('N' == dirs[i_dirs] && pos_yx.y > 0)
+ {
+ neighbor_scores[i_dirs] = score_map[pos_i - world.map.size.x];
+ }
+ else if ('E' == dirs[i_dirs] && pos_yx.x < world.map.size.x - 1)
+ {
+ neighbor_scores[i_dirs] = score_map[pos_i + 1];
+ }
+ else if ('S' == dirs[i_dirs] && pos_yx.y < world.map.size.y - 1)
+ {
+ neighbor_scores[i_dirs] = score_map[pos_i + world.map.size.x];
+ }
+ else if ('W' == dirs[i_dirs] && pos_yx.x > 0)
+ {
+ neighbor_scores[i_dirs] = score_map[pos_i - 1];
+ }
+ }
+}