--- path_finding1.h Mon Apr 8 09:06:55 2002 +++ path_finding2.h Mon Apr 8 10:04:58 2002 @@ -21,9 +21,10 @@ * - turn: obvious * - path: a list of steps which leads from the start to the end * - basic movement cost (BMC): the basic movements costs of the step - * as returned by map_move_cost + * as returned by map_move_cost. Note that the BMC of a step is 0 + * if the target is unknown. * - extra cost (EC): sum of various extra costs (which all have to be >=0) - * - final cost (FC): BMC * PF_BMC_FACTOR + FC + * - final cost (FC): FC = BMC * PF_BMC_FACTOR + EC * - best path: a path which has the minimal FC. If two paths have * equal FC, the path with the minimal turns and if these are equal * too the maximum remaining points at the destination is choosen. @@ -35,6 +36,12 @@ #define PF_BMC_FACTOR 100 /* + * The step is ignored completely if any extra cost or the sum EC is + * larger or equal PF_IGNORE_COST. + */ +#define PF_IGNORE_COST FC_INFINITY + +/* * Maximal number of steps in a path. */ #define MAX_PATH_LENGTH 100 @@ -49,10 +56,10 @@ struct player *owner; /* - * Callback to query the known state of a tile. tile_get_known can - * be used for the client. + * Callback to query the known state of a tile for the given + * player. */ - enum known_type (*get_known)(int , int); + enum known_type (*get_known)(int , int, struct player *); /* * GOTO_MOVE_STRAIGHTEST will set the BMC to constant 1. Even for @@ -61,50 +68,30 @@ enum goto_move_restriction restriction; /* - * If EC is above this value the step is ignored completely. - */ - int extra_cost_cutoff; - - /* - * If the destination tile of a step is fogged these extra costs - * are added to EC. - */ - int fogged_area_extra_cost; - - /* - * If the destination tile of a step is unknown these extra costs - * are added to EC. - * - * Note: For an unknown tile the BMC is 0. So it is a good idea to - * set unknown_area_extra_cost to something >0. - */ - int unknown_area_extra_cost; - - /* - * Passed as third parameter to extra_cost1. + * Passed as last parameter to extra_cost1. */ void *user_data1; /* * Callback which can be used to provide extra costs depending on - * the tile. Can be NULL. Parameter are x, y and user_data1. It - * can be assumed that the implementation of path_finding.h will - * cache this value. + * the tile. Can be NULL. Parameters are x, y, known and + * user_data1. It can be assumed that the implementation of + * path_finding.h will cache this value. */ - int (*extra_cost_1)(int, int, void *); + int (*extra_cost_1)(int, int, enum known_type, void *); /* - * Passed as fourth parameter to extra_cost2. + * Passed as last parameter to extra_cost2. */ void *user_data2; /* * Callback which can be used to provide extra costs depending on * the tile and the moves left of the unit. Can be NULL. Parameter - * are x, y, moves left and user_data2. An implementation of - * path_finding.h may or may not cache this value. + * are x, y, known, moves left and user_data2. An implementation + * of path_finding.h may or may not cache this value. */ - int (*extra_cost_2)(int, int, int, void *); + int (*extra_cost_2)(int, int, enum known_type, int, void *); }; struct pf_path {