00001 /* $Id: ai.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2009 - 2012 by Yurii Chernyi <terraninfo@terraninfo.net> 00004 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY. 00012 00013 See the COPYING file for more details. 00014 */ 00015 00016 /** 00017 * @file 00018 * Composite AI with turn sequence which is a vector of stages 00019 */ 00020 00021 #ifndef AI_COMPOSITE_AI_HPP_INCLUDED 00022 #define AI_COMPOSITE_AI_HPP_INCLUDED 00023 00024 #include "contexts.hpp" 00025 #include "../interface.hpp" 00026 #include "component.hpp" 00027 00028 #ifdef _MSC_VER 00029 #pragma warning(push) 00030 //silence "inherits via dominance" warnings 00031 #pragma warning(disable:4250) 00032 #endif 00033 00034 //============================================================================ 00035 namespace ai { 00036 00037 class ai_composite : public ai_context, public virtual default_ai_context_proxy, public interface, public component { 00038 public: 00039 00040 00041 /** 00042 * Constructor 00043 */ 00044 ai_composite( default_ai_context &context, const config &cfg ); 00045 00046 00047 /** 00048 * Destructor 00049 */ 00050 virtual ~ai_composite(); 00051 00052 00053 /** 00054 * Play the turn 00055 */ 00056 void play_turn(); 00057 00058 00059 /** 00060 * Evaluate command (using fai) 00061 */ 00062 virtual std::string evaluate(const std::string& str); 00063 00064 /** 00065 * On new turn 00066 */ 00067 virtual void new_turn(); 00068 00069 00070 std::string describe_self() const; 00071 00072 /** 00073 * serialize 00074 */ 00075 virtual config to_config() const; 00076 00077 00078 int get_recursion_count() const; 00079 00080 00081 void switch_side(side_number side); 00082 00083 00084 virtual bool add_goal(const config &cfg); 00085 00086 00087 virtual bool add_stage(const config &cfg); 00088 00089 00090 void create_stage(std::vector<stage_ptr> &stages, const config &cfg); 00091 00092 00093 void create_goal(std::vector<goal_ptr> &goals, const config &cfg); 00094 00095 00096 void create_engine(std::vector<engine_ptr> &engines, const config &cfg); 00097 00098 00099 void on_create(); 00100 00101 /** 00102 * unwrap 00103 */ 00104 virtual ai_context& get_ai_context(); 00105 00106 00107 virtual std::string get_id() const; 00108 virtual std::string get_name() const; 00109 virtual std::string get_engine() const; 00110 00111 protected: 00112 00113 /** 00114 * Config of the AI 00115 */ 00116 const config &cfg_; 00117 00118 00119 /** 00120 * Stages of the composite AI 00121 */ 00122 std::vector< stage_ptr > stages_; 00123 00124 00125 /** 00126 * Recursion counter 00127 */ 00128 recursion_counter recursion_counter_; 00129 }; 00130 00131 } //end of namespace ai 00132 00133 #ifdef _MSC_VER 00134 #pragma warning(pop) 00135 #endif 00136 00137 #endif
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:28 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |