The Battle for Wesnoth  1.19.0-dev
game_info.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  * Game information for the AI
19  */
20 
21 #pragma once
22 
23 #include "map/location.hpp"
24 
25 #include <map>
26 #include <memory>
27 
28 namespace pathfind
29 {
30 struct paths;
31 }
32 
33 /**
34  * info is structure which holds references to all the important objects
35  * that an AI might need access to, in order to make and implement its
36  * decisions.
37  */
38 namespace ai
39 {
40 typedef int side_number;
41 
42 /** The standard way in which a map of possible moves is recorded. */
43 typedef std::multimap<map_location, map_location> move_map;
44 
45 /** The standard way in which a map of possible movement routes to location is recorded*/
46 typedef std::map<map_location, pathfind::paths> moves_map;
47 
48 class ai_composite;
49 typedef std::unique_ptr<ai_composite> composite_ai_ptr;
50 
51 class attack_analysis;
52 typedef std::vector<attack_analysis> attacks_vector;
53 
54 template<typename T>
55 class typesafe_aspect;
56 
57 template<typename T>
58 using typesafe_aspect_ptr = std::shared_ptr<typesafe_aspect<T>>;
59 
60 template<typename T>
61 using typesafe_aspect_vector = std::vector<typesafe_aspect_ptr<T>>;
62 
63 template<typename T>
65 
66 template<typename T>
67 using typesafe_known_aspect_ptr = std::shared_ptr<typesafe_known_aspect<T>>;
68 
69 template<typename T>
70 using typesafe_known_aspect_vector = std::vector<typesafe_known_aspect_ptr<T>>;
71 
72 class action_result;
73 class attack_result;
74 class recall_result;
75 class recruit_result;
76 class move_result;
77 class move_and_attack_result;
78 class stopunit_result;
80 
81 typedef std::shared_ptr<action_result> action_result_ptr;
82 typedef std::shared_ptr<attack_result> attack_result_ptr;
83 typedef std::shared_ptr<recall_result> recall_result_ptr;
84 typedef std::shared_ptr<recruit_result> recruit_result_ptr;
85 typedef std::shared_ptr<move_result> move_result_ptr;
86 typedef std::shared_ptr<move_and_attack_result> move_and_attack_result_ptr;
87 typedef std::shared_ptr<stopunit_result> stopunit_result_ptr;
88 typedef std::shared_ptr<synced_command_result> synced_command_result_ptr;
89 
90 class aspect;
91 class candidate_action;
92 class engine;
93 class goal;
94 class known_aspect;
95 class stage;
96 
97 typedef std::shared_ptr<aspect> aspect_ptr;
98 typedef std::shared_ptr<candidate_action> candidate_action_ptr;
99 typedef std::shared_ptr<engine> engine_ptr;
100 typedef std::shared_ptr<goal> goal_ptr;
101 typedef std::shared_ptr<known_aspect> known_aspect_ptr;
102 typedef std::shared_ptr<stage> stage_ptr;
103 
104 typedef std::map<std::string, aspect_ptr> aspect_map;
105 typedef std::map<std::string, known_aspect_ptr> known_aspect_map;
106 
108 {
109 public:
111  : recent_attacks()
112  {
113  }
114 
115  std::set<map_location> recent_attacks;
116 };
117 
118 } // of namespace ai
std::set< map_location > recent_attacks
Definition: game_info.hpp:115
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:59
std::shared_ptr< engine > engine_ptr
Definition: game_info.hpp:99
std::vector< attack_analysis > attacks_vector
Definition: game_info.hpp:51
std::shared_ptr< recruit_result > recruit_result_ptr
Definition: game_info.hpp:84
std::shared_ptr< move_and_attack_result > move_and_attack_result_ptr
Definition: game_info.hpp:86
std::shared_ptr< typesafe_known_aspect< T > > typesafe_known_aspect_ptr
Definition: game_info.hpp:67
std::shared_ptr< typesafe_aspect< T > > typesafe_aspect_ptr
Definition: game_info.hpp:58
std::map< std::string, known_aspect_ptr > known_aspect_map
Definition: game_info.hpp:105
std::shared_ptr< aspect > aspect_ptr
Definition: game_info.hpp:95
std::shared_ptr< attack_result > attack_result_ptr
Definition: game_info.hpp:82
std::shared_ptr< stopunit_result > stopunit_result_ptr
Definition: game_info.hpp:87
std::multimap< map_location, map_location > move_map
The standard way in which a map of possible moves is recorded.
Definition: game_info.hpp:43
std::vector< typesafe_known_aspect_ptr< T > > typesafe_known_aspect_vector
Definition: game_info.hpp:70
std::shared_ptr< goal > goal_ptr
Definition: game_info.hpp:100
std::shared_ptr< stage > stage_ptr
Definition: game_info.hpp:102
std::shared_ptr< synced_command_result > synced_command_result_ptr
Definition: game_info.hpp:88
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:46
int side_number
Definition: game_info.hpp:40
std::shared_ptr< candidate_action > candidate_action_ptr
Definition: rca.hpp:145
std::shared_ptr< move_result > move_result_ptr
Definition: game_info.hpp:85
std::shared_ptr< known_aspect > known_aspect_ptr
Definition: game_info.hpp:101
std::shared_ptr< action_result > action_result_ptr
Definition: game_info.hpp:79
std::shared_ptr< recall_result > recall_result_ptr
Definition: game_info.hpp:83
std::map< std::string, aspect_ptr > aspect_map
Definition: game_info.hpp:104
std::unique_ptr< ai_composite > composite_ai_ptr
Definition: game_info.hpp:48
std::vector< typesafe_aspect_ptr< T > > typesafe_aspect_vector
Definition: game_info.hpp:61