The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ai::engine_lua Class Reference

#include <engine_lua.hpp>

Inheritance diagram for ai::engine_lua:

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_contextget_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 componentget_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_mapproperty_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_contextlua_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_contextai_
 
ai_context_ptr ai_context_
 
std::string engine_
 name of the engine which has created this engine More...
 
std::string id_
 
std::string name_
 

Detailed Description

Definition at line 30 of file engine_lua.hpp.

Constructor & Destructor Documentation

◆ engine_lua()

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_.

◆ ~engine_lua()

ai::engine_lua::~engine_lua ( )
virtual

Definition at line 288 of file engine_lua.cpp.

Member Function Documentation

◆ apply_micro_ai()

void ai::engine_lua::apply_micro_ai ( const config cfg)

Definition at line 386 of file engine_lua.cpp.

References lua_ai_context_.

◆ do_parse_aspect_from_config()

void ai::engine_lua::do_parse_aspect_from_config ( const config cfg,
const std::string &  id,
std::back_insert_iterator< std::vector< aspect_ptr > >  b 
)
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_.

◆ do_parse_candidate_action_from_config()

void ai::engine_lua::do_parse_candidate_action_from_config ( rca_context context,
const config cfg,
std::back_insert_iterator< std::vector< candidate_action_ptr > >  b 
)
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_.

◆ do_parse_goal_from_config()

void ai::engine_lua::do_parse_goal_from_config ( const config cfg,
std::back_insert_iterator< std::vector< goal_ptr > >  b 
)
virtual

◆ do_parse_stage_from_config()

void ai::engine_lua::do_parse_stage_from_config ( ai_context context,
const config cfg,
std::back_insert_iterator< std::vector< stage_ptr > >  b 
)
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_.

◆ evaluate()

std::string ai::engine_lua::evaluate ( const std::string &  str)
virtual

Reimplemented from ai::engine.

Definition at line 379 of file engine_lua.cpp.

◆ get_engine_code()

std::string ai::engine_lua::get_engine_code ( const config cfg) const
private

Definition at line 278 of file engine_lua.cpp.

References config::has_attribute().

◆ is_ok()

bool ai::engine_lua::is_ok ( ) const
virtual

Reimplemented from ai::engine.

Definition at line 292 of file engine_lua.cpp.

References lua_ai_context_.

◆ push_ai_table()

void ai::engine_lua::push_ai_table ( )
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().

◆ to_config()

config ai::engine_lua::to_config ( ) const
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().

Member Data Documentation

◆ code_

std::string ai::engine_lua::code_
private

The underlying lua code.

Definition at line 86 of file engine_lua.hpp.

Referenced by to_config().

◆ lua_ai_context_

std::shared_ptr<lua_ai_context> ai::engine_lua::lua_ai_context_
private

The documentation for this class was generated from the following files: