102 const std::string&
get_type()
const;
150 bool is_duplicate(
const std::string &name);
157 static factory_map *candidate_action_factories;
158 if (candidate_action_factories==
nullptr) {
159 candidate_action_factories =
new factory_map;
161 return *candidate_action_factories;
164 virtual candidate_action_ptr get_new_instance(
rca_context &context,
const config &cfg ) = 0;
168 if (is_duplicate(name)) {
171 factory_ptr ptr_to_this(
this);
172 get_list().emplace(name,ptr_to_this);
178 template<
class CANDIDATE_ACTION>
187 return std::make_shared<CANDIDATE_ACTION>(ai, cfg);
static factory_map & get_list()
std::shared_ptr< unit_filter > get_filter_own() const
Get the unit filter for allowed units for this candidate action.
std::shared_ptr< candidate_action > candidate_action_ptr
This class represents a single unit of a specific type.
std::shared_ptr< unit_filter > filter_own_
virtual std::string get_engine() const
const std::string & get_type() const
Get the type of the candidate action (useful for debug purposes)
std::ostream & operator<<(std::ostream &s, const ai::candidate_action &ca)
virtual std::string get_id() const
A small explanation about what's going on here: Each action has access to two game_info objects First...
virtual candidate_action_ptr get_new_instance(rca_context &ai, const config &cfg)
bool is_enabled() const
Is this candidate action enabled ?
recursion_counter recursion_counter_
bool is_allowed_unit(const unit &u) const
Flag indicating whether unit may be used by this candidate action.
A component of the AI framework.
candidate_action_factory(const std::string &name)
void enable()
Enable the candidate action.
virtual void set_to_be_removed()
virtual bool to_be_removed()
double get_max_score() const
Get the upper bound of the score of the candidate action without re-evaluation.
static const double HIGH_SCORE
candidate_action(rca_context &context, const config &cfg)
std::map< std::string, factory_ptr > factory_map
virtual config to_config() const
serialize
static map_location::DIRECTION s
virtual ~candidate_action_factory()
int get_recursion_count() const
Get the value of the recursion counter.
virtual std::string get_name() const
Get the name of the candidate action (useful for debug purposes)
virtual double evaluate()=0
Evaluate the candidate action, resetting the internal state of the action.
void disable()
Disable the candidate action.
std::shared_ptr< candidate_action_factory > factory_ptr
virtual ~candidate_action()
Destructor.
std::pair< const std::string, factory_ptr > factory_map_pair
static const double BAD_SCORE
A config object defines a single node in a WML file, with access to child nodes.
double get_score() const
Get the usual score of the candidate action without re-evaluation.
register_candidate_action_factory(const std::string &name)
virtual void execute()=0
Execute the candidate action.