Author: alink
Date: Fri Apr 3 15:23:00 2009
New Revision: 34430
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34430&view=rev
Log:
Fix a possibly serious breakage of the AI:
The pathfinding 'distance' used by the AI was changed to 'moves left at
destination or 0 if unreachable in 1 turn', thus breaking some target's rating.
This commit revert r32318 and r32310 which are not needed anymore.
I plan to clean this abuse of the name 'move_left' later, but first need to
test this simple fix for possible back-port to 1.6
Modified:
trunk/src/ai_move.cpp
trunk/src/astarsearch.cpp
trunk/src/pathfind.cpp
trunk/src/pathfind.hpp
Modified: trunk/src/ai_move.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai_move.cpp?rev=34430&r1=34429&r2=34430&view=diff
==============================================================================
--- trunk/src/ai_move.cpp (original)
+++ trunk/src/ai_move.cpp Fri Apr 3 15:23:00 2009
@@ -36,8 +36,6 @@
loc_(loc), dstsrc_(dstsrc), enemy_dstsrc_(enemy_dstsrc),
avoid_enemies_(u.usage() == "scout")
{}
-
- virtual int get_max_cost() const { return unit_.movement_left(); };
virtual double cost(const map_location&, const map_location& loc, const
double) const
{
Modified: trunk/src/astarsearch.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/astarsearch.cpp?rev=34430&r1=34429&r2=34430&view=diff
==============================================================================
--- trunk/src/astarsearch.cpp (original)
+++ trunk/src/astarsearch.cpp Fri Apr 3 15:23:00 2009
@@ -197,10 +197,7 @@
locCurNode = locCurNode->nodeParent;
}
std::reverse(locRoute.steps.begin(), locRoute.steps.end());
- int move_left = costCalculator->get_max_cost() -
int(locDestNode->g);
-
- if (move_left > 0)
- locRoute.move_left = move_left;
+ locRoute.move_left = int(locDestNode->g);
assert(locRoute.steps.front() == src);
assert(locRoute.steps.back() == dst);
Modified: trunk/src/pathfind.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind.cpp?rev=34430&r1=34429&r2=34430&view=diff
==============================================================================
--- trunk/src/pathfind.cpp (original)
+++ trunk/src/pathfind.cpp Fri Apr 3 15:23:00 2009
@@ -380,22 +380,12 @@
return unit_.movement_cost(map_[loc]);
}
-int emergency_path_calculator::get_max_cost() const
-{
- return unit_.movement_left();
-}
-
dummy_path_calculator::dummy_path_calculator(const unit&, const gamemap&)
{}
double dummy_path_calculator::cost(const map_location&, const map_location&,
const double) const
{
return 0.0;
-}
-
-int dummy_path_calculator::get_max_cost() const
-{
- return 0;
}
std::ostream& operator << (std::ostream& outstream, const paths::route& rt) {
Modified: trunk/src/pathfind.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind.hpp?rev=34430&r1=34429&r2=34430&view=diff
==============================================================================
--- trunk/src/pathfind.hpp (original)
+++ trunk/src/pathfind.hpp Fri Apr 3 15:23:00 2009
@@ -81,11 +81,6 @@
virtual double cost(const map_location& src, const map_location& loc,
const double so_far) const = 0;
virtual ~cost_calculator() {}
- // This represents the maximum cost that is allowed for a route.
- // Currently there is only one use: Get the remaining movement of units
to calculate the movepoints
- // left at the end of the route.
- virtual int get_max_cost() const { return 0; }
-
inline double getNoPathValue() const { return (42424242.0); }
private:
@@ -162,7 +157,6 @@
bool ignore_unit = false, bool ignore_defense_ =
false);
virtual double cost(const map_location& src, const map_location& loc,
const double so_far) const;
- virtual int get_max_cost() const { return movement_left_; }
private:
unit const &unit_;
team const &viewing_team_;
@@ -183,7 +177,6 @@
{
emergency_path_calculator(const unit& u, const gamemap& map);
virtual double cost(const map_location& src, const map_location& loc,
const double so_far) const;
- virtual int get_max_cost() const;
private:
unit const &unit_;
@@ -198,7 +191,6 @@
{
dummy_path_calculator(const unit& u, const gamemap& map);
virtual double cost(const map_location& src, const map_location& loc,
const double so_far) const;
- virtual int get_max_cost() const;
};
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits