AI: stub code for default_ai_testing
This commit is contained in:
parent
3d25902cc5
commit
2fc7380aa3
9 changed files with 293 additions and 58 deletions
|
@ -13,10 +13,33 @@ ai_algorithm=composite_ai
|
|||
engine=cpp
|
||||
name=testing_ai_default::recruitment_phase
|
||||
[/candidate_action]
|
||||
[/stage]
|
||||
[stage]
|
||||
engine=cpp
|
||||
name=testing_ai_default::fallback
|
||||
fallback=default
|
||||
[candidate_action]
|
||||
engine=cpp
|
||||
name=testing_ai_default::combat_phase
|
||||
[/candidate_action]
|
||||
[candidate_action]
|
||||
engine=cpp
|
||||
name=testing_ai_default::move_leader_to_goals_phase
|
||||
[/candidate_action]
|
||||
[candidate_action]
|
||||
engine=cpp
|
||||
name=testing_ai_default::get_villages_phase
|
||||
[/candidate_action]
|
||||
[candidate_action]
|
||||
engine=cpp
|
||||
name=testing_ai_default::get_healing_phase
|
||||
[/candidate_action]
|
||||
[candidate_action]
|
||||
engine=cpp
|
||||
name=testing_ai_default::retreat_phase
|
||||
[/candidate_action]
|
||||
[candidate_action]
|
||||
engine=cpp
|
||||
name=testing_ai_default::move_and_targeting_phase
|
||||
[/candidate_action]
|
||||
[candidate_action]
|
||||
engine=cpp
|
||||
name=testing_ai_default::leader_control_phase
|
||||
[/candidate_action]
|
||||
[/stage]
|
||||
[/ai]
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
* Evaluate the candidate action, resetting the internal state of the action
|
||||
* @return the score
|
||||
* @retval >0 if the action is good
|
||||
* @retval <0 if the action is not good
|
||||
* @retval <=0 if the action is not good
|
||||
*/
|
||||
virtual double evaluate() = 0;
|
||||
|
||||
|
|
|
@ -67,6 +67,26 @@ static composite_ai::register_candidate_action_factory<testing_ai_default::goto_
|
|||
static composite_ai::register_candidate_action_factory<testing_ai_default::recruitment_phase>
|
||||
recruitment_phase_factory("testing_ai_default::recruitment_phase");
|
||||
|
||||
static composite_ai::register_candidate_action_factory<testing_ai_default::combat_phase>
|
||||
combat_phase_factory("testing_ai_default::combat_phase");
|
||||
|
||||
static composite_ai::register_candidate_action_factory<testing_ai_default::move_leader_to_goals_phase>
|
||||
move_leader_to_goals_phase_factory("testing_ai_default::move_leader_to_goals_phase");
|
||||
|
||||
static composite_ai::register_candidate_action_factory<testing_ai_default::get_villages_phase>
|
||||
get_villages_phase_factory("testing_ai_default::get_villages_phase");
|
||||
|
||||
static composite_ai::register_candidate_action_factory<testing_ai_default::get_healing_phase>
|
||||
get_healing_phase_factory("testing_ai_default::get_healing_phase");
|
||||
|
||||
static composite_ai::register_candidate_action_factory<testing_ai_default::retreat_phase>
|
||||
retreat_phase_factory("testing_ai_default::retreat_phase");
|
||||
|
||||
static composite_ai::register_candidate_action_factory<testing_ai_default::move_and_targeting_phase>
|
||||
move_and_targeting_phase_factory("testing_ai_default::move_and_targeting_phase");
|
||||
|
||||
static composite_ai::register_candidate_action_factory<testing_ai_default::leader_control_phase>
|
||||
leader_control_phase_factory("testing_ai_default::leader_control_phase");
|
||||
|
||||
void registry::init()
|
||||
{
|
||||
|
|
|
@ -29,9 +29,13 @@ static lg::log_domain log_ai_testing_ai_default("ai/testing/ai_default");
|
|||
#define ERR_AI_TESTING_AI_DEFAULT LOG_STREAM(err, log_ai_testing_ai_default)
|
||||
|
||||
|
||||
namespace ai {
|
||||
|
||||
namespace testing_ai_default {
|
||||
|
||||
goto_phase::goto_phase( ai::composite_ai::rca_context &context, const config &cfg )
|
||||
//==============================================================
|
||||
|
||||
goto_phase::goto_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::goto_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
@ -52,11 +56,14 @@ bool goto_phase::execute()
|
|||
return true;
|
||||
}
|
||||
|
||||
recruitment_phase::recruitment_phase( ai::composite_ai::rca_context &context, const config &cfg )
|
||||
//==============================================================
|
||||
|
||||
recruitment_phase::recruitment_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::recruitment_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
recruitment_phase::~recruitment_phase()
|
||||
{
|
||||
}
|
||||
|
@ -73,5 +80,169 @@ bool recruitment_phase::execute()
|
|||
return true;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
combat_phase::combat_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::combat_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
||||
combat_phase::~combat_phase()
|
||||
{
|
||||
}
|
||||
|
||||
double combat_phase::evaluate()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": evaluate - not yet implemented!" << std::endl;
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
bool combat_phase::execute()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": execute - not yet implemented!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
move_leader_to_goals_phase::move_leader_to_goals_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::move_leader_to_goals_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
||||
move_leader_to_goals_phase::~move_leader_to_goals_phase()
|
||||
{
|
||||
}
|
||||
|
||||
double move_leader_to_goals_phase::evaluate()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": evaluate - not yet implemented!" << std::endl;
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
bool move_leader_to_goals_phase::execute()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": execute - not yet implemented!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
get_villages_phase::get_villages_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::get_villages_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
||||
get_villages_phase::~get_villages_phase()
|
||||
{
|
||||
}
|
||||
|
||||
double get_villages_phase::evaluate()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": evaluate - not yet implemented!" << std::endl;
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
bool get_villages_phase::execute()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": execute - not yet implemented!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
get_healing_phase::get_healing_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::get_healing_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
||||
get_healing_phase::~get_healing_phase()
|
||||
{
|
||||
}
|
||||
|
||||
double get_healing_phase::evaluate()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": evaluate - not yet implemented!" << std::endl;
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
bool get_healing_phase::execute()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": execute - not yet implemented!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
retreat_phase::retreat_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::retreat_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
||||
retreat_phase::~retreat_phase()
|
||||
{
|
||||
}
|
||||
|
||||
double retreat_phase::evaluate()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": evaluate - not yet implemented!" << std::endl;
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
bool retreat_phase::execute()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": execute - not yet implemented!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
move_and_targeting_phase::move_and_targeting_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::move_and_targeting_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
||||
move_and_targeting_phase::~move_and_targeting_phase()
|
||||
{
|
||||
}
|
||||
|
||||
double move_and_targeting_phase::evaluate()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": evaluate - not yet implemented!" << std::endl;
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
bool move_and_targeting_phase::execute()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": execute - not yet implemented!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
leader_control_phase::leader_control_phase( rca_context &context, const config &cfg )
|
||||
: candidate_action(context,"testing_ai_default::leader_control_phase",cfg["type"])
|
||||
{
|
||||
}
|
||||
|
||||
leader_control_phase::~leader_control_phase()
|
||||
{
|
||||
}
|
||||
|
||||
double leader_control_phase::evaluate()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": evaluate - not yet implemented!" << std::endl;
|
||||
return BAD_SCORE;
|
||||
}
|
||||
|
||||
bool leader_control_phase::execute()
|
||||
{
|
||||
ERR_AI_TESTING_AI_DEFAULT << get_name() << ": execute - not yet implemented!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
|
||||
} //end of namespace testing_ai_default
|
||||
|
||||
} //end of namespace ai
|
||||
|
|
|
@ -25,14 +25,19 @@
|
|||
#include "../composite/rca.hpp"
|
||||
#include "../composite/engine_default.hpp"
|
||||
|
||||
namespace ai {
|
||||
|
||||
namespace testing_ai_default {
|
||||
|
||||
using composite_ai::rca_context;
|
||||
using composite_ai::candidate_action;
|
||||
|
||||
//============================================================================
|
||||
|
||||
class goto_phase : public ai::composite_ai::candidate_action {
|
||||
class goto_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
goto_phase( ai::composite_ai::rca_context &context, const config &cfg );
|
||||
goto_phase( rca_context &context, const config &cfg );
|
||||
|
||||
virtual ~goto_phase();
|
||||
|
||||
|
@ -44,10 +49,10 @@ public:
|
|||
|
||||
//============================================================================
|
||||
|
||||
class recruitment_phase : public ai::composite_ai::candidate_action {
|
||||
class recruitment_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
recruitment_phase( ai::composite_ai::rca_context &context, const config &cfg );
|
||||
recruitment_phase( rca_context &context, const config &cfg );
|
||||
|
||||
virtual ~recruitment_phase();
|
||||
|
||||
|
@ -56,117 +61,117 @@ public:
|
|||
virtual bool execute();
|
||||
|
||||
};
|
||||
/*
|
||||
|
||||
//============================================================================
|
||||
|
||||
class combat_phase : public ai_candidate_action {
|
||||
class combat_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
combat_phase( ai_readonly_context& ai, const std::string& name, const std::string& type );
|
||||
combat_phase( rca_context &context, const config &cfg );
|
||||
|
||||
virtual ~combat_phase();
|
||||
|
||||
virtual double evaluate();
|
||||
|
||||
virtual bool execute(ai_readwrite_context& context);
|
||||
virtual bool execute();
|
||||
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
||||
class move_leader_to_goals_phase : public ai_candidate_action {
|
||||
class move_leader_to_goals_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
move_leader_to_goals_phase( ai_readonly_context& ai, const std::string& name, const std::string& type );
|
||||
move_leader_to_goals_phase( rca_context &context, const config &cfg );
|
||||
|
||||
virtual ~move_leader_to_goals_phase();
|
||||
|
||||
virtual double evaluate();
|
||||
|
||||
virtual bool execute(ai_readwrite_context& ai);
|
||||
virtual bool execute();
|
||||
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
||||
class get_villages_phase : public ai_candidate_action {
|
||||
class get_villages_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
get_villages_phase( ai_readonly_context& ai, const std::string& name, const std::string& type );
|
||||
get_villages_phase( rca_context &context, const config& cfg );
|
||||
|
||||
virtual ~get_villages_phase();
|
||||
|
||||
virtual double evaluate();
|
||||
|
||||
virtual bool execute(ai_readwrite_context& ai);
|
||||
virtual bool execute();
|
||||
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
||||
class get_healing_phase : public ai_candidate_action {
|
||||
class get_healing_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
get_healing_phase( ai_readonly_context& ai, const std::string& name, const std::string& type );
|
||||
get_healing_phase( rca_context &context, const config& cfg );
|
||||
|
||||
virtual ~get_healing_phase();
|
||||
|
||||
virtual double evaluate();
|
||||
|
||||
virtual bool execute(ai_readwrite_context& ai);
|
||||
virtual bool execute();
|
||||
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
||||
class retreat_phase : public ai_candidate_action {
|
||||
class retreat_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
retreat_phase( ai_readonly_context& ai, const std::string& name, const std::string& type );
|
||||
retreat_phase( rca_context &context, const config &cfg );
|
||||
|
||||
virtual ~retreat_phase();
|
||||
|
||||
virtual double evaluate();
|
||||
|
||||
virtual bool execute(ai_readwrite_context& ai);
|
||||
virtual bool execute();
|
||||
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
||||
class move_and_targeting_phase : public ai_candidate_action {
|
||||
class move_and_targeting_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
move_and_targeting_phase( ai_readonly_context& ai, const std::string& name, const std::string& type );
|
||||
move_and_targeting_phase( rca_context &context, const config &cfg );
|
||||
|
||||
virtual ~move_and_targeting_phase();
|
||||
|
||||
virtual double evaluate();
|
||||
|
||||
virtual bool execute(ai_readwrite_context& ai);
|
||||
virtual bool execute();
|
||||
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
||||
class leader_control_phase : public ai_candidate_action {
|
||||
class leader_control_phase : public candidate_action {
|
||||
public:
|
||||
|
||||
leader_control_phase( ai_readonly_context& ai, const std::string& name, const std::string& type );
|
||||
leader_control_phase( rca_context &context, const config &cfg );
|
||||
|
||||
virtual ~leader_control_phase();
|
||||
|
||||
virtual double evaluate();
|
||||
|
||||
virtual bool execute(ai_readwrite_context& ai);
|
||||
virtual bool execute();
|
||||
|
||||
};
|
||||
|
||||
|
||||
//============================================================================
|
||||
|
||||
*/
|
||||
} // end of namespace testing_ai_default
|
||||
|
||||
}
|
||||
} // end of namespace ai
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "../../foreach.hpp"
|
||||
#include "../../log.hpp"
|
||||
|
||||
namespace ai {
|
||||
|
||||
namespace testing_ai_default {
|
||||
|
||||
static lg::log_domain log_ai_testing_stage_fallback("ai/testing/stage_fallback");
|
||||
|
@ -31,14 +33,14 @@ static lg::log_domain log_ai_testing_stage_fallback("ai/testing/stage_fallback")
|
|||
#define LOG_AI_TESTING_STAGE_FALLBACK LOG_STREAM(info, log_ai_testing_stage_fallback)
|
||||
#define ERR_AI_TESTING_STAGE_FALLBACK LOG_STREAM(err, log_ai_testing_stage_fallback)
|
||||
|
||||
fallback_to_other_ai::fallback_to_other_ai( ai::composite_ai::composite_ai_context &context, const config &cfg )
|
||||
fallback_to_other_ai::fallback_to_other_ai( composite_ai::composite_ai_context &context, const config &cfg )
|
||||
: stage(context,cfg), cfg_(cfg), fallback_ai_()
|
||||
{
|
||||
}
|
||||
|
||||
void fallback_to_other_ai::on_create()
|
||||
{
|
||||
fallback_ai_ = ai::manager::create_transient_ai(cfg_["fallback"], this);
|
||||
fallback_ai_ = manager::create_transient_ai(cfg_["fallback"], this);
|
||||
}
|
||||
|
||||
void fallback_to_other_ai::do_play_stage()
|
||||
|
@ -55,4 +57,6 @@ fallback_to_other_ai::~fallback_to_other_ai()
|
|||
{
|
||||
}
|
||||
|
||||
} // of namespace testing_ai_default
|
||||
} // end of namespace testing_ai_default
|
||||
|
||||
} // end of namespace ai
|
||||
|
|
|
@ -28,11 +28,13 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
namespace ai {
|
||||
|
||||
namespace testing_ai_default {
|
||||
|
||||
class fallback_to_other_ai: public ai::composite_ai::stage {
|
||||
class fallback_to_other_ai: public composite_ai::stage {
|
||||
public:
|
||||
fallback_to_other_ai( ai::composite_ai::composite_ai_context &context, const config &cfg );
|
||||
fallback_to_other_ai( composite_ai::composite_ai_context &context, const config &cfg );
|
||||
|
||||
~fallback_to_other_ai();
|
||||
|
||||
|
@ -43,9 +45,11 @@ public:
|
|||
private:
|
||||
const config &cfg_;
|
||||
|
||||
ai::ai_ptr fallback_ai_;
|
||||
ai_ptr fallback_ai_;
|
||||
};
|
||||
|
||||
} // end of namespace testing_ai_default
|
||||
|
||||
} // end of namespace ai
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "../../foreach.hpp"
|
||||
#include "../../log.hpp"
|
||||
|
||||
namespace ai {
|
||||
|
||||
namespace testing_ai_default {
|
||||
|
||||
static lg::log_domain log_ai_testing_rca_default("ai/testing/rca_default");
|
||||
|
@ -30,7 +32,7 @@ static lg::log_domain log_ai_testing_rca_default("ai/testing/rca_default");
|
|||
#define LOG_AI_TESTING_RCA_DEFAULT LOG_STREAM(info, log_ai_testing_rca_default)
|
||||
#define ERR_AI_TESTING_RCA_DEFAULT LOG_STREAM(err, log_ai_testing_rca_default)
|
||||
|
||||
candidate_action_evaluation_loop::candidate_action_evaluation_loop( ai::composite_ai::composite_ai_context &context, const config &cfg)
|
||||
candidate_action_evaluation_loop::candidate_action_evaluation_loop( composite_ai::composite_ai_context &context, const config &cfg)
|
||||
: stage(context,cfg),cfg_(cfg)
|
||||
{
|
||||
}
|
||||
|
@ -39,7 +41,7 @@ void candidate_action_evaluation_loop::on_create()
|
|||
{
|
||||
//init the candidate actions
|
||||
foreach(const config &cfg_element, cfg_.child_range("candidate_action")){
|
||||
ai::composite_ai::engine::parse_candidate_action_from_config(*this,cfg_element,back_inserter(candidate_actions_));
|
||||
composite_ai::engine::parse_candidate_action_from_config(*this,cfg_element,back_inserter(candidate_actions_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,18 +50,18 @@ void candidate_action_evaluation_loop::do_play_stage()
|
|||
LOG_AI_TESTING_RCA_DEFAULT << "Starting candidate action evaluation loop for side "<< get_side() << std::endl;
|
||||
const static double STOP_VALUE = 0;
|
||||
|
||||
foreach(ai::composite_ai::candidate_action_ptr ca, candidate_actions_){
|
||||
foreach(composite_ai::candidate_action_ptr ca, candidate_actions_){
|
||||
ca->enable();
|
||||
}
|
||||
|
||||
bool executed = false;
|
||||
do {
|
||||
executed = false;
|
||||
double best_score = ai::composite_ai::candidate_action::BAD_SCORE;
|
||||
ai::composite_ai::candidate_action_ptr best_ptr;
|
||||
double best_score = composite_ai::candidate_action::BAD_SCORE;
|
||||
composite_ai::candidate_action_ptr best_ptr;
|
||||
|
||||
//Evaluation
|
||||
foreach(ai::composite_ai::candidate_action_ptr ca_ptr, candidate_actions_){
|
||||
foreach(composite_ai::candidate_action_ptr ca_ptr, candidate_actions_){
|
||||
if (!ca_ptr->is_enabled()){
|
||||
continue;
|
||||
}
|
||||
|
@ -69,7 +71,7 @@ void candidate_action_evaluation_loop::do_play_stage()
|
|||
DBG_AI_TESTING_RCA_DEFAULT << "Evaluating candidate action: "<< *ca_ptr << std::endl;
|
||||
score = ca_ptr->evaluate();
|
||||
DBG_AI_TESTING_RCA_DEFAULT << "Evaluated candidate action to score "<< score << " : " << *ca_ptr << std::endl;
|
||||
} catch (ai::composite_ai::candidate_action_evaluation_exception &caee) {
|
||||
} catch (composite_ai::candidate_action_evaluation_exception &caee) {
|
||||
ERR_AI_TESTING_RCA_DEFAULT << "Candidate action evaluation threw an exception: " << caee << std::endl;
|
||||
ca_ptr->disable();
|
||||
continue;
|
||||
|
@ -82,11 +84,11 @@ void candidate_action_evaluation_loop::do_play_stage()
|
|||
}
|
||||
|
||||
//Execution
|
||||
if (best_score>ai::composite_ai::candidate_action::BAD_SCORE) {
|
||||
if (best_score>composite_ai::candidate_action::BAD_SCORE) {
|
||||
try {
|
||||
DBG_AI_TESTING_RCA_DEFAULT << "Best candidate action: "<< *best_ptr << std::endl;
|
||||
executed = best_ptr->execute();
|
||||
} catch (ai::composite_ai::candidate_action_execution_exception &caee) {
|
||||
} catch (composite_ai::candidate_action_execution_exception &caee) {
|
||||
ERR_AI_TESTING_RCA_DEFAULT << "Candidate action execution threw an exception: " << caee << std::endl;
|
||||
executed = false;
|
||||
}
|
||||
|
@ -98,13 +100,13 @@ void candidate_action_evaluation_loop::do_play_stage()
|
|||
executed = true;
|
||||
}
|
||||
} else {
|
||||
LOG_AI_TESTING_RCA_DEFAULT << "Ending candidate action evaluation loop due to best score "<< best_score<<"<="<< ai::composite_ai::candidate_action::BAD_SCORE<<std::endl;
|
||||
LOG_AI_TESTING_RCA_DEFAULT << "Ending candidate action evaluation loop due to best score "<< best_score<<"<="<< composite_ai::candidate_action::BAD_SCORE<<std::endl;
|
||||
}
|
||||
} while (executed);
|
||||
LOG_AI_TESTING_RCA_DEFAULT << "Ended candidate action evaluation loop for side "<< get_side() << std::endl;
|
||||
}
|
||||
|
||||
ai::composite_ai::rca_context& candidate_action_evaluation_loop::get_rca_context()
|
||||
composite_ai::rca_context& candidate_action_evaluation_loop::get_rca_context()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
@ -113,4 +115,6 @@ candidate_action_evaluation_loop::~candidate_action_evaluation_loop()
|
|||
{
|
||||
}
|
||||
|
||||
} // of namespace testing_ai_default
|
||||
} // end of namespace testing_ai_default
|
||||
|
||||
} // end of namespace ai
|
||||
|
|
|
@ -30,11 +30,13 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace ai {
|
||||
|
||||
namespace testing_ai_default {
|
||||
|
||||
class candidate_action_evaluation_loop: public virtual ai::composite_ai::stage, public virtual ai::composite_ai::rca_context {
|
||||
class candidate_action_evaluation_loop: public virtual composite_ai::stage, public virtual composite_ai::rca_context {
|
||||
public:
|
||||
candidate_action_evaluation_loop( ai::composite_ai::composite_ai_context &context, const config &cfg );
|
||||
candidate_action_evaluation_loop( composite_ai::composite_ai_context &context, const config &cfg );
|
||||
|
||||
~candidate_action_evaluation_loop();
|
||||
|
||||
|
@ -42,10 +44,10 @@ public:
|
|||
|
||||
void on_create();
|
||||
|
||||
ai::composite_ai::rca_context& get_rca_context();
|
||||
composite_ai::rca_context& get_rca_context();
|
||||
|
||||
private:
|
||||
std::vector<ai::composite_ai::candidate_action_ptr> candidate_actions_;
|
||||
std::vector<composite_ai::candidate_action_ptr> candidate_actions_;
|
||||
|
||||
const config &cfg_;
|
||||
};
|
||||
|
@ -53,4 +55,6 @@ private:
|
|||
|
||||
} // of namespace testing_ai_default
|
||||
|
||||
} // of namespace ai
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue