X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=src%2Fserver%2Fai.c;h=75b4b89fc350b45d26da319a9f0046c71a24afa4;hb=e2f7f39d5d52702f0b0b9dfdcf5867be325e7572;hp=7724c14b8230434899f8bb9917ec5d2854975191;hpb=e430e9baabcde0c5ee373928ffb363bb452f6bb7;p=plomrogue diff --git a/src/server/ai.c b/src/server/ai.c index 7724c14..75b4b89 100644 --- a/src/server/ai.c +++ b/src/server/ai.c @@ -19,6 +19,28 @@ * "pos_i"'s redundancy.). "max_score" is written into "neighbor_scores" for * illegal directions (that from "pos_yx" would lead beyond the map's border). */ +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); + +/* Iterate over scored cells in "score_map" of world.map's 2D geometry. Compare + * each cell's score against the scores of its immediate neighbors in "dirs" + * directions; if at least one of these is lower, re-set the current cell's + * score to one higher than its lowest neighbor score. Repeat this whole process + * until all cells have settled on their final score. Ignore cells whose + * position in "score_map" fits a non-island cell in world.map.cells. Expect + * "max_score" to be the maximum score for cells, marking them as unreachable. + */ +static void dijkstra_map(char * dirs, uint8_t * score_map, uint8_t max_score); + +/* Return char of direction ("N", "E", "S" or "W") of enemy with the shortest + * path to "mo_target". If no enemy is around, return 0. + */ +static char get_dir_to_nearest_enemy(struct MapObj * mo_target); + + + 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, @@ -49,14 +71,6 @@ static void get_neighbor_scores(char * dirs, uint8_t len_dirs, -/* Iterate over scored cells in "score_map" of world.map's 2D geometry. Compare - * each cell's score against the scores of its immediate neighbors in "dirs" - * directions; if at least one of these is lower, re-set the current cell's - * score to one higher than its lowest neighbor score. Repeat this whole process - * until all cells have settled on their final score. Ignore cells whose - * position in "score_map" fits a non-island cell in world.map.cells. Expect - * "max_score" to be the maximum score for cells, marking them as unreachable. - */ static void dijkstra_map(char * dirs, uint8_t * score_map, uint8_t max_score) { uint8_t len_dirs = strlen(dirs); @@ -98,9 +112,6 @@ static void dijkstra_map(char * dirs, uint8_t * score_map, uint8_t max_score) -/* Return char of direction ("N", "E", "S" or "W") of enemy with the shortest - * path to "mo_target". If no enemy is around, return 0. - */ static char get_dir_to_nearest_enemy(struct MapObj * mo_target) { /* Calculate for each cell the distance to the nearest map actor that is