The Battle for Wesnoth  1.15.0-dev
ca_move_to_targets.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2018 by Yurii Chernyi <terraninfo@terraninfo.net>
3  Part of the Battle for Wesnoth Project https://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 #pragma once
21 
22 #include "ai/composite/rca.hpp"
23 
24 #include "units/map.hpp"
25 
26 namespace pathfind {
27 
28 struct plain_route;
29 
30 } //of namespace pathfind
31 
32 namespace ai {
33 
34 namespace ai_default_rca {
35 
37 public:
38 
39  move_to_targets_phase( rca_context &context, const config &cfg );
40 
41  virtual ~move_to_targets_phase();
42 
43  virtual double evaluate();
44 
45  virtual void execute();
46 
47 protected:
48  void access_points(const move_map& srcdst, const map_location& u, const map_location& dst, std::vector<map_location>& out);
49 
50  std::pair<map_location,map_location> choose_move(std::vector<target>& targets);
51 
52  double compare_groups(const std::set<map_location>& our_group, const std::set<map_location>& their_group, const std::vector<map_location>& battlefield) const;
53 
54  void enemies_along_path(const std::vector<map_location>& route, const move_map& dstsrc, std::set<map_location>& res);
55 
56  map_location form_group(const std::vector<map_location>& route, const move_map& dstsrc, std::set<map_location>& res);
57 
58  bool move_group(const map_location& dst, const std::vector<map_location>& route, const std::set<map_location>& units);
59 
60  double rate_group(const std::set<map_location>& group, const std::vector<map_location>& battlefield) const;
61 
62  /**
63  * rate a target, but can also return the maximal possible rating
64  * by passing a dummy route
65  */
66  double rate_target(const target& tg, const unit_map::iterator& u,
67  const move_map& dstsrc, const move_map& enemy_dstsrc,
68  const pathfind::plain_route& rt);
69 
70  bool should_retreat(const map_location& loc, const unit_map::const_iterator& un,
71  const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc,
72  double caution);
73 };
74 
75 } // of namespace testing_ai_default
76 
77 } // of namespace ai
std::multimap< map_location, map_location > move_map
The standard way in which a map of possible moves is recorded.
Definition: game_info.hpp:42
A small explanation about what&#39;s going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:58
Structure which holds a single route between one location and another.
Definition: pathfind.hpp:131
Encapsulates the map of the game.
Definition: location.hpp:42
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
candidate action framework