The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ca_move_to_targets.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Yurii Chernyi <[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  * Strategic movement routine, for experimentation
18  */
19 
20 #ifndef AI_TESTING_CA_TESTING_MOVE_TO_TARGETS_HPP_INCLUDED
21 #define AI_TESTING_CA_TESTING_MOVE_TO_TARGETS_HPP_INCLUDED
22 
23 #include "ai/composite/rca.hpp"
24 
25 #include "units/map.hpp"
26 
27 #ifdef _MSC_VER
28 #pragma warning(push)
29 //silence "inherits via dominance" warnings
30 #pragma warning(disable:4250)
31 #endif
32 
33 namespace pathfind {
34 
35 struct plain_route;
36 
37 } //of namespace pathfind
38 
39 namespace ai {
40 
41 namespace ai_default_rca {
42 
44 public:
45 
46  move_to_targets_phase( rca_context &context, const config &cfg );
47 
48  virtual ~move_to_targets_phase();
49 
50  virtual double evaluate();
51 
52  virtual void execute();
53 
54 protected:
55  void access_points(const move_map& srcdst, const map_location& u, const map_location& dst, std::vector<map_location>& out);
56 
57  std::pair<map_location,map_location> choose_move(std::vector<target>& targets, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc);
58 
59  double compare_groups(const std::set<map_location>& our_group, const std::set<map_location>& their_group, const std::vector<map_location>& battlefield) const;
60 
61  void enemies_along_path(const std::vector<map_location>& route, const move_map& dstsrc, std::set<map_location>& res);
62 
63  map_location form_group(const std::vector<map_location>& route, const move_map& dstsrc, std::set<map_location>& res);
64 
65  bool move_group(const map_location& dst, const std::vector<map_location>& route, const std::set<map_location>& units);
66 
67  double rate_group(const std::set<map_location>& group, const std::vector<map_location>& battlefield) const;
68 
69  /**
70  * rate a target, but can also return the maximal possible rating
71  * by passing a dummy route
72  */
73  double rate_target(const target& tg, const unit_map::iterator& u,
74  const move_map& dstsrc, const move_map& enemy_dstsrc,
75  const pathfind::plain_route& rt);
76 
77  bool should_retreat(const map_location& loc, const unit_map::const_iterator& un,
78  const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc,
79  double caution);
80 };
81 
82 } // of namespace testing_ai_default
83 
84 } // of namespace ai
85 
86 #ifdef _MSC_VER
87 #pragma warning(pop)
88 #endif
89 
90 #endif
map_location form_group(const std::vector< map_location > &route, const move_map &dstsrc, std::set< map_location > &res)
move_to_targets_phase(rca_context &context, const config &cfg)
std::multimap< map_location, map_location > move_map
The standard way in which a map of possible moves is recorded.
Definition: game_info.hpp:47
std::pair< map_location, map_location > choose_move(std::vector< target > &targets, const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_dstsrc)
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:57
virtual double evaluate()
Evaluate the candidate action, resetting the internal state of the action.
Structure which holds a single route between one location and another.
Definition: pathfind.hpp:132
GLenum GLenum dst
Definition: glew.h:2392
double rate_group(const std::set< map_location > &group, const std::vector< map_location > &battlefield) const
Encapsulates the map of the game.
Definition: location.hpp:38
GLuint res
Definition: glew.h:9258
double rate_target(const target &tg, const unit_map::iterator &u, const move_map &dstsrc, const move_map &enemy_dstsrc, const pathfind::plain_route &rt)
rate a target, but can also return the maximal possible rating by passing a dummy route ...
void enemies_along_path(const std::vector< map_location > &route, const move_map &dstsrc, std::set< map_location > &res)
bool move_group(const map_location &dst, const std::vector< map_location > &route, const std::set< map_location > &units)
GLboolean GLuint group
Definition: glew.h:2589
double compare_groups(const std::set< map_location > &our_group, const std::set< map_location > &their_group, const std::vector< map_location > &battlefield) const
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
bool should_retreat(const map_location &loc, const unit_map::const_iterator &un, const move_map &srcdst, const move_map &dstsrc, const move_map &enemy_dstsrc, double caution)
unit_map * units
Definition: resources.cpp:35
void access_points(const move_map &srcdst, const map_location &u, const map_location &dst, std::vector< map_location > &out)
candidate action framework
virtual void execute()
Execute the candidate action.