Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AI_TESTING_CA_HPP_INCLUDED
00023 #define AI_TESTING_CA_HPP_INCLUDED
00024
00025 #include "../../unit_map.hpp"
00026
00027 #include "../composite/rca.hpp"
00028
00029
00030 #ifdef _MSC_VER
00031 #pragma warning(push)
00032
00033 #pragma warning(disable:4250)
00034 #endif
00035
00036 namespace ai {
00037
00038 namespace testing_ai_default {
00039
00040
00041
00042 class goto_phase : public candidate_action {
00043 public:
00044
00045 goto_phase( rca_context &context, const config &cfg );
00046
00047 virtual ~goto_phase();
00048
00049 virtual double evaluate();
00050
00051 virtual void execute();
00052 private:
00053 move_result_ptr move_;
00054 };
00055
00056
00057
00058 class aspect_recruitment_phase : public candidate_action {
00059 public:
00060
00061 aspect_recruitment_phase( rca_context &context, const config &cfg );
00062
00063 virtual ~aspect_recruitment_phase();
00064
00065 virtual double evaluate();
00066
00067 virtual void execute();
00068 };
00069
00070
00071
00072 class recruitment_phase : public candidate_action {
00073 public:
00074
00075 recruitment_phase( rca_context &context, const config &cfg );
00076
00077 virtual ~recruitment_phase();
00078
00079 virtual double evaluate();
00080
00081 virtual void execute();
00082
00083 private:
00084
00085 bool recruit_usage(const std::string& usage);
00086
00087 std::map<std::string,int> unit_movement_scores_;
00088 std::set<std::string> not_recommended_units_;
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 void analyze_potential_recruit_combat();
00099
00100 std::map<std::string,int> unit_combat_scores_;
00101
00102
00103
00104
00105
00106
00107
00108 int compare_unit_types(const unit_type& a, const unit_type& b) const;
00109
00110
00111
00112
00113
00114 int average_resistance_against(const unit_type& a, const unit_type& b) const;
00115 };
00116
00117
00118
00119 class combat_phase : public candidate_action {
00120 public:
00121
00122 combat_phase( rca_context &context, const config &cfg );
00123
00124 virtual ~combat_phase();
00125
00126 virtual double evaluate();
00127
00128 virtual void execute();
00129 private:
00130 attack_analysis best_analysis_;
00131 double choice_rating_;
00132
00133 };
00134
00135
00136
00137 class move_leader_to_goals_phase : public candidate_action {
00138 public:
00139
00140 move_leader_to_goals_phase( rca_context &context, const config &cfg );
00141
00142 virtual ~move_leader_to_goals_phase();
00143
00144 virtual double evaluate();
00145
00146 virtual void execute();
00147 private:
00148
00149 void remove_goal(const std::string &id);
00150
00151 bool auto_remove_;
00152 map_location dst_;
00153 std::string id_;
00154 move_result_ptr move_;
00155 };
00156
00157
00158
00159 class move_leader_to_keep_phase : public candidate_action {
00160 public:
00161
00162 move_leader_to_keep_phase( rca_context &context, const config &cfg );
00163
00164 virtual ~move_leader_to_keep_phase();
00165
00166 virtual double evaluate();
00167
00168 virtual void execute();
00169
00170 private:
00171 move_result_ptr move_;
00172 };
00173
00174
00175
00176 class get_villages_phase : public candidate_action {
00177 public:
00178
00179 get_villages_phase( rca_context &context, const config& cfg );
00180
00181 virtual ~get_villages_phase();
00182
00183 virtual double evaluate();
00184
00185 virtual void execute();
00186 private:
00187
00188 map_location keep_loc_;
00189
00190
00191 map_location leader_loc_;
00192
00193
00194 map_location best_leader_loc_;
00195
00196
00197 bool debug_;
00198
00199 typedef std::map<map_location ,
00200 std::vector<map_location > > treachmap;
00201
00202 typedef std::vector<std::pair<map_location ,
00203 map_location > > tmoves;
00204
00205
00206
00207 tmoves moves_;
00208
00209
00210
00211 void dispatch(treachmap& reachmap, tmoves& moves);
00212
00213
00214
00215
00216
00217
00218 bool dispatch_unit_simple(treachmap& reachmap, tmoves& moves);
00219
00220
00221
00222
00223
00224
00225 bool dispatch_village_simple(
00226 treachmap& reachmap, tmoves& moves, size_t& village_count);
00227
00228
00229
00230 bool remove_village(
00231 treachmap& reachmap, tmoves& moves, const map_location& village);
00232
00233
00234
00235 treachmap::iterator remove_unit(
00236 treachmap& reachmap, tmoves& moves, treachmap::iterator unit);
00237
00238
00239
00240 void dispatch_complex(
00241 treachmap& reachmap, tmoves& moves, const size_t village_count);
00242
00243
00244
00245 void full_dispatch(treachmap& reachmap, tmoves& moves);
00246
00247
00248
00249 void dump_reachmap(treachmap& reachmap);
00250
00251
00252 void get_villages(
00253 const move_map &dstsrc, const move_map &enemy_dstsrc,
00254 unit_map::const_iterator &leader);
00255
00256
00257 void find_villages(
00258 treachmap& reachmap,
00259 tmoves& moves,
00260 const std::multimap<map_location,map_location>& dstsrc,
00261 const std::multimap<map_location,map_location>& enemy_dstsrc);
00262
00263 };
00264
00265
00266
00267 class get_healing_phase : public candidate_action {
00268 public:
00269
00270 get_healing_phase( rca_context &context, const config& cfg );
00271
00272 virtual ~get_healing_phase();
00273
00274 virtual double evaluate();
00275
00276 virtual void execute();
00277 private:
00278
00279 move_result_ptr move_;
00280 };
00281
00282
00283
00284 class retreat_phase : public candidate_action {
00285 public:
00286
00287 retreat_phase( rca_context &context, const config &cfg );
00288
00289 virtual ~retreat_phase();
00290
00291 virtual double evaluate();
00292
00293 virtual void execute();
00294 private:
00295
00296 bool should_retreat(const map_location& loc, const unit_map::const_iterator& un, const move_map &srcdst, const move_map &dstsrc, double caution);
00297
00298 move_result_ptr move_;
00299
00300 };
00301
00302
00303
00304 class simple_move_and_targeting_phase : public candidate_action {
00305 public:
00306
00307 simple_move_and_targeting_phase( rca_context &context, const config &cfg );
00308
00309 virtual ~simple_move_and_targeting_phase();
00310
00311 virtual double evaluate();
00312
00313 virtual void execute();
00314
00315 private:
00316
00317 move_result_ptr move_;
00318 };
00319
00320
00321
00322
00323 class leader_control_phase : public candidate_action {
00324 public:
00325
00326 leader_control_phase( rca_context &context, const config &cfg );
00327
00328 virtual ~leader_control_phase();
00329
00330 virtual double evaluate();
00331
00332 virtual void execute();
00333 };
00334
00335
00336
00337 class passive_leader_shares_keep_phase : public candidate_action {
00338 public:
00339
00340 passive_leader_shares_keep_phase( rca_context &context, const config &cfg );
00341
00342 virtual ~passive_leader_shares_keep_phase();
00343
00344 virtual double evaluate();
00345
00346 virtual void execute();
00347 };
00348
00349
00350 }
00351
00352 }
00353
00354 #ifdef _MSC_VER
00355 #pragma warning(pop)
00356 #endif
00357
00358 #endif