The Battle for Wesnoth  1.15.0-dev
game_info.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.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  * Game information for the AI
18  */
19 
20 #pragma once
21 
22 #include "map/location.hpp"
23 
24 #include <map>
25 #include <memory>
26 
27 namespace pathfind
28 {
29 struct paths;
30 }
31 
32 /**
33  * info is structure which holds references to all the important objects
34  * that an AI might need access to, in order to make and implement its
35  * decisions.
36  */
37 namespace ai
38 {
39 typedef int side_number;
40 
41 /** The standard way in which a map of possible moves is recorded. */
42 typedef std::multimap<map_location, map_location> move_map;
43 
44 /** The standard way in which a map of possible movement routes to location is recorded*/
45 typedef std::map<map_location, pathfind::paths> moves_map;
46 
48 typedef std::unique_ptr<ai_composite> composite_ai_ptr;
49 
51 typedef std::vector<attack_analysis> attacks_vector;
52 
53 template<typename T>
54 class typesafe_aspect;
55 
56 template<typename T>
57 using typesafe_aspect_ptr = std::shared_ptr<typesafe_aspect<T>>;
58 
59 template<typename T>
60 using typesafe_aspect_vector = std::vector<typesafe_aspect_ptr<T>>;
61 
62 template<typename T>
64 
65 template<typename T>
66 using typesafe_known_aspect_ptr = std::shared_ptr<typesafe_known_aspect<T>>;
67 
68 template<typename T>
69 using typesafe_known_aspect_vector = std::vector<typesafe_known_aspect_ptr<T>>;
70 
71 class action_result;
72 class attack_result;
73 class recall_result;
74 class recruit_result;
75 class move_result;
76 class move_and_attack_result;
77 class stopunit_result;
79 
80 typedef std::shared_ptr<action_result> action_result_ptr;
81 typedef std::shared_ptr<attack_result> attack_result_ptr;
82 typedef std::shared_ptr<recall_result> recall_result_ptr;
83 typedef std::shared_ptr<recruit_result> recruit_result_ptr;
84 typedef std::shared_ptr<move_result> move_result_ptr;
85 typedef std::shared_ptr<move_and_attack_result> move_and_attack_result_ptr;
86 typedef std::shared_ptr<stopunit_result> stopunit_result_ptr;
87 typedef std::shared_ptr<synced_command_result> synced_command_result_ptr;
88 
89 class aspect;
90 class candidate_action;
91 class engine;
92 class goal;
93 class known_aspect;
94 class stage;
95 
96 typedef std::shared_ptr<aspect> aspect_ptr;
97 typedef std::shared_ptr<candidate_action> candidate_action_ptr;
98 typedef std::shared_ptr<engine> engine_ptr;
99 typedef std::shared_ptr<goal> goal_ptr;
100 typedef std::shared_ptr<known_aspect> known_aspect_ptr;
101 typedef std::shared_ptr<stage> stage_ptr;
102 
103 typedef std::map<std::string, aspect_ptr> aspect_map;
104 typedef std::map<std::string, known_aspect_ptr> known_aspect_map;
105 
107 {
108 public:
110  : recent_attacks()
111  {
112  }
113 
114  std::set<map_location> recent_attacks;
115 };
116 
117 } // of namespace ai
std::shared_ptr< action_result > action_result_ptr
Definition: game_info.hpp:78
std::shared_ptr< candidate_action > candidate_action_ptr
Definition: rca.hpp:141
std::unique_ptr< ai_composite > composite_ai_ptr
Definition: game_info.hpp:47
std::shared_ptr< stage > stage_ptr
Definition: game_info.hpp:101
std::shared_ptr< stopunit_result > stopunit_result_ptr
Definition: game_info.hpp:86
std::vector< typesafe_known_aspect_ptr< T > > typesafe_known_aspect_vector
Definition: game_info.hpp:69
std::shared_ptr< known_aspect > known_aspect_ptr
Definition: game_info.hpp:100
std::shared_ptr< move_result > move_result_ptr
Definition: game_info.hpp:84
std::shared_ptr< recruit_result > recruit_result_ptr
Definition: game_info.hpp:83
std::shared_ptr< attack_result > attack_result_ptr
Definition: game_info.hpp:81
std::shared_ptr< aspect > aspect_ptr
Definition: game_info.hpp:94
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
std::vector< attack_analysis > attacks_vector
Definition: game_info.hpp:50
std::map< map_location, pathfind::paths > moves_map
The standard way in which a map of possible movement routes to location is recorded.
Definition: game_info.hpp:45
A small explanation about what&#39;s going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:58
std::shared_ptr< typesafe_aspect< T > > typesafe_aspect_ptr
Definition: game_info.hpp:57
std::shared_ptr< recall_result > recall_result_ptr
Definition: game_info.hpp:82
std::shared_ptr< typesafe_known_aspect< T > > typesafe_known_aspect_ptr
Definition: game_info.hpp:66
std::shared_ptr< goal > goal_ptr
Definition: game_info.hpp:99
std::shared_ptr< synced_command_result > synced_command_result_ptr
Definition: game_info.hpp:87
std::map< std::string, known_aspect_ptr > known_aspect_map
Definition: game_info.hpp:104
std::shared_ptr< move_and_attack_result > move_and_attack_result_ptr
Definition: game_info.hpp:85
std::set< map_location > recent_attacks
Definition: game_info.hpp:114
std::map< std::string, aspect_ptr > aspect_map
Definition: game_info.hpp:103
int side_number
Definition: game_info.hpp:39
std::shared_ptr< engine > engine_ptr
Definition: game_info.hpp:98
std::vector< typesafe_aspect_ptr< T > > typesafe_aspect_vector
Definition: game_info.hpp:60