Author: esr
Date: Thu Oct 23 08:49:13 2008
New Revision: 30331

URL: http://svn.gna.org/viewcvs/wesnoth?rev=30331&view=rev
Log:
Merge in suokko's method of evaluating recruitment value for a leader
not on a keep, because this may be useful to enable an decision that a
leader should move to a keep in order to recruit rather than fighting.

Modified:
    trunk/src/ai.cpp

Modified: trunk/src/ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai.cpp?rev=30331&r1=30330&r2=30331&view=diff
==============================================================================
--- trunk/src/ai.cpp (original)
+++ trunk/src/ai.cpp Thu Oct 23 08:49:13 2008
@@ -992,14 +992,20 @@
        }
 
        float free_slots = 0.0f;
+       const float gold = current_team().gold();
+       const float unit_price = current_team().average_recruit_price();
        if (map_.is_keep(leader->first))
        {
                std::set<location> checked_hexes;
                checked_hexes.insert(leader->first);
                free_slots = count_free_hexes_in_castle(leader->first, 
checked_hexes);
-       }
-       const float gold = current_team().gold();
-       const float unit_price = current_team().average_recruit_price();
+       } else {
+               map_location loc = nearest_keep(leader->first);
+               if (units_.find(loc) == units_.end() && gold/unit_price > 1.0f)
+               {
+                       free_slots -= 
current_team().num_pos_recruits_to_force();
+               }
+       }
        recruiting_preferred_ = (gold/unit_price) - free_slots > 
current_team().num_pos_recruits_to_force();
        DBG_AI << "recruiting preferred: " << 
(recruiting_preferred_?"yes":"no") << 
                " units to recruit: " << (gold/unit_price) << 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to