The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
game_info.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2017 by David White <dave@whitevine.net>
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  * Game information for the AI
18  */
19 
20 #pragma once
21 
22 #include "map/location.hpp"
23 namespace pathfind {
24  struct paths;
25 }
26 #include <map>
27 #include <memory>
28 
29 class game_display;
30 class gamemap;
31 class unit_map;
32 class team;
33 class tod_manager;
34 
35 /**
36  * info is structure which holds references to all the important objects
37  * that an AI might need access to, in order to make and implement its
38  * decisions.
39  */
40 namespace ai {
41 
42 typedef int side_number;
43 
44 /** The standard way in which a map of possible moves is recorded. */
45 typedef std::multimap<map_location,map_location> move_map;
46 
47 /** The standard way in which a map of possible movement routes to location is recorded*/
48 typedef std::map<map_location,pathfind::paths> moves_map;
49 
51 
52 typedef std::shared_ptr<ai_composite> ai_ptr;
53 
55 typedef std::vector<attack_analysis> attacks_vector;
56 
57 class readonly_context;
58 class readwrite_context;
59 class default_ai_context;
60 class ai_context;
61 
62 class aspect;
63 class candidate_action;
64 class engine;
65 class goal;
66 class known_aspect;
67 class stage;
68 
69 template<typename T>
70 class typesafe_aspect;
71 
72 template<typename T>
73 struct aspect_type {
74  typedef std::shared_ptr< typesafe_aspect<T> > typesafe_ptr;
75  typedef std::vector< std::shared_ptr< typesafe_aspect<T> > > typesafe_ptr_vector;
76 };
77 
78 template<typename T>
80 
81 template<typename T>
83  typedef std::shared_ptr< typesafe_known_aspect<T> > typesafe_ptr;
84  typedef std::vector< std::shared_ptr< typesafe_known_aspect<T> > > typesafe_ptr_vector;
85 };
86 
87 class action_result;
88 class attack_result;
89 class recall_result;
90 class recruit_result;
91 class move_result;
92 class move_and_attack_result;
93 class stopunit_result;
95 
96 typedef std::shared_ptr<action_result> action_result_ptr;
97 typedef std::shared_ptr<attack_result> attack_result_ptr;
98 typedef std::shared_ptr<recall_result> recall_result_ptr;
99 typedef std::shared_ptr<recruit_result> recruit_result_ptr;
100 typedef std::shared_ptr<move_result> move_result_ptr;
101 typedef std::shared_ptr<move_and_attack_result> move_and_attack_result_ptr;
102 typedef std::shared_ptr<stopunit_result> stopunit_result_ptr;
103 typedef std::shared_ptr<synced_command_result> synced_command_result_ptr;
104 
105 typedef std::shared_ptr< aspect > aspect_ptr;
106 typedef std::shared_ptr< candidate_action > candidate_action_ptr;
107 typedef std::shared_ptr< engine > engine_ptr;
108 typedef std::shared_ptr< goal > goal_ptr;
109 typedef std::shared_ptr< known_aspect > known_aspect_ptr;
110 typedef std::shared_ptr< stage > stage_ptr;
111 
112 typedef std::map<std::string, aspect_ptr > aspect_map;
113 typedef std::map<std::string, known_aspect_ptr > known_aspect_map;
114 
115 class game_info {
116 public:
117 
119  : recent_attacks()
120  {}
121 
122  /** hack. @todo 1.9 rework that via extended event system, or at least ensure it hurts no one */
123  std::set<map_location> recent_attacks;
124 };
125 
126 } //of namespace ai
std::shared_ptr< action_result > action_result_ptr
Definition: game_info.hpp:94
std::shared_ptr< candidate_action > candidate_action_ptr
Definition: rca.hpp:147
std::shared_ptr< stopunit_result > stopunit_result_ptr
Definition: game_info.hpp:102
std::vector< std::shared_ptr< typesafe_known_aspect< T > > > typesafe_ptr_vector
Definition: game_info.hpp:84
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:48
std::shared_ptr< move_result > move_result_ptr
Definition: game_info.hpp:100
std::shared_ptr< known_aspect > known_aspect_ptr
Definition: game_info.hpp:109
std::shared_ptr< aspect > aspect_ptr
Definition: game_info.hpp:105
std::shared_ptr< recruit_result > recruit_result_ptr
Definition: game_info.hpp:99
std::shared_ptr< engine > engine_ptr
Definition: game_info.hpp:107
std::shared_ptr< attack_result > attack_result_ptr
Definition: game_info.hpp:97
std::shared_ptr< ai_composite > ai_ptr
Definition: game_info.hpp:50
std::vector< attack_analysis > attacks_vector
Definition: game_info.hpp:54
std::map< std::string, known_aspect_ptr > known_aspect_map
Definition: game_info.hpp:113
std::multimap< map_location, map_location > move_map
The standard way in which a map of possible moves is recorded.
Definition: game_info.hpp:45
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:44
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:58
std::shared_ptr< recall_result > recall_result_ptr
Definition: game_info.hpp:98
std::shared_ptr< stage > stage_ptr
Definition: game_info.hpp:110
std::shared_ptr< typesafe_known_aspect< T > > typesafe_ptr
Definition: game_info.hpp:83
std::shared_ptr< typesafe_aspect< T > > typesafe_ptr
Definition: game_info.hpp:74
Encapsulates the map of the game.
Definition: map.hpp:34
std::shared_ptr< goal > goal_ptr
Definition: game_info.hpp:108
std::shared_ptr< synced_command_result > synced_command_result_ptr
Definition: game_info.hpp:103
std::shared_ptr< move_and_attack_result > move_and_attack_result_ptr
Definition: game_info.hpp:101
std::vector< std::shared_ptr< typesafe_aspect< T > > > typesafe_ptr_vector
Definition: game_info.hpp:75
std::map< std::string, aspect_ptr > aspect_map
Definition: game_info.hpp:112
std::set< map_location > recent_attacks
hack.
Definition: game_info.hpp:123
Container associating units to locations.
Definition: map.hpp:99
int side_number
Definition: game_info.hpp:42