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 #ifndef AI_DEFAULT_AI_HPP_INCLUDED
00019 #define AI_DEFAULT_AI_HPP_INCLUDED
00020
00021 #include "../interface.hpp"
00022 #include "../composite/stage.hpp"
00023
00024 #ifdef _MSC_VER
00025 #pragma warning(push)
00026
00027 #pragma warning(disable:4250)
00028 #endif
00029
00030
00031 namespace pathfind {
00032
00033 struct plain_route;
00034
00035 }
00036
00037
00038 namespace ai {
00039
00040 class formula_ai;
00041
00042
00043 class idle_ai : public readwrite_context_proxy, public interface {
00044 public:
00045 idle_ai(readwrite_context &context, const config &cfg);
00046 void play_turn();
00047 void new_turn();
00048 std::string describe_self() const;
00049 void switch_side(side_number side);
00050 int get_recursion_count() const;
00051 virtual config to_config() const;
00052 private:
00053 const config &cfg_;
00054 recursion_counter recursion_counter_;
00055 };
00056
00057 class ai_default_recruitment_stage : public stage {
00058 public:
00059 ai_default_recruitment_stage(ai_context &context, const config &cfg);
00060 virtual ~ai_default_recruitment_stage();
00061 void on_create();
00062 bool do_play_stage();
00063 config to_config() const;
00064 int get_combat_score(const unit_type& ut) const;
00065
00066 private:
00067
00068 void get_combat_score_vs(const unit_type& ut, const std::string &enemy_type_id, int &score, int &weighting, int hitpoints, int max_hitpoints) const;
00069
00070 virtual bool recruit_usage(const std::string& usage);
00071
00072
00073 class recruit_situation_change_observer : public events::observer {
00074 public:
00075 recruit_situation_change_observer();
00076 ~recruit_situation_change_observer();
00077
00078 void handle_generic_event(const std::string& );
00079
00080 bool get_valid();
00081 void set_valid(bool valid);
00082 private:
00083 bool valid_;
00084
00085 };
00086
00087
00088
00089
00090 void analyze_all();
00091
00092
00093
00094
00095
00096
00097
00098
00099 virtual void analyze_potential_recruit_movements();
00100
00101 std::string find_suitable_recall_id();
00102
00103 std::map<std::string,int> best_usage_;
00104
00105 config cfg_;
00106
00107 std::map<std::string,int> maximum_counts_;
00108
00109 std::set<std::string> not_recommended_units_;
00110
00111 std::vector<std::pair<std::string,double> > recall_list_scores_;
00112
00113 recruit_situation_change_observer recruit_situation_change_observer_;
00114
00115 std::map<std::string,int> unit_combat_scores_;
00116
00117 std::map<std::string,int> unit_movement_scores_;
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 virtual void analyze_potential_recruit_combat();
00128
00129
00130 bool analyze_recall_list();
00131
00132
00133
00134
00135
00136
00137
00138 virtual int compare_unit_types(const unit_type& a, const unit_type& b) const;
00139
00140
00141
00142
00143
00144 virtual int average_resistance_against(const unit_type& a, const unit_type& b) const;
00145
00146
00147 };
00148
00149 }
00150
00151 #ifdef _MSC_VER
00152 #pragma warning(pop)
00153 #endif
00154
00155
00156 #endif