The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
candidates.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Bartosz Waresiak <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * Defines formula ai candidate actions - headers
18  * */
19 
20 #ifndef AI_FORMULA_CANDIDATES_HPP_INCLUDED
21 #define AI_FORMULA_CANDIDATES_HPP_INCLUDED
22 
23 #include <set>
24 
25 class unit_map;
26 class config;
27 
28 namespace ai {
29 class formula_ai;
30 }
31 
32 namespace game_logic {
33 
35 
36 typedef std::map< std::string, game_logic::const_formula_ptr > candidate_action_filters;
38 
39 //every new candidate action type should be derived from this class
40 //and should complete evaluate and update_callable_map methods
42 public:
43  base_candidate_action(const std::string& name, const std::string& type,const config& cfg, function_symbol_table* function_table);
44 
46 
47  //evaluate candidate action using eval_ formula
48  virtual void evaluate(ai::formula_ai* /*ai*/, unit_map& /*units*/) {}
49 
50  //adds needed callable objects to callable map
52 
53 
54  //return score of last evaluation
55  int get_score() const {return score_;}
56 
58 
59  const std::string& get_name() const { return name_;}
60  const std::string& get_type() const { return type_;}
61 
62 protected:
64  const game_logic::formula_callable& callable, const ai::formula_ai* ai);
65 
70  int score_;
71 };
72 
73 
75 public:
77 protected:
79 
81 };
82 
84 public:
85  move_candidate_action(const std::string& name, const std::string& type,const config& cfg, function_symbol_table* function_table);
86 
87  virtual void evaluate(ai::formula_ai* ai, unit_map& units);
88 
90 
91 protected:
93 };
94 
96 public:
97  attack_candidate_action(const std::string& name, const std::string& type,const config& cfg, function_symbol_table* function_table);
98 
99  virtual void evaluate(ai::formula_ai* ai, unit_map& units);
100 
102 protected:
105 };
106 
107 }
108 
109 #endif /* AI_FORMULA_CANDIDATES_HPP_INCLUDED */
110 
const std::string & get_type() const
Definition: candidates.hpp:60
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
GLenum GLenum GLenum input
Definition: glew.h:10668
boost::shared_ptr< game_logic::base_candidate_action > candidate_action_ptr
Definition: candidates.hpp:37
variant do_filtering(ai::formula_ai *ai, variant &input, game_logic::const_formula_ptr formula)
Definition: candidates.cpp:77
move_candidate_action(const std::string &name, const std::string &type, const config &cfg, function_symbol_table *function_table)
Definition: candidates.cpp:87
virtual void update_callable_map(game_logic::map_formula_callable &callable)
Definition: candidates.cpp:138
game_logic::candidate_action_filters filter_map_
Definition: candidates.hpp:80
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:57
int execute_formula(const const_formula_ptr &formula, const game_logic::formula_callable &callable, const ai::formula_ai *ai)
Definition: candidates.cpp:41
base_candidate_action(const std::string &name, const std::string &type, const config &cfg, function_symbol_table *function_table)
Definition: candidates.cpp:31
std::map< std::string, game_logic::const_formula_ptr > candidate_action_filters
Definition: candidates.hpp:34
virtual void evaluate(ai::formula_ai *ai, unit_map &units)
Definition: candidates.cpp:94
candidate_action_with_filters(const std::string &name, const std::string &type, const config &cfg, function_symbol_table *function_table)
Definition: candidates.cpp:58
const_formula_ptr & get_action()
Definition: candidates.hpp:57
virtual void evaluate(ai::formula_ai *, unit_map &)
Definition: candidates.hpp:48
const std::string & get_name() const
Definition: candidates.hpp:59
GLuint const GLchar * name
Definition: glew.h:1782
virtual void update_callable_map(game_logic::map_formula_callable &)
Definition: candidates.hpp:51
Container associating units to locations.
Definition: map.hpp:90
attack_candidate_action(const std::string &name, const std::string &type, const config &cfg, function_symbol_table *function_table)
Definition: candidates.cpp:143
virtual void evaluate(ai::formula_ai *ai, unit_map &units)
Definition: candidates.cpp:151
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
virtual void update_callable_map(game_logic::map_formula_callable &callable)
Definition: candidates.cpp:246
GLsizei const GLcharARB ** string
Definition: glew.h:4503
unit_map * units
Definition: resources.cpp:35