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 /**
30  * info is structure which holds references to all the important objects
31  * that an AI might need access to, in order to make and implement its
32  * decisions.
33  */
34 namespace ai {
35 
36 typedef int side_number;
37 
38 /** The standard way in which a map of possible moves is recorded. */
39 typedef std::multimap<map_location,map_location> move_map;
40 
41 /** The standard way in which a map of possible movement routes to location is recorded*/
42 typedef std::map<map_location,pathfind::paths> moves_map;
43 
45 
46 typedef std::shared_ptr<ai_composite> ai_ptr;
47 
49 typedef std::vector<attack_analysis> attacks_vector;
50 
51 class readonly_context;
52 class readwrite_context;
53 class default_ai_context;
54 class ai_context;
55 
56 class aspect;
57 class candidate_action;
58 class engine;
59 class goal;
60 class known_aspect;
61 class stage;
62 
63 template<typename T>
64 class typesafe_aspect;
65 
66 template<typename T>
67 struct aspect_type {
68  typedef std::shared_ptr< typesafe_aspect<T> > typesafe_ptr;
69  typedef std::vector< std::shared_ptr< typesafe_aspect<T> > > typesafe_ptr_vector;
70 };
71 
72 template<typename T>
74 
75 template<typename T>
77  typedef std::shared_ptr< typesafe_known_aspect<T> > typesafe_ptr;
78  typedef std::vector< std::shared_ptr< typesafe_known_aspect<T> > > typesafe_ptr_vector;
79 };
80 
81 class action_result;
82 class attack_result;
83 class recall_result;
84 class recruit_result;
85 class move_result;
86 class move_and_attack_result;
87 class stopunit_result;
89 
90 typedef std::shared_ptr<action_result> action_result_ptr;
91 typedef std::shared_ptr<attack_result> attack_result_ptr;
92 typedef std::shared_ptr<recall_result> recall_result_ptr;
93 typedef std::shared_ptr<recruit_result> recruit_result_ptr;
94 typedef std::shared_ptr<move_result> move_result_ptr;
95 typedef std::shared_ptr<move_and_attack_result> move_and_attack_result_ptr;
96 typedef std::shared_ptr<stopunit_result> stopunit_result_ptr;
97 typedef std::shared_ptr<synced_command_result> synced_command_result_ptr;
98 
99 typedef std::shared_ptr< aspect > aspect_ptr;
100 typedef std::shared_ptr< candidate_action > candidate_action_ptr;
101 typedef std::shared_ptr< engine > engine_ptr;
102 typedef std::shared_ptr< goal > goal_ptr;
103 typedef std::shared_ptr< known_aspect > known_aspect_ptr;
104 typedef std::shared_ptr< stage > stage_ptr;
105 
106 typedef std::map<std::string, aspect_ptr > aspect_map;
107 typedef std::map<std::string, known_aspect_ptr > known_aspect_map;
108 
109 class game_info {
110 public:
111 
113  : recent_attacks()
114  {}
115 
116  /** hack. @todo 1.9 rework that via extended event system, or at least ensure it hurts no one */
117  std::set<map_location> recent_attacks;
118 };
119 
120 } //of namespace ai
std::shared_ptr< action_result > action_result_ptr
Definition: game_info.hpp:88
std::shared_ptr< candidate_action > candidate_action_ptr
Definition: rca.hpp:147
std::shared_ptr< stopunit_result > stopunit_result_ptr
Definition: game_info.hpp:96
std::vector< std::shared_ptr< typesafe_known_aspect< T > > > typesafe_ptr_vector
Definition: game_info.hpp:78
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:42
std::shared_ptr< move_result > move_result_ptr
Definition: game_info.hpp:94
std::shared_ptr< known_aspect > known_aspect_ptr
Definition: game_info.hpp:103
std::shared_ptr< aspect > aspect_ptr
Definition: game_info.hpp:99
std::shared_ptr< recruit_result > recruit_result_ptr
Definition: game_info.hpp:93
std::shared_ptr< engine > engine_ptr
Definition: game_info.hpp:101
std::shared_ptr< attack_result > attack_result_ptr
Definition: game_info.hpp:91
std::shared_ptr< ai_composite > ai_ptr
Definition: game_info.hpp:44
std::vector< attack_analysis > attacks_vector
Definition: game_info.hpp:48
std::map< std::string, known_aspect_ptr > known_aspect_map
Definition: game_info.hpp:107
std::multimap< map_location, map_location > move_map
The standard way in which a map of possible moves is recorded.
Definition: game_info.hpp:39
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:92
std::shared_ptr< stage > stage_ptr
Definition: game_info.hpp:104
std::shared_ptr< typesafe_known_aspect< T > > typesafe_ptr
Definition: game_info.hpp:77
std::shared_ptr< typesafe_aspect< T > > typesafe_ptr
Definition: game_info.hpp:68
std::shared_ptr< goal > goal_ptr
Definition: game_info.hpp:102
std::shared_ptr< synced_command_result > synced_command_result_ptr
Definition: game_info.hpp:97
std::shared_ptr< move_and_attack_result > move_and_attack_result_ptr
Definition: game_info.hpp:95
std::vector< std::shared_ptr< typesafe_aspect< T > > > typesafe_ptr_vector
Definition: game_info.hpp:69
std::map< std::string, aspect_ptr > aspect_map
Definition: game_info.hpp:106
std::set< map_location > recent_attacks
hack.
Definition: game_info.hpp:117
int side_number
Definition: game_info.hpp:36