Fix plain wrong A* implementation.

The computed value should be an underestimation of the travel
time. Because g+1.3*h is not, A* is not guaranteed to find the best
path (see http://www.wesnoth.org/forum/viewtopic.php?t=4411 for an
example), and it is an understatement...
This commit is contained in:
Guillaume Melquiond 2005-01-27 20:30:51 +00:00
parent a7357f2c0e
commit 97b4eb166b

View file

@ -30,11 +30,11 @@ typedef std::vector<a_star_node*> vector_a_star_node;
typedef std::set<gamemap::location> set_location;
bool compare_strict_sup_a_star_node(const a_star_node* node1, const a_star_node* node2) {
return (node1->g + (1.3 * node1->h) > node2->g + (1.3 * node2->h));
return node1->g + node1->h > node2->g + node2->h;
}
bool compare_sup_equal_a_star_node(const a_star_node* node1, const a_star_node* node2) {
return (node1->g + (1.3 * node1->h) >= node2->g + (1.3 * node2->h));
return node1->g + node1->h >= node2->g + node2->h;
}
void a_star_init(gamemap::location const &src, gamemap::location const &dst,