+static void get_neighbor_scores(uint16_t * score_map, uint16_t pos_i,
+ uint16_t kill_score, uint16_t * neighbors,
+ uint8_t check_inhabitants);
+
+/* Iterate over scored cells in "score_map" of world.map's geometry. Compare
+ * each cell's score against the score of its immediate neighbors in N_DIRS
+ * directions. If any neighbor's score is at least two points lower than the
+ * current cell's score, re-set it to 1 point higher than its lowest-scored
+ * neighbor. Repeat this whole process until all cells have settled on their
+ * final score. Ignore cells whose score is greater than "max_score". Expect
+ * "max_score" to be the maximum score for cells, marking them as unreachable.
+ */
+static void dijkstra_map(uint16_t * score_map, uint16_t max_score);
+
+/* Helpers to init_score_map(), realizing individual filters. */
+static uint8_t score_map_filter_attack(uint8_t filter, uint16_t * score_map,
+ struct Thing * t_eye);
+static uint8_t score_map_filter_flee(uint8_t filter, uint16_t * score_map,
+ struct Thing * t_eye);
+static uint8_t score_map_filter_consume(uint8_t filter, uint16_t * score_map,
+ struct Thing * t_eye);
+static uint8_t score_map_filter_search(uint8_t filter, uint16_t * score_map,
+ struct Thing * t_eye);
+
+/* get_dir_to_nearest_target() helper: Prepare "score_map" for dijkstra_map(). */
+static void init_score_map(char filter, uint16_t * score_map, uint32_t map_size,
+ struct Thing * t_eye);
+
+/* From "targets" select random "cmp" match as directory by order in "dirs". */
+static char rand_target_dir(char * dirs, uint16_t cmp, uint16_t * targets);
+
+/* Helper to get_dir_to_nearest_target(). */
+static char get_dir_from_neighbors(char filter, struct Thing * t_eye,
+ uint16_t * score_map);
+
+/* Set (if possible) as "t_eye"'s command a move to the path to the path-wise
+ * nearest target that is not "t_eye" and fits criteria set by "filter". On
+ * success, return !0, else 0. Values for "filter":
+ * "a": thing in FOV is animate, but of a type that is not "t_eye"'s, and
+ * starts out weaker than it is; build path as avoiding things of "t_eye"'s
+ * type
+ * "f": neighbor cell (not inhabited by any animate thing) further away from
+ * animate thing not further than x steps away and in FOV and of a type
+ * that is not "t_eye"'s, and starts out stronger or as strong as "t_eye"
+ * is currently; or (cornered), if no such flight cell, but thing of above
+ * criteria is in neighbor cell, that cell
+ * "c": thing in memorized map is consumable
+ * "s": memory map cell with greatest-reachable degree of unexploredness
+ */
+static uint8_t get_dir_to_nearest_target(struct Thing * t_eye, char filter);
+
+/* Return 1 if any thing not "t_eye" is known and fulfills some criteria defined
+ * by "filter", else 0. Values for "filter":
+ * "a" or "f": thing in FOV is animate, but of type that not that of "t_eye",
+ * and starts out weaker ("a") / stronger ("f") than "t_eye" is
+ * "c" : thing in memorized map is consumable
+ */
+static uint8_t seeing_thing(struct Thing * t_eye, char filter);
+
+/* Return slot ID of strongest consumable in "t_owner"'s inventory, else -1. */
+static int16_t get_inventory_slot_to_consume(struct Thing * t_owner);
+
+/* Return 1 if "t_standing" is standing on a consumable, else 0. */
+static uint8_t standing_on_consumable(struct Thing * t_standing);
+
+
+
+static uint16_t set_neighbor_val(uint16_t * score_map, uint8_t check_inhabitant,
+ uint16_t kill_score, uint16_t pos)
+{
+ if (check_inhabitant)
+ {
+ struct Thing * t = world.things;
+ for (; t; t = t->next)
+ {
+ if (t->lifepoints && pos == t->pos.y * world.map.length + t->pos.x)
+ {
+ return kill_score;
+ }
+ }
+ }
+ return score_map[pos];
+}
+
+
+
+static void get_neighbor_scores(uint16_t * score_map, uint16_t pos_i,
+ uint16_t kill_score, uint16_t * neighbors,
+ uint8_t check_inhabitants)
+{
+ uint32_t map_size = world.map.length * world.map.length;
+ uint8_t open_north = pos_i >= world.map.length;
+ uint8_t open_east = pos_i + 1 % world.map.length;
+ uint8_t open_south = pos_i + world.map.length < map_size;
+ uint8_t open_west = pos_i % world.map.length;
+ uint8_t is_indented = (pos_i / world.map.length) % 2;
+ uint8_t open_diag_west = is_indented || open_west;
+ uint8_t open_diag_east = !is_indented || open_east;
+ neighbors[0] = !(open_north && open_diag_east) ? kill_score :
+ set_neighbor_val(score_map, check_inhabitants, kill_score,
+ pos_i - world.map.length + is_indented);
+ neighbors[1] = !(open_east) ? kill_score :
+ set_neighbor_val(score_map, check_inhabitants, kill_score,
+ pos_i + 1);
+ neighbors[2] = !(open_south && open_diag_east) ? kill_score :
+ set_neighbor_val(score_map, check_inhabitants, kill_score,
+ pos_i + world.map.length + is_indented);
+ neighbors[3] = !(open_south && open_diag_west) ? kill_score :
+ set_neighbor_val(score_map, check_inhabitants, kill_score,
+ pos_i + world.map.length - !is_indented);
+ neighbors[4] = !(open_west) ? kill_score :
+ set_neighbor_val(score_map, check_inhabitants, kill_score,
+ pos_i - 1);
+ neighbors[5] = !(open_north && open_diag_west) ? kill_score :
+ set_neighbor_val(score_map, check_inhabitants, kill_score,
+ pos_i - world.map.length - !is_indented);
+}
+
+
+
+static void dijkstra_map(uint16_t * score_map, uint16_t max_score)