ai/composite/engine_lua.hpp

Go to the documentation of this file.
00001 /* $Id: engine_lua.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  * LUA AI Support engine - creating specific ai components from config
00018  * @file
00019  */
00020 
00021 #ifndef AI_COMPOSITE_ENGINE_LUA_HPP_INCLUDED
00022 #define AI_COMPOSITE_ENGINE_LUA_HPP_INCLUDED
00023 
00024 #include "engine.hpp"
00025 
00026 //============================================================================
00027 namespace ai {
00028 
00029 class lua_ai_context;
00030 
00031 class engine_lua : public engine {
00032 public:
00033     engine_lua( readonly_context &context, const config &cfg );
00034 
00035     virtual ~engine_lua();
00036 
00037     /**
00038      * Taka a config (with engine=lua in it)
00039      * and parse several (usually, 1) candidate actions out of it
00040      */
00041     virtual void do_parse_candidate_action_from_config( rca_context &context, const config &cfg, std::back_insert_iterator<std::vector< candidate_action_ptr > > b );
00042 
00043     /**
00044      * Taka a config (with engine=lua in it)
00045      * and parse several (usually, 1) stages out of it
00046      */
00047     virtual void do_parse_stage_from_config( ai_context &context, const config &cfg, std::back_insert_iterator<std::vector< stage_ptr > > b );
00048 
00049     /**
00050      * Taka a config (with engine=lua in it)
00051      * and parse several (usually, 1) aspects out of it
00052      */
00053     virtual void do_parse_aspect_from_config( const config &cfg, const std::string &id, std::back_insert_iterator<std::vector< aspect_ptr > > b );
00054 
00055     virtual void do_parse_goal_from_config(const config &cfg, std::back_insert_iterator<std::vector< goal_ptr > > b );
00056 
00057     virtual std::string evaluate(const std::string &str);
00058 
00059     /**
00060      * Serialize to config
00061      */
00062     virtual config to_config() const;
00063 
00064 //  /**
00065 //   * Method to inject AI context into the engine.
00066 //   * The context includes all that in necessary for the AI -
00067 //   * , like access to game state and movement/attack routines.
00068 //   */
00069 //  virtual void set_ai_context(ai_context *context);
00070 
00071 private:
00072 
00073     /**
00074      * The underlying lua code
00075      */
00076     std::string code_;
00077 
00078     //There is one lua engine per AI. So, it can hold state
00079     boost::shared_ptr<lua_ai_context> lua_ai_context_;
00080 
00081 };
00082 
00083 } //end of namespace ai
00084 
00085 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:28 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs