#include <engine_lua.hpp>
Public Member Functions | |
engine_lua (readonly_context &context, const config &cfg) | |
Note that initially we get access only to readonly context (engine is created rather early, when there's no way to move/attack. More... | |
virtual | ~engine_lua () |
bool | is_ok () const |
virtual void | do_parse_candidate_action_from_config (rca_context &context, const config &cfg, std::back_insert_iterator< std::vector< candidate_action_ptr > > b) |
Taka a config (with engine=lua in it) and parse several (usually, 1) candidate actions out of it. More... | |
virtual void | do_parse_stage_from_config (ai_context &context, const config &cfg, std::back_insert_iterator< std::vector< stage_ptr > > b) |
Taka a config (with engine=lua in it) and parse several (usually, 1) stages out of it. More... | |
virtual void | do_parse_aspect_from_config (const config &cfg, const std::string &id, std::back_insert_iterator< std::vector< aspect_ptr > > b) |
Taka a config (with engine=lua in it) and parse several (usually, 1) aspects out of it. More... | |
virtual void | do_parse_goal_from_config (const config &cfg, std::back_insert_iterator< std::vector< goal_ptr > > b) |
virtual std::string | evaluate (const std::string &str) |
void | apply_micro_ai (const config &cfg) |
virtual void | push_ai_table () |
Method that pushes the AI table of the lua_context on the stack for debugging purposes. More... | |
virtual config | to_config () const |
Serialize to config. More... | |
Public Member Functions inherited from ai::engine | |
engine (readonly_context &context, const config &cfg) | |
virtual | ~engine () |
virtual void | do_parse_aspect_from_config (const config &cfg, const std::string &id, std::back_insert_iterator< std::vector< aspect_ptr >> b) |
virtual void | do_parse_candidate_action_from_config (rca_context &context, const config &cfg, std::back_insert_iterator< std::vector< candidate_action_ptr >> b) |
virtual void | do_parse_goal_from_config (const config &cfg, std::back_insert_iterator< std::vector< goal_ptr >> b) |
virtual void | do_parse_engine_from_config (const config &cfg, std::back_insert_iterator< std::vector< engine_ptr >> b) |
virtual void | do_parse_stage_from_config (ai_context &context, const config &cfg, std::back_insert_iterator< std::vector< stage_ptr >> b) |
readonly_context & | get_readonly_context () |
virtual void | set_ai_context (ai_context_ptr context) |
set ai context (which is not available during early initialization) More... | |
virtual ai_context_ptr | get_ai_context () |
virtual std::string | get_id () const |
virtual std::string | get_engine () const |
virtual std::string | get_name () const |
Public Member Functions inherited from ai::component | |
component () | |
virtual | ~component () |
virtual component * | get_child (const path_element &child) |
virtual std::vector< component * > | get_children (const std::string &type) |
virtual std::vector< std::string > | get_children_types () |
virtual bool | change_child (const path_element &child, const config &cfg) |
virtual bool | add_child (const path_element &child, const config &cfg) |
virtual bool | delete_child (const path_element &child) |
property_handler_map & | property_handlers () |
Private Member Functions | |
std::string | get_engine_code (const config &) const |
Private Attributes | |
std::string | code_ |
The underlying lua code. More... | |
std::shared_ptr< lua_ai_context > | lua_ai_context_ |
Additional Inherited Members | |
Static Public Member Functions inherited from ai::engine | |
static void | parse_aspect_from_config (readonly_context &context, const config &cfg, const std::string &id, std::back_insert_iterator< std::vector< aspect_ptr >> b) |
static void | parse_goal_from_config (readonly_context &context, const config &cfg, std::back_insert_iterator< std::vector< goal_ptr >> b) |
static void | parse_candidate_action_from_config (rca_context &context, const config &cfg, std::back_insert_iterator< std::vector< candidate_action_ptr >> b) |
static void | parse_engine_from_config (readonly_context &context, const config &cfg, std::back_insert_iterator< std::vector< engine_ptr >> b) |
static void | parse_stage_from_config (ai_context &context, const config &cfg, std::back_insert_iterator< std::vector< stage_ptr >> b) |
Protected Attributes inherited from ai::engine | |
readonly_context & | ai_ |
ai_context_ptr | ai_context_ |
std::string | engine_ |
name of the engine which has created this engine More... | |
std::string | id_ |
std::string | name_ |
Definition at line 30 of file engine_lua.hpp.
ai::engine_lua::engine_lua | ( | readonly_context & | context, |
const config & | cfg | ||
) |
Note that initially we get access only to readonly context (engine is created rather early, when there's no way to move/attack.
We inject full ai_context later.
Definition at line 261 of file engine_lua.cpp.
References config::child_or_empty(), data, lua_ai_context_, and ai::engine::name_.
|
virtual |
Definition at line 288 of file engine_lua.cpp.
void ai::engine_lua::apply_micro_ai | ( | const config & | cfg | ) |
Definition at line 386 of file engine_lua.cpp.
References lua_ai_context_.
|
virtual |
Taka a config (with engine=lua in it) and parse several (usually, 1) aspects out of it.
Definition at line 342 of file engine_lua.cpp.
References ai::engine::ai_, b, DBG_AI_LUA, ERR_AI_LUA, f, ai::lua_aspect_factory::get_list(), ai::side_context::get_side(), and lua_ai_context_.
|
virtual |
Taka a config (with engine=lua in it) and parse several (usually, 1) candidate actions out of it.
Definition at line 305 of file engine_lua.cpp.
References b, config::has_attribute(), and lua_ai_context_.
|
virtual |
Definition at line 361 of file engine_lua.cpp.
References ai::engine::ai_, b, DBG_AI_LUA, ERR_AI_LUA, f, ai::goal_factory::get_list(), ai::side_context::get_side(), and lua_ai_context_.
|
virtual |
Taka a config (with engine=lua in it) and parse several (usually, 1) stages out of it.
Definition at line 330 of file engine_lua.cpp.
References b, and lua_ai_context_.
|
virtual |
Reimplemented from ai::engine.
Definition at line 379 of file engine_lua.cpp.
|
private |
Definition at line 278 of file engine_lua.cpp.
References config::has_attribute().
|
virtual |
Reimplemented from ai::engine.
Definition at line 292 of file engine_lua.cpp.
References lua_ai_context_.
|
virtual |
Method that pushes the AI table of the lua_context on the stack for debugging purposes.
Definition at line 297 of file engine_lua.cpp.
References game_config::debug, and lua_ai_context_.
Referenced by intf_debug_ai().
|
virtual |
Serialize to config.
Reimplemented from ai::engine.
Definition at line 391 of file engine_lua.cpp.
References config::add_child(), code_, data, ai::engine::get_id(), lua_ai_context_, and ai::engine::to_config().
Referenced by intf_debug_ai().
|
private |
|
private |
Definition at line 89 of file engine_lua.hpp.
Referenced by apply_micro_ai(), do_parse_aspect_from_config(), do_parse_candidate_action_from_config(), do_parse_goal_from_config(), do_parse_stage_from_config(), engine_lua(), is_ok(), push_ai_table(), and to_config().