mail[Wesnoth-commits] r40396 - in /trunk/src/ai: contexts.cpp default/contexts.cpp default/contexts.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by terraninfo on December 25, 2009 - 13:15:
Author: crab
Date: Fri Dec 25 13:15:36 2009
New Revision: 40396

URL: http://svn.gna.org/viewcvs/wesnoth?rev=40396&view=rev
Log:
Handle the things that were exposed by patch #1379, and reschedule todos

Modified:
    trunk/src/ai/contexts.cpp
    trunk/src/ai/default/contexts.cpp
    trunk/src/ai/default/contexts.hpp

Modified: trunk/src/ai/contexts.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/contexts.cpp?rev=40396&r1=40395&r2=40396&view=diff
==============================================================================
--- trunk/src/ai/contexts.cpp (original)
+++ trunk/src/ai/contexts.cpp Fri Dec 25 13:15:36 2009
@@ -475,7 +475,7 @@
 int readonly_context_impl::get_attack_depth() const
 {
        if (attack_depth_) {
-               return std::max<int>(1,attack_depth_->get()); //@todo 1.7: 
add minmax filter to attack_depth aspect
+               return std::max<int>(1,attack_depth_->get()); //@todo 1.9: 
add validators, such as minmax filters to aspects
        }
        return 1;
 }
@@ -508,7 +508,7 @@
        if (attacks_) {
                return attacks_->get_variant();
        }
-       static variant v;//@todo: replace with variant::null_variant;
+       static variant v;//@todo 1.9: replace with variant::null_variant;
        return v;
 }
 
@@ -704,7 +704,7 @@
 const std::vector<unit>& readonly_context_impl::get_recall_list() const
 {
        static std::vector<unit> dummy_units;
-       //@todo: check for (level_["disallow_recall"]))
+       //@todo 1.9: check for (level_["disallow_recall"]))
        if(!current_team().persistent()) {
                return dummy_units;
        }
@@ -1056,7 +1056,7 @@
                                        ++i;
                                }
                        }
-               //@todo: shall possible moves be modified as well ?
+               //@todo 1.9: shall possible moves be modified as well ?
                }
        }
        move_maps_valid_ = true;
@@ -1079,26 +1079,26 @@
        }
 
        map_location const* best_free_keep = &map_location::null_location;
-       double cost_to_best_free_keep = 0.0;
+       double move_left_at_best_free_keep = 0.0;
 
        map_location const* best_occupied_keep = &map_location::null_location;
-       double cost_to_best_occupied_keep = 0.0;
+       double move_left_at_best_occupied_keep = 0.0;
 
        foreach (const paths::step &dest, leader_paths.destinations)
        {
                const map_location &loc = dest.curr;
                if (keeps().find(loc)!=keeps().end()){
-                       //@todo 1.7 move_left for 1-turn-moves is really 
"cost_to_get_there", it is just not renamed there yet. see r34430 for more 
detais.
-                       const int cost_to_loc = dest.move_left;
+
+                       const int move_left_at_loc = dest.move_left;
                        if (get_info().units.count(loc) == 0) {
-                               if 
((*best_free_keep==map_location::null_location)||(cost_to_loc<cost_to_best_free_keep)){
+                               if 
((*best_free_keep==map_location::null_location)||(move_left_at_loc>move_left_at_best_free_keep)){
                                        best_free_keep = &loc;
-                                       cost_to_best_free_keep = cost_to_loc;
+                                       move_left_at_best_free_keep = 
move_left_at_loc;
                                }
                        } else {
-                               if 
((*best_occupied_keep==map_location::null_location)||(cost_to_loc<cost_to_best_occupied_keep)){
+                               if 
((*best_occupied_keep==map_location::null_location)||(move_left_at_loc>move_left_at_best_occupied_keep)){
                                        best_occupied_keep = &loc;
-                                       cost_to_best_occupied_keep = 
cost_to_loc;
+                                       move_left_at_best_occupied_keep = 
move_left_at_loc;
                                }
                        }
                }

Modified: trunk/src/ai/default/contexts.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/default/contexts.cpp?rev=40396&r1=40395&r2=40396&view=diff
==============================================================================
--- trunk/src/ai/default/contexts.cpp (original)
+++ trunk/src/ai/default/contexts.cpp Fri Dec 25 13:15:36 2009
@@ -173,49 +173,6 @@
        return rating;
 }
 
-const map_location& default_ai_context_impl::suitable_keep(const 
map_location& leader_location, const paths& leader_paths){
-       if (get_info().map.is_keep(leader_location)) {
-               return leader_location; //if leader already on keep, then 
return leader_location
-       }
-
-       map_location const* best_free_keep = &map_location::null_location;
-       double cost_to_best_free_keep = 0.0;
-
-       map_location const* best_occupied_keep = &map_location::null_location;
-       double cost_to_best_occupied_keep = 0.0;
-
-       foreach (const paths::step &dest, leader_paths.destinations)
-       {
-               const map_location &loc = dest.curr;
-               if (keeps().find(loc)!=keeps().end()){
-                       //@todo 1.7 move_left for 1-turn-moves is really 
"cost_to_get_there", it is just not renamed there yet. see r34430 for more 
detais.
-                       const int cost_to_loc = dest.move_left;
-                       if (get_info().units.count(loc) == 0) {
-                               if 
((*best_free_keep==map_location::null_location)||(cost_to_loc<cost_to_best_free_keep)){
-                                       best_free_keep = &loc;
-                                       cost_to_best_free_keep = cost_to_loc;
-                               }
-                       } else {
-                               if 
((*best_occupied_keep==map_location::null_location)||(cost_to_loc<cost_to_best_occupied_keep)){
-                                       best_occupied_keep = &loc;
-                                       cost_to_best_occupied_keep = 
cost_to_loc;
-                               }
-                       }
-               }
-       }
-
-       if (*best_free_keep != map_location::null_location){
-               return *best_free_keep; // if there is a free keep reachable 
during current turn, return it
-       }
-
-       if (*best_occupied_keep != map_location::null_location){
-               return *best_occupied_keep; // if there is an occupied keep 
reachable during current turn, return it
-       }
-
-       return nearest_keep(leader_location); // return nearest keep
-}
-
-
 std::vector<target> 
default_ai_context_impl::find_targets(unit_map::const_iterator leader, const 
move_map& enemy_dstsrc)
 {
        log_scope2(log_ai, "finding targets...");

Modified: trunk/src/ai/default/contexts.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/default/contexts.hpp?rev=40396&r1=40395&r2=40396&view=diff
==============================================================================
--- trunk/src/ai/default/contexts.hpp (original)
+++ trunk/src/ai/default/contexts.hpp Fri Dec 25 13:15:36 2009
@@ -246,11 +246,6 @@
        }
 
 
-       virtual const map_location& suitable_keep( const map_location& 
leader_location, const paths& leader_paths )
-       {
-               return target_->suitable_keep(leader_location,leader_paths);
-       }
-
        virtual config to_default_ai_context_config() const
        {
                return target_->to_default_ai_context_config();
@@ -307,14 +302,11 @@
        virtual int rate_terrain(const unit& u, const map_location& loc) 
const;
 
 
-       virtual const map_location& suitable_keep( const map_location& 
leader_location, const paths& leader_paths );
-
-
        virtual config to_default_ai_context_config() const;
 
 private:
        recursion_counter recursion_counter_;
-       mutable std::vector<target> additional_targets_;//@todo: refactor this
+       mutable std::vector<target> additional_targets_;//@todo 1.9 refactor 
this
 
 
 };




Related Messages


Powered by MHonArc, Updated Fri Dec 25 13:20:11 2009