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