The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
contexts.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2016 by Yurii Chernyi <[email protected]>
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  * Helper functions for the object which operates in the context of AI for specific side
18  * this is part of AI interface
19  */
20 
21 #ifndef AI_CONTEXTS_HPP_INCLUDED
22 #define AI_CONTEXTS_HPP_INCLUDED
23 
24 #include "ai/game_info.hpp" // for move_map, aspect_type, etc
25 
26 #include "global.hpp"
27 
28 #include "config.hpp" // for config
29 #include "game_errors.hpp"
30 #include "generic_event.hpp" // for observer
31 #include "units/ptr.hpp" // for unit_ptr
32 #include "map/location.hpp" // for map_location
33 
34 #include <map> // for map, map<>::value_compare
35 #include <set> // for set
36 #include <string> // for string
37 #include <utility> // for pair
38 #include <vector> // for vector
39 
40 class gamemap; // lines 41-41
41 class team;
42 class terrain_filter; // lines 43-43
43 class unit_map;
44 class unit_type; // lines 46-46
45 class variant; // lines 42-42
46 namespace ai { class ai_context; } // lines 51-51
47 namespace ai { class unit_advancements_aspect; }
48 namespace ai { template <typename T> class typesafe_aspect; }
49 namespace boost { template <class T> class shared_ptr; }
50 namespace pathfind { struct paths; }
51 struct battle_context_unit_stats; // lines 39-39
52 
53 #ifdef _MSC_VER
54 #pragma warning(push)
55 //silence "inherits via dominance" warnings
56 #pragma warning(disable:4250)
57 #endif
58 
59 namespace ai {
60 
62 
63 
64 // recursion counter
66 public:
68  : counter_(++counter)
69  {
70  if (counter > MAX_COUNTER_VALUE ) {
71  throw game::game_error("maximum recursion depth reached!");
72  }
73  }
74 
75 
76  /**
77  * Get the current value of the recursion counter
78  */
79  int get_count() const
80  {
81  return counter_;
82  }
83 
84 
85  //max recursion depth
86  static const int MAX_COUNTER_VALUE = 100;
87 
88 
89  /**
90  * Check if more recursion is allowed
91  */
92  bool is_ok() const
93  {
94  return counter_ < MAX_COUNTER_VALUE;
95  }
96 private:
97 
98  // recursion counter value
99  int counter_;
100 };
101 
102 //defensive position
103 
106  loc(),
107  chance_to_hit(0),
108  vulnerability(0.0),
109  support(0.0)
110  {}
111 
115 };
116 
117 // keeps cache
119 {
120 public:
121  keeps_cache();
122  ~keeps_cache();
123  void handle_generic_event(const std::string& event_name);
124  void clear();
125  const std::set<map_location>& get();
126  void init(const gamemap &map);
127 private:
128  const gamemap *map_;
129  std::set<map_location> keeps_;
130 };
131 
132 // side context
133 
134 class side_context;
135 
137 public:
138 
139  /**
140  * Get the side number
141  */
142  virtual side_number get_side() const = 0;
143 
144 
145  /**
146  * Set the side number
147  */
148  virtual void set_side(side_number side) = 0;
149 
150 
151  /**
152  * empty destructor
153  */
154  virtual ~side_context(){}
155 
156 
157  /**
158  * empty constructor
159  */
161 
162 
163  /**
164  * unwrap
165  */
166  virtual side_context& get_side_context() = 0;
167 
168 
169  /**
170  * serialize this context to config
171  */
172  virtual config to_side_context_config() const = 0;
173 
174 
175  /**
176  * Get the value of the recursion counter
177  */
178  virtual int get_recursion_count() const = 0;
179 
180 
181 };
182 
183 class readonly_context;
184 class readonly_context : public virtual side_context {
185 public:
187  virtual ~readonly_context(){}
188  virtual readonly_context& get_readonly_context() = 0;
189  virtual void on_readonly_context_create() = 0;
190  virtual const team& current_team() const = 0;
191  virtual void diagnostic(const std::string& msg) = 0;
192  virtual void log_message(const std::string& msg) = 0;
193  virtual attack_result_ptr check_attack_action(const map_location& attacker_loc, const map_location& defender_loc, int attacker_weapon) = 0;
194  virtual move_result_ptr check_move_action(const map_location& from, const map_location& to, bool remove_movement=true, bool unreach_is_ok=false) = 0;
197  virtual stopunit_result_ptr check_stopunit_action(const map_location& unit_location, bool remove_movement = true, bool remove_attacks = false) = 0;
199  virtual void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
200  move_map& srcdst, move_map& dstsrc, bool enemy,
201  bool assume_full_movement=false,
202  const terrain_filter* remove_destinations=nullptr) const = 0;
203  virtual void calculate_moves(const unit_map& units,
204  std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
205  move_map& dstsrc, bool enemy, bool assume_full_movement=false,
206  const terrain_filter* remove_destinations=nullptr,
207  bool see_all=false) const = 0;
208 
209  virtual const game_info& get_info() const = 0;
210 
211 
212  //@note: following part is in alphabetic order
214  const move_map& dstsrc, const move_map& srcdst, const move_map& enemy_dstsrc) const = 0;
215 
216 
217  virtual std::map<map_location,defensive_position>& defensive_position_cache() const = 0;
218 
219 
220  virtual const unit_advancements_aspect& get_advancements() const = 0;
221 
222 
223  virtual double get_aggression() const = 0;
224 
225 
226  virtual int get_attack_depth() const = 0;
227 
228 
229  virtual const aspect_map& get_aspects() const = 0;
230 
231 
232  virtual aspect_map& get_aspects() = 0;
233 
234 
235  virtual void add_facet(const std::string &id, const config &cfg) const = 0;
236 
237 
238  virtual void add_aspects(std::vector< aspect_ptr > &aspects ) = 0;
239 
240 
241  virtual const attacks_vector& get_attacks() const = 0;
242 
243 
244  virtual const variant& get_attacks_as_variant() const = 0;
245 
246 
247  virtual const terrain_filter& get_avoid() const = 0;
248 
249 
250  virtual double get_caution() const = 0;
251 
252 
253  virtual const move_map& get_dstsrc() const = 0;
254 
255 
256  virtual const move_map& get_enemy_dstsrc() const = 0;
257 
258 
259  virtual const moves_map& get_enemy_possible_moves() const = 0;
260 
261 
262  virtual const move_map& get_enemy_srcdst() const = 0;
263 
264  /**
265  * get engine by cfg, creating it if it is not created yet but known
266  */
267  virtual engine_ptr get_engine_by_cfg(const config& cfg) = 0;
268 
269 
270  virtual const std::vector<engine_ptr>& get_engines() const = 0;
271 
272 
273  virtual std::vector<engine_ptr>& get_engines() = 0;
274 
275 
276  virtual std::string get_grouping() const = 0;
277 
278 
279  virtual const std::vector<goal_ptr>& get_goals() const = 0;
280 
281 
282  virtual std::vector<goal_ptr>& get_goals() = 0;
283 
284 
285  virtual double get_leader_aggression() const = 0;
286 
287 
288  virtual config get_leader_goal() const = 0;
289 
290 
291  virtual bool get_leader_ignores_keep() const = 0;
292 
293 
294  virtual double get_leader_value() const = 0;
295 
296 
297  virtual bool get_passive_leader() const = 0;
298 
299 
300  virtual bool get_passive_leader_shares_keep() const = 0;
301 
302 
303  virtual const moves_map& get_possible_moves() const = 0;
304 
305 
306  virtual const std::vector<unit_ptr>& get_recall_list() const = 0;
307 
308 
309  virtual double get_recruitment_diversity() const = 0;
310 
311 
312  virtual const config get_recruitment_instructions() const = 0;
313 
314 
315  virtual const std::vector<std::string> get_recruitment_more() const = 0;
316 
317 
318  virtual const std::vector<std::string> get_recruitment_pattern() const = 0;
319 
320 
321  virtual int get_recruitment_randomness() const = 0;
322 
323 
324  virtual const config get_recruitment_save_gold() const = 0;
325 
326 
327  virtual double get_scout_village_targeting() const = 0;
328 
329 
330  virtual bool get_simple_targeting() const = 0;
331 
332 
333  virtual const move_map& get_srcdst() const = 0;
334 
335 
336  virtual bool get_support_villages() const = 0;
337 
338 
339  virtual double get_village_value() const = 0;
340 
341 
342  virtual int get_villages_per_scout() const = 0;
343 
344 
345 
346  virtual bool is_active(const std::string &time_of_day, const std::string &turns) const = 0;
347 
348  virtual bool is_dst_src_valid_lua() const = 0;
349 
350  virtual bool is_dst_src_enemy_valid_lua() const = 0;
351 
352  virtual bool is_src_dst_valid_lua() const = 0;
353 
354  virtual bool is_src_dst_enemy_valid_lua() const = 0;
355 
356  virtual void invalidate_defensive_position_cache() const = 0;
357 
358 
359  virtual void invalidate_move_maps() const = 0;
360 
361 
362  virtual void invalidate_keeps_cache() const= 0;
363 
364 
365  virtual const std::set<map_location>& keeps() const= 0;
366 
367 
368  virtual bool leader_can_reach_keep() const = 0;
369 
370 
371  virtual const map_location& nearest_keep(const map_location& loc) const = 0;
372 
373 
374  /**
375  * Function which finds how much 'power' a side can attack a certain location with.
376  * This is basically the maximum hp of damage that can be inflicted upon a unit on loc
377  * by full-health units, multiplied by the defense these units will have.
378  * (if 'use_terrain' is false, then it will be multiplied by 0.5)
379  *
380  * Example: 'loc' can be reached by two units, one of whom has a 10-3 attack
381  * and has 48/48 hp, and can defend at 40% on the adjacent grassland.
382  * The other has a 8-2 attack, and has 30/40 hp, and can defend at 60% on the adjacent mountain.
383  * The rating will be 10*3*1.0*0.4 + 8*2*0.75*0.6 = 19.2
384  */
385  virtual double power_projection(const map_location& loc, const move_map& dstsrc) const = 0;
386 
387 
388  virtual void raise_user_interact() const = 0;
389 
390 
391  virtual void recalculate_move_maps() const = 0;
392 
393 
394  virtual void recalculate_move_maps_enemy() const = 0;
395 
396  virtual void set_src_dst_valid_lua() = 0;
397  virtual void set_src_dst_enemy_valid_lua() = 0;
398  virtual void set_dst_src_valid_lua() = 0;
399  virtual void set_dst_src_enemy_valid_lua() = 0;
400 
401  /** get most suitable keep for leader - nearest free that can be reached in 1 turn, if none - return nearest occupied that can be reached in 1 turn, if none - return nearest keep, if none - return null_location */
402  virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths ) = 0;
403 
404  /**
405  * serialize to config
406  */
407  virtual config to_readonly_context_config() const = 0;
408 
409 
410  typedef std::map<std::pair<map_location,const unit_type *>,
411  std::pair<battle_context_unit_stats,battle_context_unit_stats> >
413  virtual unit_stats_cache_t & unit_stats_cache() const = 0;
414 
415 };
416 
417 class readwrite_context;
418 class readwrite_context : public virtual readonly_context {
419 public:
421 
422 
423  virtual ~readwrite_context(){}
424 
425 
427 
428 
429  virtual attack_result_ptr execute_attack_action(const map_location& attacker_loc, const map_location& defender_loc, int attacker_weapon) = 0;
430 
431 
432  virtual move_result_ptr execute_move_action(const map_location& from, const map_location& to, bool remove_movement=true, bool unreach_is_ok=false) = 0;
433 
434 
436 
437 
439 
440 
441  virtual stopunit_result_ptr execute_stopunit_action(const map_location& unit_location, bool remove_movement = true, bool remove_attacks = false) = 0;
442 
443 
445 
446 
447  virtual team& current_team_w() = 0;
448 
449 
450  virtual void raise_gamestate_changed() const = 0;
451 
452 
453  virtual game_info& get_info_w() = 0;
454 
455 
456  /**
457  * serialize this context to config
458  */
459  virtual config to_readwrite_context_config() const = 0;
460 
461 };
462 
463 //proxies
464 
465 class side_context_proxy : public virtual side_context {
466 public:
468  : target_(nullptr)
469  {
470  }
471 
473 
474 
476  {
477  target_= &target.get_side_context();
478  }
479 
480  virtual side_number get_side() const
481  {
482  return target_->get_side();
483  }
484 
485  virtual void set_side(side_number side)
486  {
487  return target_->set_side(side);
488  }
489 
491  {
492  return target_->get_side_context();
493  }
494 
495  virtual int get_recursion_count() const
496  {
497  return target_->get_recursion_count();
498  }
499 
500 
502  {
504  }
505 
506 
507 private:
509 };
510 
511 
512 class readonly_context_proxy : public virtual readonly_context, public virtual side_context_proxy {
513 public:
515  : target_(nullptr)
516  {
517  }
518 
520 
522  {
523  init_side_context_proxy(target);
524  target_ = &target.get_readonly_context();
525  }
526 
528  {
529  return target_->get_readonly_context();
530  }
531 
532 
534  {
536  }
537 
538 
539  virtual const team& current_team() const
540  {
541  return target_->current_team();
542  }
543 
544  virtual void diagnostic(const std::string& msg)
545  {
546  target_->diagnostic(msg);
547  }
548 
549  virtual void log_message(const std::string& msg)
550  {
551  target_->log_message(msg);
552  }
553 
554  virtual attack_result_ptr check_attack_action(const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon)
555  {
556  return target_->check_attack_action(attacker_loc, defender_loc, attacker_weapon);
557  }
558 
559  virtual move_result_ptr check_move_action(const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false)
560  {
561  return target_->check_move_action(from, to, remove_movement, unreach_is_ok);
562  }
563 
564 
567  {
568  return target_->check_recall_action(id, where, from);
569  }
570 
571 
574  {
575  return target_->check_recruit_action(unit_name, where, from);
576  }
577 
578  virtual stopunit_result_ptr check_stopunit_action(const map_location &unit_location, bool remove_movement = true, bool remove_attacks = false)
579  {
580  return target_->check_stopunit_action(unit_location, remove_movement, remove_attacks);
581  }
582 
584  {
585  return target_->check_synced_command_action(lua_code, location);
586  }
587 
588  virtual void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
589  move_map& srcdst, move_map& dstsrc, bool enemy,
590  bool assume_full_movement=false,
591  const terrain_filter* remove_destinations=nullptr) const
592  {
593  target_->calculate_possible_moves(possible_moves, srcdst, dstsrc, enemy, assume_full_movement, remove_destinations);
594  }
595 
596  virtual void calculate_moves(const unit_map& units,
597  std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
598  move_map& dstsrc, bool enemy, bool assume_full_movement=false,
599  const terrain_filter* remove_destinations=nullptr,
600  bool see_all=false) const
601  {
602  target_->calculate_moves(units, possible_moves, srcdst, dstsrc, enemy, assume_full_movement, remove_destinations, see_all);
603  }
604 
605  virtual const game_info& get_info() const
606  {
607  return target_->get_info();
608  }
609 
610  virtual void raise_user_interact() const
611  {
613  }
614 
615 
616  virtual int get_recursion_count() const
617  {
618  return target_->get_recursion_count();
619  }
620 
621  //@note: following part is in alphabetic order
623  const move_map& dstsrc, const move_map& srcdst, const move_map& enemy_dstsrc) const
624  {
625  return target_->best_defensive_position(unit,dstsrc,srcdst,enemy_dstsrc);
626  }
627 
628 
629  virtual std::map<map_location,defensive_position>& defensive_position_cache() const
630  {
632  }
633 
634 
636  {
637  return target_->get_advancements();
638  }
639 
640 
641  virtual double get_aggression() const
642  {
643  return target_->get_aggression();
644  }
645 
646 
647  virtual int get_attack_depth() const
648  {
649  return target_->get_attack_depth();
650  }
651 
652 
653  virtual const aspect_map& get_aspects() const
654  {
655  return target_->get_aspects();
656  }
657 
658 
660  {
661  return target_->get_aspects();
662  }
663 
664 
665  virtual void add_aspects(std::vector< aspect_ptr > &aspects )
666  {
667  return target_->add_aspects(aspects);
668  }
669 
670 
671  virtual void add_facet(const std::string &id, const config &cfg) const
672  {
673  target_->add_facet(id,cfg);
674  }
675 
676 
677 
678  virtual const attacks_vector& get_attacks() const
679  {
680  return target_->get_attacks();
681  }
682 
683 
684 
685  virtual const variant& get_attacks_as_variant() const
686  {
688  }
689 
690 
691  virtual const terrain_filter& get_avoid() const
692  {
693  return target_->get_avoid();
694  }
695 
696 
697  virtual double get_caution() const
698  {
699  return target_->get_caution();
700  }
701 
702 
703  virtual const move_map& get_dstsrc() const
704  {
705  return target_->get_dstsrc();
706  }
707 
708 
709  virtual const move_map& get_enemy_dstsrc() const
710  {
711  return target_->get_enemy_dstsrc();
712  }
713 
714 
715  virtual const moves_map& get_enemy_possible_moves() const
716  {
718  }
719 
720 
721  virtual const move_map& get_enemy_srcdst() const
722  {
723  return target_->get_enemy_srcdst();
724  }
725 
726 
727  virtual engine_ptr get_engine_by_cfg(const config &cfg)
728  {
729  return target_->get_engine_by_cfg(cfg);
730  }
731 
732 
733  virtual const std::vector<engine_ptr>& get_engines() const
734  {
735  return target_->get_engines();
736  }
737 
738 
739  virtual std::vector<engine_ptr>& get_engines()
740  {
741  return target_->get_engines();
742  }
743 
744 
745  virtual std::string get_grouping() const
746  {
747  return target_->get_grouping();
748  }
749 
750 
751  virtual const std::vector<goal_ptr>& get_goals() const
752  {
753  return target_->get_goals();
754  }
755 
756 
757  virtual std::vector<goal_ptr>& get_goals()
758  {
759  return target_->get_goals();
760  }
761 
762 
763  virtual double get_leader_aggression() const
764  {
765  return target_->get_leader_aggression();
766  }
767 
768 
769 
770  virtual config get_leader_goal() const
771  {
772  return target_->get_leader_goal();
773  }
774 
775 
776  virtual bool get_leader_ignores_keep() const
777  {
779  }
780 
781 
782  virtual double get_leader_value() const
783  {
784  return target_->get_leader_value();
785  }
786 
787 
788  virtual bool get_passive_leader() const
789  {
790  return target_->get_passive_leader();
791  }
792 
793 
794  virtual bool get_passive_leader_shares_keep() const
795  {
797  }
798 
799 
800  virtual const moves_map& get_possible_moves() const
801  {
802  return target_->get_possible_moves();
803  }
804 
805 
806  virtual double power_projection(const map_location& loc, const move_map& dstsrc) const
807  {
808  return target_->power_projection(loc,dstsrc);
809  }
810 
811 
812  virtual const std::vector<unit_ptr>& get_recall_list() const
813  {
814  return target_->get_recall_list();
815  }
816 
817 
818  virtual double get_recruitment_diversity() const
819  {
821  }
822 
823 
824  virtual const config get_recruitment_instructions() const
825  {
827  }
828 
829 
830  virtual const std::vector<std::string> get_recruitment_more() const
831  {
832  return target_->get_recruitment_more();
833  }
834 
835 
836  virtual const std::vector<std::string> get_recruitment_pattern() const
837  {
839  }
840 
841 
842  virtual int get_recruitment_randomness() const
843  {
845  }
846 
847 
848  virtual const config get_recruitment_save_gold() const
849  {
851  }
852 
853 
854  virtual const move_map& get_srcdst() const
855  {
856  return target_->get_srcdst();
857  }
858 
859 
860  virtual double get_scout_village_targeting() const
861  {
863  }
864 
865 
866  virtual bool get_simple_targeting() const
867  {
868  return target_->get_simple_targeting();
869  }
870 
871 
872  virtual bool get_support_villages() const
873  {
874  return target_->get_support_villages();
875  }
876 
877 
878  virtual double get_village_value() const
879  {
880  return target_->get_village_value();
881  }
882 
883 
884  virtual int get_villages_per_scout() const
885  {
887  }
888 
889 
890 
891  virtual bool is_active(const std::string &time_of_day, const std::string &turns) const
892  {
893  return target_->is_active(time_of_day, turns);
894  }
895 
896  virtual bool is_dst_src_valid_lua() const
897  {
898  return target_->is_dst_src_valid_lua();
899  }
900 
901  virtual bool is_dst_src_enemy_valid_lua() const
902  {
904  }
905 
906  virtual bool is_src_dst_valid_lua() const
907  {
908  return target_->is_src_dst_valid_lua();
909  }
910 
911  virtual bool is_src_dst_enemy_valid_lua() const
912  {
914  }
915 
917  {
919  }
920 
921 
922  virtual void invalidate_move_maps() const
923  {
925  }
926 
927 
928  virtual void invalidate_keeps_cache() const
929  {
931  }
932 
933 
934  virtual const std::set<map_location>& keeps() const
935  {
936  return target_->keeps();
937  }
938 
939 
940  virtual bool leader_can_reach_keep() const
941  {
942  return target_->leader_can_reach_keep();
943  }
944 
945 
946  virtual const map_location& nearest_keep( const map_location& loc ) const
947  {
948  return target_->nearest_keep(loc);
949  }
950 
951 
952  virtual void recalculate_move_maps() const
953  {
955  }
956 
957 
958  virtual void recalculate_move_maps_enemy() const
959  {
961  }
962 
963  virtual void set_dst_src_valid_lua()
964  {
966  }
967 
969  {
971  }
972 
973  virtual void set_src_dst_valid_lua()
974  {
976  }
977 
979  {
981  }
982 
983  virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths )
984  {
985  return target_->suitable_keep(leader_location, leader_paths);
986  }
987 
988 
990  {
992  }
993 
994 
996  {
997  return target_->unit_stats_cache();
998  }
999 
1000 
1001 private:
1003 };
1004 
1005 
1006 class readwrite_context_proxy : public virtual readwrite_context, public virtual readonly_context_proxy {
1007 public:
1009  : target_(nullptr)
1010  {
1011  }
1012 
1013 
1015  {
1017  target_ = &target.get_readwrite_context();
1018  }
1019 
1020 
1022  {
1023  return target_->get_readwrite_context();
1024  }
1025 
1026 
1027  virtual attack_result_ptr execute_attack_action(const map_location& attacker_loc, const map_location& defender_loc, int attacker_weapon)
1028  {
1029  return target_->execute_attack_action(attacker_loc,defender_loc,attacker_weapon);
1030  }
1031 
1032 
1033  virtual move_result_ptr execute_move_action(const map_location& from, const map_location& to, bool remove_movement=true, bool unreach_is_ok=false)
1034  {
1035  return target_->execute_move_action(from, to, remove_movement, unreach_is_ok);
1036  }
1037 
1038 
1040  {
1041  return target_->execute_recall_action(id,where,from);
1042  }
1043 
1044 
1046  {
1047  return target_->execute_recruit_action(unit_name,where,from);
1048  }
1049 
1050 
1051  virtual stopunit_result_ptr execute_stopunit_action(const map_location& unit_location, bool remove_movement = true, bool remove_attacks = false)
1052  {
1053  return target_->execute_stopunit_action(unit_location,remove_movement,remove_attacks);
1054  }
1055 
1056 
1058  {
1060  }
1061 
1062 
1064  {
1065  return target_->current_team_w();
1066  }
1067 
1068 
1069  virtual void raise_gamestate_changed() const
1070  {
1072  }
1073 
1074 
1076  {
1077  return target_->get_info_w();
1078  }
1079 
1080 
1081  virtual int get_recursion_count() const
1082  {
1083  return target_->get_recursion_count();
1084  }
1085 
1086 
1088  {
1090  }
1091 
1092 private:
1094 };
1095 
1096 
1097 //implementation
1099 public:
1100  side_context_impl(side_number side, const config &/*cfg*/)
1101  : side_(side), recursion_counter_(0)
1102  {
1103  }
1104 
1106 
1107  virtual side_number get_side() const
1108  {
1109  return side_;
1110  }
1111 
1112  virtual void set_side(side_number side)
1113  {
1114  side_ = side;
1115  }
1116 
1117 
1119  {
1120  return *this;
1121  }
1122 
1123 
1124  virtual int get_recursion_count() const;
1125 
1126 
1127  virtual config to_side_context_config() const;
1128 
1129 private:
1132 };
1133 
1134 
1136 public:
1137 
1138  /**
1139  * Constructor
1140  */
1141  readonly_context_impl(side_context &context, const config &cfg);
1142 
1143 
1144  /**
1145  * Destructor
1146  */
1147  virtual ~readonly_context_impl();
1148 
1149 
1150  /**
1151  * Unwrap - this class is not a proxy, so return *this
1152 :w
1153  */
1155  {
1156  return *this;
1157  }
1158 
1159 
1160  virtual void on_readonly_context_create();
1161 
1162 
1163  /** Handle generic event */
1164  virtual void handle_generic_event(const std::string& event_name);
1165 
1166 
1167  /** Return a reference to the 'team' object for the AI. */
1168  const team& current_team() const;
1169 
1170 
1171  /** Show a diagnostic message on the screen. */
1172  void diagnostic(const std::string& msg);
1173 
1174 
1175  /** Display a debug message as a chat message. */
1176  void log_message(const std::string& msg);
1177 
1178 
1179  /**
1180  * Check if it is possible to attack enemy defender using our unit attacker from attackers current location,
1181  * @param attacker_loc location of attacker
1182  * @param defender_loc location of defender
1183  * @param attacker_weapon weapon of attacker
1184  * @retval possible result: ok
1185  * @retval possible result: something wrong
1186  * @retval possible result: attacker and/or defender are invalid
1187  * @retval possible result: attacker and/or defender are invalid
1188  * @retval possible result: attacker doesn't have the specified weapon
1189  */
1190  attack_result_ptr check_attack_action(const map_location& attacker_loc, const map_location& defender_loc, int attacker_weapon);
1191 
1192 
1193  /**
1194  * Check if it is possible to move our unit from location 'from' to location 'to'
1195  * @param from location of our unit
1196  * @param to where to move
1197  * @param remove_movement set unit movement to 0 in case of successful move
1198  * @retval possible result: ok
1199  * @retval possible result: something wrong
1200  * @retval possible result: move is interrupted
1201  * @retval possible result: move is impossible
1202  */
1203  move_result_ptr check_move_action(const map_location& from, const map_location& to, bool remove_movement=true, bool unreach_is_ok=false);
1204 
1205 
1206 
1207  /**
1208  * Check if it is possible to recall a unit for us on specified location
1209  * @param id the id of the unit to be recruited.
1210  * @param where location where the unit is to be recruited.
1211  * @retval possible result: ok
1212  * @retval possible_result: something wrong
1213  * @retval possible_result: leader not on keep
1214  * @retval possible_result: no free space on keep
1215  * @retval possible_result: not enough gold
1216  */
1218 
1219 
1220  /**
1221  * Check if it is possible to recruit a unit for us on specified location
1222  * @param unit_name the name of the unit to be recruited.
1223  * @param where location where the unit is to be recruited.
1224  * @retval possible result: ok
1225  * @retval possible_result: something wrong
1226  * @retval possible_result: leader not on keep
1227  * @retval possible_result: no free space on keep
1228  * @retval possible_result: not enough gold
1229  */
1231 
1232 
1233  /**
1234  * Check if it is possible to remove unit movements and/or attack
1235  * @param unit_location the location of our unit
1236  * @param remove_movement set remaining movements to 0
1237  * @param remove_attacks set remaining attacks to 0
1238  * @retval possible result: ok
1239  * @retval possible_result: something wrong
1240  * @retval possible_result: nothing to do
1241  */
1242  stopunit_result_ptr check_stopunit_action(const map_location& unit_location, bool remove_movement = true, bool remove_attacks = false);
1243 
1244 
1245  /**
1246  * Check if it is possible to run Lua code
1247  * @param lua_code the code to be run
1248  * @param location location to be passed to the code as x1/y1
1249  * @retval possible result: ok
1250  * @retval possible_result: something wrong
1251  * @retval possible_result: nothing to do
1252  */
1254 
1255 
1256  /**
1257  * Calculate the moves units may possibly make.
1258  *
1259  * @param possible_moves A map which will be filled with the paths
1260  * each unit can take to get to every possible
1261  * destination. You probably don't want to use
1262  * this object at all, except to pass to
1263  * 'move_unit'.
1264  * @param srcdst A map of units to all their possible
1265  * destinations.
1266  * @param dstsrc A map of destinations to all the units that
1267  * can move to that destination.
1268  * @param enemy if true, a map of possible moves for enemies
1269  * will be calculated. If false, a map of
1270  * possible moves for units on the AI's side
1271  * will be calculated. The AI's own leader will
1272  * not be included in this map.
1273  * @param assume_full_movement
1274  * If true, the function will operate on the
1275  * assumption that all units can move their full
1276  * movement allotment.
1277  * @param remove_destinations a pointer to a terrain filter for possible destinations
1278  * to omit.
1279  */
1280  void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
1281  move_map& srcdst, move_map& dstsrc, bool enemy,
1282  bool assume_full_movement=false,
1283  const terrain_filter* remove_destinations=nullptr) const;
1284 
1285  /**
1286  * A more fundamental version of calculate_possible_moves which allows the
1287  * use of a speculative unit map.
1288  * NOTE: Support for a speculative map is broken (not used when pathfinding)
1289  * and has not been used since (probably) r38610 (September 2009).
1290  * (See the todo in the implementation.)
1291  */
1292  void calculate_moves(const unit_map& units,
1293  std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
1294  move_map& dstsrc, bool enemy, bool assume_full_movement=false,
1295  const terrain_filter* remove_destinations=nullptr,
1296  bool see_all=false) const;
1297 
1298 
1299  virtual const game_info& get_info() const;
1300 
1301  /**
1302  * Function which should be called frequently to allow the user to interact
1303  * with the interface. This function will make sure that interaction
1304  * doesn't occur too often, so there is no problem with calling it very
1305  * regularly.
1306  */
1307  void raise_user_interact() const;
1308 
1309 
1310  virtual int get_recursion_count() const;
1311 
1312 
1313  //@note: following functions are in alphabetic order
1315  const move_map& dstsrc, const move_map& srcdst, const move_map& enemy_dstsrc) const;
1316 
1317 
1318  virtual std::map<map_location,defensive_position>& defensive_position_cache() const;
1319 
1320 
1321  virtual const unit_advancements_aspect& get_advancements() const;
1322 
1323 
1324  virtual double get_aggression() const;
1325 
1326 
1327  virtual int get_attack_depth() const;
1328 
1329 
1330  virtual const aspect_map& get_aspects() const;
1331 
1332 
1333  virtual aspect_map& get_aspects();
1334 
1335 
1336  virtual const attacks_vector& get_attacks() const;
1337 
1338 
1339  virtual const variant& get_attacks_as_variant() const;
1340 
1341 
1342  virtual const terrain_filter& get_avoid() const;
1343 
1344 
1345  virtual double get_caution() const;
1346 
1347 
1348  virtual const move_map& get_dstsrc() const;
1349 
1350 
1351  virtual const move_map& get_enemy_dstsrc() const;
1352 
1353 
1354  virtual const moves_map& get_enemy_possible_moves() const;
1355 
1356 
1357  virtual const move_map& get_enemy_srcdst() const;
1358 
1359 
1360  virtual engine_ptr get_engine_by_cfg(const config& cfg);
1361 
1362 
1363  virtual const std::vector<engine_ptr>& get_engines() const;
1364 
1365 
1366  virtual std::vector<engine_ptr>& get_engines();
1367 
1368 
1369  virtual std::string get_grouping() const;
1370 
1371 
1372  virtual const std::vector<goal_ptr>& get_goals() const;
1373 
1374 
1375  virtual std::vector<goal_ptr>& get_goals();
1376 
1377 
1378  virtual double get_leader_aggression() const;
1379 
1380 
1381  virtual config get_leader_goal() const;
1382 
1383 
1384  virtual bool get_leader_ignores_keep() const;
1385 
1386 
1387  virtual double get_leader_value() const;
1388 
1389 
1390  virtual bool get_passive_leader() const;
1391 
1392 
1393  virtual bool get_passive_leader_shares_keep() const;
1394 
1395 
1396  virtual const moves_map& get_possible_moves() const;
1397 
1398 
1399  virtual const std::vector<unit_ptr>& get_recall_list() const;
1400 
1401 
1402  virtual double get_recruitment_diversity() const;
1403 
1404 
1405  virtual const config get_recruitment_instructions() const;
1406 
1407 
1408  virtual const std::vector<std::string> get_recruitment_more() const;
1409 
1410 
1411  virtual const std::vector<std::string> get_recruitment_pattern() const;
1412 
1413 
1414  virtual int get_recruitment_randomness() const;
1415 
1416 
1417  virtual const config get_recruitment_save_gold() const;
1418 
1419 
1420  virtual double get_scout_village_targeting() const;
1421 
1422 
1423  virtual bool get_simple_targeting() const;
1424 
1425 
1426  virtual const move_map& get_srcdst() const;
1427 
1428 
1429  virtual bool get_support_villages() const;
1430 
1431 
1432  virtual double get_village_value() const;
1433 
1434 
1435  virtual int get_villages_per_scout() const;
1436 
1437 
1438  virtual bool is_active(const std::string &time_of_day, const std::string &turns) const;
1439 
1440  virtual bool is_dst_src_valid_lua() const;
1441 
1442  virtual bool is_dst_src_enemy_valid_lua() const;
1443 
1444  virtual bool is_src_dst_valid_lua() const;
1445 
1446  virtual bool is_src_dst_enemy_valid_lua() const;
1447 
1448  virtual void invalidate_defensive_position_cache() const;
1449 
1450 
1451  virtual void invalidate_move_maps() const;
1452 
1453 
1454  virtual void invalidate_keeps_cache() const;
1455 
1456 
1457  virtual const std::set<map_location>& keeps() const;
1458 
1459 
1460  virtual bool leader_can_reach_keep() const;
1461 
1462 
1463  virtual const map_location& nearest_keep(const map_location& loc) const;
1464 
1465 
1466  virtual double power_projection(const map_location& loc, const move_map& dstsrc) const;
1467 
1468 
1469  virtual void recalculate_move_maps() const;
1470 
1471 
1472  virtual void recalculate_move_maps_enemy() const;
1473 
1474 
1475  virtual void add_aspects(std::vector< aspect_ptr > &aspects);
1476 
1477 
1478  virtual void add_facet(const std::string &id, const config &cfg) const;
1479 
1480 
1481  void on_create();
1482 
1483  virtual void set_dst_src_valid_lua();
1484 
1485  virtual void set_dst_src_enemy_valid_lua();
1486 
1487  virtual void set_src_dst_valid_lua();
1488 
1489  virtual void set_src_dst_enemy_valid_lua();
1490 
1491  virtual const map_location& suitable_keep( const map_location& leader_location, const pathfind::paths& leader_paths );
1492 
1493 
1494  virtual config to_readonly_context_config() const;
1495 
1496 
1497  virtual unit_stats_cache_t & unit_stats_cache() const;
1498 
1499 private:
1500  template<typename T>
1502 
1503  const config cfg_;
1504 
1505  /**
1506  * AI Support Engines
1507  */
1508  std::vector< engine_ptr > engines_;
1509 
1511 
1519  mutable std::map<map_location,defensive_position> defensive_position_cache_;
1525  std::vector< goal_ptr > goals_;
1532  mutable bool move_maps_valid_;
1533  mutable bool dst_src_valid_lua_;
1535  mutable bool src_dst_valid_lua_;
1554 
1555 
1556 };
1557 
1559 public:
1560  /**
1561  * Unwrap - this class is not a proxy, so return *this
1562  */
1564  {
1565  return *this;
1566  }
1567 
1568 
1569  /**
1570  * Ask the game to attack an enemy defender using our unit attacker from attackers current location,
1571  * @param attacker_loc location of attacker
1572  * @param defender_loc location of defender
1573  * @param attacker_weapon weapon of attacker
1574  * @retval possible result: ok
1575  * @retval possible result: something wrong
1576  * @retval possible result: attacker and/or defender are invalid
1577  * @retval possible result: attacker and/or defender are invalid
1578  * @retval possible result: attacker doesn't have the specified weapon
1579  */
1580  virtual attack_result_ptr execute_attack_action(const map_location& attacker_loc, const map_location& defender_loc, int attacker_weapon);
1581 
1582 
1583  /**
1584  * Ask the game to move our unit from location 'from' to location 'to', optionally - doing a partial move
1585  * @param from location of our unit
1586  * @param to where to move
1587  * @param remove_movement set unit movement to 0 in case of successful move
1588  * @retval possible result: ok
1589  * @retval possible result: something wrong
1590  * @retval possible result: move is interrupted
1591  * @retval possible result: move is impossible
1592  */
1593  virtual move_result_ptr execute_move_action(const map_location& from, const map_location& to, bool remove_movement=true, bool unreach_is_ok=false);
1594 
1595 
1596  /**
1597  * Ask the game to recall a unit for us on specified location
1598  * @param id the id of the unit to be recalled.
1599  * @param where location where the unit is to be recalled.
1600  * @retval possible result: ok
1601  * @retval possible_result: something wrong
1602  * @retval possible_result: leader not on keep
1603  * @retval possible_result: no free space on keep
1604  * @retval possible_result: not enough gold
1605  */
1607 
1608 
1609  /**
1610  * Ask the game to recruit a unit for us on specified location
1611  * @param unit_name the name of the unit to be recruited.
1612  * @param where location where the unit is to be recruited.
1613  * @retval possible result: ok
1614  * @retval possible_result: something wrong
1615  * @retval possible_result: leader not on keep
1616  * @retval possible_result: no free space on keep
1617  * @retval possible_result: not enough gold
1618  */
1620 
1621 
1622  /**
1623  * Ask the game to remove unit movements and/or attack
1624  * @param unit_location the location of our unit
1625  * @param remove_movement set remaining movements to 0
1626  * @param remove_attacks set remaining attacks to 0
1627  * @retval possible result: ok
1628  * @retval possible_result: something wrong
1629  * @retval possible_result: nothing to do
1630  */
1631  virtual stopunit_result_ptr execute_stopunit_action(const map_location& unit_location, bool remove_movement = true, bool remove_attacks = false);
1632 
1633 
1634  /**
1635  * Ask the game to run Lua code
1636  * @param lua_code the code to be run
1637  * @param location location to be passed to the code as x1/y1
1638  * @retval possible result: ok
1639  * @retval possible_result: something wrong
1640  * @retval possible_result: nothing to do
1641  */
1643 
1644 
1645  /** Return a reference to the 'team' object for the AI. */
1646  virtual team& current_team_w();
1647 
1648 
1649  /** Notifies all interested observers of the event respectively. */
1650  void raise_gamestate_changed() const;
1651 
1652 
1653  /**
1654  * Constructor.
1655  */
1658  {
1659  init_readonly_context_proxy(context);
1660  }
1661 
1662 
1664  {
1665  }
1666 
1667  /**
1668  * Functions to retrieve the 'info' object.
1669  * Used by derived classes to discover all necessary game information.
1670  */
1671  virtual game_info& get_info_w();
1672 
1673 
1674  virtual int get_recursion_count() const;
1675 
1676 
1677  virtual config to_readwrite_context_config() const;
1678 
1679 private:
1681 };
1682 
1683 
1684 } //end of namespace ai
1685 
1686 #ifdef _MSC_VER
1687 #pragma warning(pop)
1688 #endif
1689 
1690 #endif
aspect_type< std::string >::typesafe_ptr grouping_
Definition: contexts.hpp:1524
virtual side_number get_side() const
Get the side number.
Definition: contexts.hpp:480
virtual void invalidate_defensive_position_cache() const
Definition: contexts.hpp:916
virtual int get_attack_depth() const
Definition: contexts.cpp:555
virtual void set_dst_src_valid_lua()
Definition: contexts.cpp:1216
side_context_impl(side_number side, const config &)
Definition: contexts.hpp:1100
virtual const move_map & get_srcdst() const =0
bool is_ok() const
Check if more recursion is allowed.
Definition: contexts.hpp:92
virtual config get_leader_goal() const
Definition: contexts.cpp:731
virtual void invalidate_keeps_cache() const
Definition: contexts.cpp:926
virtual void set_src_dst_enemy_valid_lua()=0
virtual recall_result_ptr execute_recall_action(const std::string &id, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())=0
virtual bool is_src_dst_valid_lua() const =0
virtual void set_side(side_number side)=0
Set the side number.
GLuint counter
Definition: glew.h:2584
virtual config get_leader_goal() const
Definition: contexts.hpp:770
stopunit_result_ptr check_stopunit_action(const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false)
Check if it is possible to remove unit movements and/or attack.
Definition: contexts.cpp:166
virtual recruit_result_ptr execute_recruit_action(const std::string &unit_name, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())=0
virtual const moves_map & get_possible_moves() const =0
virtual const aspect_map & get_aspects() const =0
virtual side_context & get_side_context()
unwrap
Definition: contexts.hpp:1118
virtual void set_src_dst_valid_lua()=0
virtual void add_aspects(std::vector< aspect_ptr > &aspects)
Definition: contexts.cpp:459
virtual void raise_user_interact() const
Definition: contexts.hpp:610
virtual void invalidate_defensive_position_cache() const =0
attack_result_ptr check_attack_action(const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon)
Check if it is possible to attack enemy defender using our unit attacker from attackers current locat...
Definition: contexts.cpp:123
Definition: unit.hpp:95
void init(const gamemap &map)
Definition: contexts.cpp:978
virtual const std::vector< unit_ptr > & get_recall_list() const =0
virtual bool leader_can_reach_keep() const =0
virtual double get_caution() const
Definition: contexts.hpp:697
virtual side_context & get_side_context()
unwrap
Definition: contexts.hpp:490
virtual double get_recruitment_diversity() const =0
virtual recall_result_ptr check_recall_action(const std::string &id, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())=0
virtual move_result_ptr execute_move_action(const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false)
Ask the game to move our unit from location 'from' to location 'to', optionally - doing a partial mov...
Definition: contexts.cpp:131
virtual ~readwrite_context()
Definition: contexts.hpp:423
virtual stopunit_result_ptr check_stopunit_action(const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false)=0
virtual std::string get_grouping() const =0
virtual recruit_result_ptr check_recruit_action(const std::string &unit_name, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())
Definition: contexts.hpp:572
virtual attack_result_ptr execute_attack_action(const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon)
Definition: contexts.hpp:1027
virtual move_result_ptr check_move_action(const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false)=0
virtual config to_readwrite_context_config() const =0
serialize this context to config
virtual void set_src_dst_enemy_valid_lua()
Definition: contexts.cpp:1231
virtual const config get_recruitment_instructions() const
Definition: contexts.hpp:824
virtual void diagnostic(const std::string &msg)=0
virtual const std::set< map_location > & keeps() const
Definition: contexts.cpp:951
void calculate_possible_moves(std::map< map_location, pathfind::paths > &possible_moves, move_map &srcdst, move_map &dstsrc, bool enemy, bool assume_full_movement=false, const terrain_filter *remove_destinations=nullptr) const
Calculate the moves units may possibly make.
Definition: contexts.cpp:354
virtual bool get_passive_leader_shares_keep() const
Definition: contexts.cpp:767
virtual const std::vector< std::string > get_recruitment_more() const
Definition: contexts.hpp:830
virtual config get_leader_goal() const =0
virtual double get_leader_value() const
Definition: contexts.hpp:782
virtual const map_location & suitable_keep(const map_location &leader_location, const pathfind::paths &leader_paths)=0
get most suitable keep for leader - nearest free that can be reached in 1 turn, if none - return near...
virtual synced_command_result_ptr execute_synced_command_action(const std::string &lua_code, const map_location &location=map_location::null_location())=0
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:50
virtual attack_result_ptr execute_attack_action(const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon)
Ask the game to attack an enemy defender using our unit attacker from attackers current location...
Definition: contexts.cpp:115
aspect_type< double >::typesafe_ptr recruitment_diversity_
Definition: contexts.hpp:1540
virtual int get_recursion_count() const
Get the value of the recursion counter.
Definition: contexts.hpp:495
virtual config to_readwrite_context_config() const
serialize this context to config
Definition: contexts.hpp:1087
virtual void calculate_possible_moves(std::map< map_location, pathfind::paths > &possible_moves, move_map &srcdst, move_map &dstsrc, bool enemy, bool assume_full_movement=false, const terrain_filter *remove_destinations=nullptr) const =0
virtual team & current_team_w()
Definition: contexts.hpp:1063
virtual std::vector< goal_ptr > & get_goals()
Definition: contexts.hpp:757
virtual bool is_dst_src_enemy_valid_lua() const =0
virtual void calculate_moves(const unit_map &units, std::map< map_location, pathfind::paths > &possible_moves, move_map &srcdst, move_map &dstsrc, bool enemy, bool assume_full_movement=false, const terrain_filter *remove_destinations=nullptr, bool see_all=false) const
Definition: contexts.hpp:596
virtual bool is_active(const std::string &time_of_day, const std::string &turns) const =0
virtual double get_aggression() const
Definition: contexts.cpp:546
aspect_type< terrain_filter >::typesafe_ptr avoid_
Definition: contexts.hpp:1517
virtual const map_location & nearest_keep(const map_location &loc) const =0
unit_stats_cache_t unit_stats_cache_
Definition: contexts.hpp:1551
readonly_context_impl(side_context &context, const config &cfg)
Constructor.
Definition: contexts.cpp:188
virtual bool leader_can_reach_keep() const
Definition: contexts.hpp:940
aspect_type< config >::typesafe_ptr recruitment_save_gold_
Definition: contexts.hpp:1545
virtual std::string get_grouping() const
Definition: contexts.hpp:745
aspect_type< double >::typesafe_ptr village_value_
Definition: contexts.hpp:1552
virtual synced_command_result_ptr check_synced_command_action(const std::string &lua_code, const map_location &location=map_location::null_location())=0
synced_command_result_ptr check_synced_command_action(const std::string &lua_code, const map_location &location=map_location::null_location())
Check if it is possible to run Lua code.
Definition: contexts.cpp:176
readwrite_context_impl(readonly_context &context, const config &)
Constructor.
Definition: contexts.hpp:1656
virtual void add_facet(const std::string &id, const config &cfg) const
Definition: contexts.hpp:671
virtual void recalculate_move_maps() const
Definition: contexts.cpp:1174
virtual void set_dst_src_valid_lua()=0
virtual bool get_simple_targeting() const =0
virtual bool get_support_villages() const =0
virtual void invalidate_move_maps() const
Definition: contexts.cpp:938
virtual config to_side_context_config() const
serialize this context to config
Definition: contexts.cpp:285
virtual const move_map & get_enemy_dstsrc() const =0
virtual unit_stats_cache_t & unit_stats_cache() const
Definition: contexts.hpp:995
std::vector< goal_ptr > goals_
Definition: contexts.hpp:1525
virtual config to_side_context_config() const =0
serialize this context to config
virtual ~side_context_proxy()
Definition: contexts.hpp:472
void init_side_context_proxy(side_context &target)
Definition: contexts.hpp:475
virtual unit_stats_cache_t & unit_stats_cache() const
Weapon choice cache, to speed simulations.
Definition: contexts.cpp:1280
virtual const move_map & get_enemy_srcdst() const
Definition: contexts.cpp:642
virtual const move_map & get_enemy_srcdst() const =0
virtual double get_village_value() const =0
readwrite_context * target_
Definition: contexts.hpp:1093
static config unit_name(const unit *u)
Definition: reports.cpp:133
virtual const attacks_vector & get_attacks() const =0
virtual const std::vector< goal_ptr > & get_goals() const
Definition: contexts.hpp:751
side_context * target_
Definition: contexts.hpp:508
virtual const map_location & nearest_keep(const map_location &loc) const
Definition: contexts.hpp:946
virtual int get_villages_per_scout() const
Definition: contexts.hpp:884
virtual bool leader_can_reach_keep() const
Definition: contexts.cpp:1009
virtual const variant & get_attacks_as_variant() const =0
virtual readwrite_context & get_readwrite_context()
Definition: contexts.hpp:1021
aspect_type< double >::typesafe_ptr scout_village_targeting_
Definition: contexts.hpp:1547
Definitions for the interface to Wesnoth Markup Language (WML).
virtual void invalidate_keeps_cache() const =0
virtual const attacks_vector & get_attacks() const
Definition: contexts.hpp:678
virtual void invalidate_defensive_position_cache() const
Definition: contexts.cpp:920
virtual attack_result_ptr check_attack_action(const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon)=0
virtual void log_message(const std::string &msg)
Definition: contexts.hpp:549
virtual const map_location & nearest_keep(const map_location &loc) const
Definition: contexts.cpp:1032
std::map< map_location, defensive_position > defensive_position_cache_
Definition: contexts.hpp:1519
virtual stopunit_result_ptr execute_stopunit_action(const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false)=0
aspect_type< bool >::typesafe_ptr simple_targeting_
Definition: contexts.hpp:1548
virtual const std::set< map_location > & keeps() const
Definition: contexts.hpp:934
virtual bool get_passive_leader() const =0
virtual double get_leader_aggression() const
Definition: contexts.hpp:763
virtual config to_readonly_context_config() const =0
serialize to config
virtual bool is_dst_src_enemy_valid_lua() const
Definition: contexts.hpp:901
virtual const unit_advancements_aspect & get_advancements() const =0
virtual bool get_passive_leader() const
Definition: contexts.cpp:758
virtual double power_projection(const map_location &loc, const move_map &dstsrc) const
Function which finds how much 'power' a side can attack a certain location with.
Definition: contexts.hpp:806
virtual const moves_map & get_enemy_possible_moves() const
Definition: contexts.cpp:633
virtual const std::vector< unit_ptr > & get_recall_list() const
Definition: contexts.hpp:812
static const int MAX_COUNTER_VALUE
Definition: contexts.hpp:86
std::vector< attack_analysis > attacks_vector
Definition: game_info.hpp:56
virtual void set_dst_src_enemy_valid_lua()
Definition: contexts.hpp:968
virtual ~readonly_context()
Definition: contexts.hpp:187
virtual double get_scout_village_targeting() const
Definition: contexts.hpp:860
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:48
std::map< std::string, known_aspect_ptr > known_aspect_map
Definition: game_info.hpp:115
std::multimap< map_location, map_location > move_map
The standard way in which a map of possible moves is recorded.
Definition: game_info.hpp:47
virtual ~readonly_context_proxy()
Definition: contexts.hpp:519
virtual void set_side(side_number side)
Set the side number.
Definition: contexts.hpp:1112
virtual const unit_advancements_aspect & get_advancements() const
Definition: contexts.hpp:635
virtual int get_recursion_count() const
Get the value of the recursion counter.
Definition: contexts.cpp:86
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
A small explanation about what's going on here: Each action has access to two game_info objects First...
Definition: actions.cpp:57
virtual double get_aggression() const
Definition: contexts.hpp:641
virtual const moves_map & get_possible_moves() const
Definition: contexts.hpp:800
virtual int get_recursion_count() const =0
Get the value of the recursion counter.
side_context()
empty constructor
Definition: contexts.hpp:160
virtual const std::vector< unit_ptr > & get_recall_list() const
Definition: contexts.cpp:785
void raise_user_interact() const
Function which should be called frequently to allow the user to interact with the interface...
Definition: contexts.cpp:98
recursion_counter(int counter)
Definition: contexts.hpp:67
virtual bool is_src_dst_enemy_valid_lua() const
Definition: contexts.cpp:915
virtual void on_readonly_context_create()
Definition: contexts.hpp:533
aspect_type< bool >::typesafe_ptr passive_leader_
Definition: contexts.hpp:1537
virtual std::map< map_location, defensive_position > & defensive_position_cache() const
Definition: contexts.cpp:529
virtual bool is_dst_src_valid_lua() const
Definition: contexts.cpp:900
virtual void set_dst_src_valid_lua()
Definition: contexts.hpp:963
virtual double get_leader_aggression() const
Definition: contexts.cpp:722
virtual const terrain_filter & get_avoid() const =0
virtual void add_aspects(std::vector< aspect_ptr > &aspects)=0
virtual int get_attack_depth() const
Definition: contexts.hpp:647
virtual void on_readonly_context_create()=0
virtual unit_stats_cache_t & unit_stats_cache() const =0
aspect_type< double >::typesafe_ptr aggression_
Definition: contexts.hpp:1513
virtual readwrite_context & get_readwrite_context()=0
virtual synced_command_result_ptr execute_synced_command_action(const std::string &lua_code, const map_location &location=map_location::null_location())
Definition: contexts.hpp:1057
virtual engine_ptr get_engine_by_cfg(const config &cfg)
get engine by cfg, creating it if it is not created yet but known
Definition: contexts.cpp:651
virtual const game_info & get_info() const =0
virtual ~readonly_context_impl()
Destructor.
Definition: contexts.cpp:311
virtual const variant & get_attacks_as_variant() const
Definition: contexts.cpp:586
virtual move_result_ptr check_move_action(const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false)
Definition: contexts.hpp:559
aspect_type< int >::typesafe_ptr attack_depth_
Definition: contexts.hpp:1514
virtual const move_map & get_enemy_dstsrc() const
Definition: contexts.cpp:624
Encapsulates the map of the game.
Definition: map.hpp:37
virtual config to_readwrite_context_config() const
serialize this context to config
Definition: contexts.cpp:290
virtual void add_aspects(std::vector< aspect_ptr > &aspects)
Definition: contexts.hpp:665
readonly_context * target_
Definition: contexts.hpp:1002
virtual bool get_leader_ignores_keep() const
Definition: contexts.cpp:740
virtual void set_side(side_number side)
Set the side number.
Definition: contexts.hpp:485
aspect_type< bool >::typesafe_ptr passive_leader_shares_keep_
Definition: contexts.hpp:1538
virtual bool get_leader_ignores_keep() const
Definition: contexts.hpp:776
virtual const move_map & get_dstsrc() const
Definition: contexts.cpp:615
defensive_position const & best_defensive_position(const map_location &unit, const move_map &dstsrc, const move_map &srcdst, const move_map &enemy_dstsrc) const
Definition: contexts.cpp:482
virtual void recalculate_move_maps_enemy() const
Definition: contexts.hpp:958
void log_message(const std::string &msg)
Display a debug message as a chat message.
Definition: contexts.cpp:345
virtual std::map< map_location, defensive_position > & defensive_position_cache() const
Definition: contexts.hpp:629
virtual const std::vector< engine_ptr > & get_engines() const
Definition: contexts.cpp:688
virtual int get_villages_per_scout() const =0
virtual bool is_dst_src_enemy_valid_lua() const
Definition: contexts.cpp:905
virtual const move_map & get_srcdst() const
Definition: contexts.hpp:854
virtual game_info & get_info_w()
Functions to retrieve the 'info' object.
Definition: contexts.cpp:327
virtual void invalidate_move_maps() const
Definition: contexts.hpp:922
Structure describing the statistics of a unit involved in the battle.
Definition: attack.hpp:49
virtual double power_projection(const map_location &loc, const move_map &dstsrc) const =0
Function which finds how much 'power' a side can attack a certain location with.
virtual bool get_passive_leader_shares_keep() const
Definition: contexts.hpp:794
virtual synced_command_result_ptr check_synced_command_action(const std::string &lua_code, const map_location &location=map_location::null_location())
Definition: contexts.hpp:583
virtual const map_location & suitable_keep(const map_location &leader_location, const pathfind::paths &leader_paths)
get most suitable keep for leader - nearest free that can be reached in 1 turn, if none - return near...
Definition: contexts.hpp:983
virtual void calculate_possible_moves(std::map< map_location, pathfind::paths > &possible_moves, move_map &srcdst, move_map &dstsrc, bool enemy, bool assume_full_movement=false, const terrain_filter *remove_destinations=nullptr) const
Definition: contexts.hpp:588
virtual game_info & get_info_w()=0
void add_known_aspect(const std::string &name, boost::shared_ptr< typesafe_aspect< T > > &where)
Definition: contexts.cpp:182
static const map_location & null_location()
Definition: location.hpp:195
virtual bool get_support_villages() const
Definition: contexts.cpp:873
virtual const game_info & get_info() const
Definition: contexts.hpp:605
virtual const config get_recruitment_instructions() const =0
Error used for any general game error, e.g.
Definition: game_errors.hpp:46
virtual int get_recruitment_randomness() const
Definition: contexts.cpp:828
virtual attack_result_ptr execute_attack_action(const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon)=0
virtual const terrain_filter & get_avoid() const
Definition: contexts.cpp:595
std::set< map_location > keeps_
Definition: contexts.hpp:129
virtual side_context & get_side_context()=0
unwrap
virtual const move_map & get_enemy_dstsrc() const
Definition: contexts.hpp:709
recursion_counter recursion_counter_
Definition: contexts.hpp:1131
virtual const moves_map & get_possible_moves() const
Definition: contexts.cpp:776
virtual const move_map & get_enemy_srcdst() const
Definition: contexts.hpp:721
virtual recall_result_ptr execute_recall_action(const std::string &id, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())
Definition: contexts.hpp:1039
aspect_type< config >::typesafe_ptr leader_goal_
Definition: contexts.hpp:1528
virtual double get_recruitment_diversity() const
Definition: contexts.hpp:818
virtual engine_ptr get_engine_by_cfg(const config &cfg)=0
get engine by cfg, creating it if it is not created yet but known
virtual ~side_context()
empty destructor
Definition: contexts.hpp:154
virtual bool get_simple_targeting() const
Definition: contexts.hpp:866
virtual bool is_active(const std::string &time_of_day, const std::string &turns) const
Definition: contexts.hpp:891
Encapsulates the map of the game.
Definition: location.hpp:38
virtual bool is_active(const std::string &time_of_day, const std::string &turns) const
Definition: contexts.cpp:1286
virtual const config get_recruitment_instructions() const
Definition: contexts.cpp:801
virtual const config get_recruitment_save_gold() const
Definition: contexts.hpp:848
virtual std::vector< engine_ptr > & get_engines()
Definition: contexts.hpp:739
virtual readonly_context & get_readonly_context()
Definition: contexts.hpp:527
virtual void raise_gamestate_changed() const =0
virtual void log_message(const std::string &msg)=0
virtual double get_recruitment_diversity() const
Definition: contexts.cpp:792
aspect_type< bool >::typesafe_ptr support_villages_
Definition: contexts.hpp:1550
virtual int get_recursion_count() const
Get the value of the recursion counter.
Definition: contexts.cpp:80
virtual const map_location & suitable_keep(const map_location &leader_location, const pathfind::paths &leader_paths)
get most suitable keep for leader - nearest free that can be reached in 1 turn, if none - return near...
Definition: contexts.cpp:1236
std::vector< engine_ptr > engines_
AI Support Engines.
Definition: contexts.hpp:1508
aspect_type< int >::typesafe_ptr recruitment_randomness_
Definition: contexts.hpp:1544
virtual bool get_support_villages() const
Definition: contexts.hpp:872
int get_count() const
Get the current value of the recursion counter.
Definition: contexts.hpp:79
void diagnostic(const std::string &msg)
Show a diagnostic message on the screen.
Definition: contexts.cpp:331
virtual recruit_result_ptr execute_recruit_action(const std::string &unit_name, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())
Definition: contexts.hpp:1045
virtual recall_result_ptr check_recall_action(const std::string &id, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())
Definition: contexts.hpp:565
Game information for the AI.
virtual const std::vector< goal_ptr > & get_goals() const =0
virtual const team & current_team() const =0
ai_context * ai_context_ptr
Definition: contexts.hpp:61
virtual bool get_passive_leader() const
Definition: contexts.hpp:788
virtual void set_dst_src_enemy_valid_lua()=0
virtual std::map< map_location, defensive_position > & defensive_position_cache() const =0
virtual const std::vector< std::string > get_recruitment_pattern() const
Definition: contexts.cpp:819
virtual const move_map & get_srcdst() const
Definition: contexts.cpp:864
virtual double get_caution() const
Definition: contexts.cpp:607
virtual bool is_src_dst_enemy_valid_lua() const =0
std::map< std::string, aspect_ptr > aspect_map
Definition: game_info.hpp:114
recursion_counter recursion_counter_
Definition: contexts.hpp:1546
virtual void add_facet(const std::string &id, const config &cfg) const =0
virtual const config get_recruitment_save_gold() const
Definition: contexts.cpp:837
virtual aspect_map & get_aspects()
Definition: contexts.hpp:659
virtual const std::vector< goal_ptr > & get_goals() const
Definition: contexts.cpp:709
virtual const std::vector< std::string > get_recruitment_more() const
Definition: contexts.cpp:810
virtual const std::vector< engine_ptr > & get_engines() const =0
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:112
virtual int get_attack_depth() const =0
defensive_position const & best_defensive_position(const map_location &unit, const move_map &dstsrc, const move_map &srcdst, const move_map &enemy_dstsrc) const
Definition: contexts.hpp:622
virtual bool is_src_dst_enemy_valid_lua() const
Definition: contexts.hpp:911
virtual stopunit_result_ptr execute_stopunit_action(const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false)
Definition: contexts.hpp:1051
virtual const std::vector< std::string > get_recruitment_pattern() const =0
virtual void add_facet(const std::string &id, const config &cfg) const
Definition: contexts.cpp:472
virtual bool get_passive_leader_shares_keep() const =0
virtual recruit_result_ptr check_recruit_action(const std::string &unit_name, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())=0
const team & current_team() const
Return a reference to the 'team' object for the AI.
Definition: contexts.cpp:339
aspect_type< bool >::typesafe_ptr leader_ignores_keep_
Definition: contexts.hpp:1529
virtual move_result_ptr execute_move_action(const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false)
Definition: contexts.hpp:1033
virtual int get_recursion_count() const
Get the value of the recursion counter.
Definition: contexts.cpp:92
aspect_type< int >::typesafe_ptr villages_per_scout_
Definition: contexts.hpp:1553
virtual game_info & get_info_w()
Definition: contexts.hpp:1075
virtual const std::vector< std::string > get_recruitment_more() const =0
virtual recall_result_ptr execute_recall_action(const std::string &id, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())
Ask the game to recall a unit for us on specified location.
Definition: contexts.cpp:141
virtual const unit_advancements_aspect & get_advancements() const
Definition: contexts.cpp:535
aspect_type< config >::typesafe_ptr recruitment_instructions_
Definition: contexts.hpp:1541
std::map< std::pair< map_location, const unit_type * >, std::pair< battle_context_unit_stats, battle_context_unit_stats > > unit_stats_cache_t
Definition: contexts.hpp:412
virtual const moves_map & get_enemy_possible_moves() const =0
virtual double get_leader_value() const =0
virtual double power_projection(const map_location &loc, const move_map &dstsrc) const
Function which finds how much 'power' a side can attack a certain location with.
Definition: contexts.cpp:1062
aspect_type< double >::typesafe_ptr leader_aggression_
Definition: contexts.hpp:1527
virtual const game_info & get_info() const
Definition: contexts.cpp:322
virtual void invalidate_move_maps() const =0
aspect_type< double >::typesafe_ptr leader_value_
Definition: contexts.hpp:1530
virtual void on_readonly_context_create()
Definition: contexts.cpp:265
virtual void diagnostic(const std::string &msg)
Definition: contexts.hpp:544
virtual const moves_map & get_enemy_possible_moves() const
Definition: contexts.hpp:715
GLuint const GLchar * name
Definition: glew.h:1782
virtual const team & current_team() const
Definition: contexts.hpp:539
virtual config to_readonly_context_config() const
serialize to config
Definition: contexts.cpp:296
virtual config to_readonly_context_config() const
serialize to config
Definition: contexts.hpp:989
virtual readwrite_context & get_readwrite_context()
Unwrap - this class is not a proxy, so return *this.
Definition: contexts.hpp:1563
virtual bool is_dst_src_valid_lua() const
Definition: contexts.hpp:896
virtual ~side_context_impl()
Definition: contexts.hpp:1105
virtual config to_side_context_config() const
serialize this context to config
Definition: contexts.hpp:501
virtual const aspect_map & get_aspects() const
Definition: contexts.cpp:564
virtual const attacks_vector & get_attacks() const
Definition: contexts.cpp:576
virtual double get_village_value() const
Definition: contexts.cpp:882
virtual void set_dst_src_enemy_valid_lua()
Definition: contexts.cpp:1221
aspect_type< double >::typesafe_ptr caution_
Definition: contexts.hpp:1518
aspect_type< std::vector< std::string > >::typesafe_ptr recruitment_pattern_
Definition: contexts.hpp:1543
recursion_counter recursion_counter_
Definition: contexts.hpp:1680
virtual const config get_recruitment_save_gold() const =0
virtual const move_map & get_dstsrc() const =0
virtual void recalculate_move_maps_enemy() const
Definition: contexts.cpp:1203
virtual const aspect_map & get_aspects() const
Definition: contexts.hpp:653
virtual defensive_position const & best_defensive_position(const map_location &unit, const move_map &dstsrc, const move_map &srcdst, const move_map &enemy_dstsrc) const =0
virtual double get_aggression() const =0
virtual double get_village_value() const
Definition: contexts.hpp:878
virtual readonly_context & get_readonly_context()=0
virtual std::string get_grouping() const
Definition: contexts.cpp:700
virtual int get_recruitment_randomness() const
Definition: contexts.hpp:842
virtual team & current_team_w()
Return a reference to the 'team' object for the AI.
Definition: contexts.cpp:110
known_aspect_map known_aspects_
Definition: contexts.hpp:1510
virtual side_number get_side() const =0
Get the side number.
const gamemap * map_
Definition: contexts.hpp:128
virtual double get_leader_value() const
Definition: contexts.cpp:749
Object which contains all the possible locations a unit can move to, with associated best routes to t...
Definition: pathfind.hpp:71
virtual void recalculate_move_maps() const =0
virtual double get_leader_aggression() const =0
Container associating units to locations.
Definition: map.hpp:90
move_result_ptr check_move_action(const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false)
Check if it is possible to move our unit from location 'from' to location 'to'.
Definition: contexts.cpp:136
aspect_type< std::vector< std::string > >::typesafe_ptr recruitment_more_
Definition: contexts.hpp:1542
virtual int get_recursion_count() const
Get the value of the recursion counter.
Definition: contexts.hpp:1081
virtual void recalculate_move_maps() const
Definition: contexts.hpp:952
void handle_generic_event(const std::string &event_name)
Definition: contexts.cpp:932
void raise_gamestate_changed() const
Notifies all interested observers of the event respectively.
Definition: contexts.cpp:104
void init_readwrite_context_proxy(readwrite_context &target)
Definition: contexts.hpp:1014
virtual bool is_src_dst_valid_lua() const
Definition: contexts.hpp:906
virtual void raise_user_interact() const =0
virtual void raise_gamestate_changed() const
Definition: contexts.hpp:1069
virtual void invalidate_keeps_cache() const
Definition: contexts.hpp:928
int side_number
Definition: game_info.hpp:44
virtual const std::set< map_location > & keeps() const =0
virtual const std::vector< engine_ptr > & get_engines() const
Definition: contexts.hpp:733
virtual void handle_generic_event(const std::string &event_name)
Handle generic event.
Definition: contexts.cpp:316
virtual void calculate_moves(const unit_map &units, std::map< map_location, pathfind::paths > &possible_moves, move_map &srcdst, move_map &dstsrc, bool enemy, bool assume_full_movement=false, const terrain_filter *remove_destinations=nullptr, bool see_all=false) const =0
aspect_type< unit_advancements_aspect >::typesafe_ptr advancements_
Definition: contexts.hpp:1512
virtual void set_src_dst_valid_lua()
Definition: contexts.cpp:1226
virtual double get_scout_village_targeting() const =0
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
virtual const std::vector< std::string > get_recruitment_pattern() const
Definition: contexts.hpp:836
virtual void recalculate_move_maps_enemy() const =0
virtual bool is_dst_src_valid_lua() const =0
virtual attack_result_ptr check_attack_action(const map_location &attacker_loc, const map_location &defender_loc, int attacker_weapon)
Definition: contexts.hpp:554
virtual const terrain_filter & get_avoid() const
Definition: contexts.hpp:691
recruit_result_ptr check_recruit_action(const std::string &unit_name, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())
Check if it is possible to recruit a unit for us on specified location.
Definition: contexts.cpp:156
virtual int get_villages_per_scout() const
Definition: contexts.cpp:891
virtual bool get_simple_targeting() const
Definition: contexts.cpp:855
GLsizei const GLcharARB ** string
Definition: glew.h:4503
virtual engine_ptr get_engine_by_cfg(const config &cfg)
get engine by cfg, creating it if it is not created yet but known
Definition: contexts.hpp:727
virtual void set_src_dst_enemy_valid_lua()
Definition: contexts.hpp:978
unit_map * units
Definition: resources.cpp:35
virtual recruit_result_ptr execute_recruit_action(const std::string &unit_name, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())
Ask the game to recruit a unit for us on specified location.
Definition: contexts.cpp:146
void calculate_moves(const unit_map &units, std::map< map_location, pathfind::paths > &possible_moves, move_map &srcdst, move_map &dstsrc, bool enemy, bool assume_full_movement=false, const terrain_filter *remove_destinations=nullptr, bool see_all=false) const
A more fundamental version of calculate_possible_moves which allows the use of a speculative unit map...
Definition: contexts.cpp:361
virtual int get_recruitment_randomness() const =0
virtual stopunit_result_ptr execute_stopunit_action(const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false)
Ask the game to remove unit movements and/or attack.
Definition: contexts.cpp:161
virtual const move_map & get_dstsrc() const
Definition: contexts.hpp:703
virtual const variant & get_attacks_as_variant() const
Definition: contexts.hpp:685
virtual double get_caution() const =0
virtual team & current_team_w()=0
virtual bool is_src_dst_valid_lua() const
Definition: contexts.cpp:910
recall_result_ptr check_recall_action(const std::string &id, const map_location &where=map_location::null_location(), const map_location &from=map_location::null_location())
Check if it is possible to recall a unit for us on specified location.
Definition: contexts.cpp:151
aspect_type< attacks_vector >::typesafe_ptr attacks_
Definition: contexts.hpp:1516
virtual stopunit_result_ptr check_stopunit_action(const map_location &unit_location, bool remove_movement=true, bool remove_attacks=false)
Definition: contexts.hpp:578
void init_readonly_context_proxy(readonly_context &target)
Definition: contexts.hpp:521
virtual void set_src_dst_valid_lua()
Definition: contexts.hpp:973
virtual side_number get_side() const
Get the side number.
Definition: contexts.hpp:1107
virtual readonly_context & get_readonly_context()
Unwrap - this class is not a proxy, so return *this :w
Definition: contexts.hpp:1154
virtual synced_command_result_ptr execute_synced_command_action(const std::string &lua_code, const map_location &location=map_location::null_location())
Ask the game to run Lua code.
Definition: contexts.cpp:171
virtual int get_recursion_count() const
Get the value of the recursion counter.
Definition: contexts.hpp:616
virtual move_result_ptr execute_move_action(const map_location &from, const map_location &to, bool remove_movement=true, bool unreach_is_ok=false)=0
virtual bool get_leader_ignores_keep() const =0
virtual double get_scout_village_targeting() const
Definition: contexts.cpp:846