Skip to content

Commit

Permalink
Remove the deprecated recruitment stage, candidate action, and aspect
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel authored and mattsc committed Mar 22, 2016
1 parent 6972d51 commit ca8cb3b
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 1,534 deletions.
13 changes: 0 additions & 13 deletions data/ai/utils/default_config.cfg
Expand Up @@ -64,19 +64,6 @@
{DEFAULT_ASPECT_VALUE number_of_possible_recruits_to_force_recruit 3.1}
{DEFAULT_ASPECT_VALUE passive_leader no}
{DEFAULT_ASPECT_VALUE passive_leader_shares_keep no}
[aspect]
id=recruitment
engine=cpp
name=composite_aspect
[default]
engine=cpp
name=standard_aspect
[value]
engine=cpp
name=ai_default::recruitment
[/value]
[/default]
[/aspect]
{DEFAULT_ASPECT_VALUE recruitment_diversity 2.0}
{DEFAULT_ASPECT_VALUE recruitment_ignore_bad_combat no}
{DEFAULT_ASPECT_VALUE recruitment_ignore_bad_movement no}
Expand Down
37 changes: 0 additions & 37 deletions src/ai/composite/stage.cpp
Expand Up @@ -109,43 +109,6 @@ bool idle_stage::do_play_stage(){
return false;
}

// =======================================================================
// COMPOSITE AI MINISTAGE
// =======================================================================

ministage::ministage(const config &cfg)
: cfg_(cfg),stage_()
{
}

ministage::~ministage()
{
}


stage_ptr ministage::get_stage_ptr(ai_context &context)
{
if (stage_) {
return stage_;
}

std::vector<stage_ptr> stages;
engine::parse_stage_from_config(context,cfg_,std::back_inserter(stages));
if (stages.empty()) {
return stage_ptr();
}
stage_ = stages.front();
return stage_;
}

config ministage::to_config() const
{
if (!stage_) {
return cfg_;
}
return stage_->to_config();
}



} //end of namespace ai
18 changes: 2 additions & 16 deletions src/ai/composite/stage.hpp
Expand Up @@ -54,7 +54,7 @@ class stage : public virtual ai_context_proxy, public component {

/**
* Play the turn - strategy
* @return true only if game state has changed. Really only needed for ministages. Returning false is always safe.
* @return true only if game state has changed. Returning false is always safe.
*/
bool play_stage();

Expand All @@ -77,7 +77,7 @@ class stage : public virtual ai_context_proxy, public component {
protected:
/**
* Play the turn - implementation
* @return true only if game state has changed. Really only needed for ministages. Returning false is always safe.
* @return true only if game state has changed. Returning false is always safe.
*/
virtual bool do_play_stage() = 0;

Expand Down Expand Up @@ -139,20 +139,6 @@ class register_stage_factory : public stage_factory {
}
};


/** this class is a lazily-initializing proxy for a stage **/
class ministage {
public:
ministage(const config &cfg);
virtual ~ministage();
stage_ptr get_stage_ptr(ai_context &context);
config to_config() const;

private:
config cfg_;
stage_ptr stage_;
};

} //end of namespace ai

#ifdef _MSC_VER
Expand Down
55 changes: 0 additions & 55 deletions src/ai/composite/value_translator.hpp
Expand Up @@ -145,33 +145,6 @@ class config_value_translator<config> {
}
};

template<>
class config_value_translator<ministage> {
public:

static ministage cfg_to_value(const config &cfg)
{
return ministage(cfg.child_or_empty("value"));
}

static void cfg_to_value(const config &cfg, ministage &value)
{
value = cfg_to_value(cfg);
}

static void value_to_cfg(const ministage &value, config &cfg)
{
cfg.add_child("value",value.to_config());
}

static config value_to_cfg(const ministage &value)
{
config cfg;
value_to_cfg(value,cfg);
return cfg;
}
};

template<>
class config_value_translator<terrain_filter> {
public:
Expand Down Expand Up @@ -264,34 +237,6 @@ class variant_value_translator {
}
};

template<>
class variant_value_translator<ministage> {
public:

static void variant_to_value(const variant &/*var*/, ministage &/*value*/)
{
assert(false);//not implemented
}

static void value_to_variant(const ministage &/*value*/, variant &/*var*/)
{
assert(false);//not implemented
}

static variant value_to_variant(const ministage &/*value*/)
{
assert(false);
return variant();
}

static ministage variant_to_value(const variant &/*var*/)
{
assert(false);
config cfg;
return ministage(cfg);
}
};

template<>
class variant_value_translator<int> {
public:
Expand Down
13 changes: 0 additions & 13 deletions src/ai/contexts.cpp
Expand Up @@ -218,7 +218,6 @@ readonly_context_impl::readonly_context_impl(side_context &context, const config
passive_leader_(),
passive_leader_shares_keep_(),
possible_moves_(),
recruitment_(),
recruitment_diversity_(),
recruitment_ignore_bad_combat_(),
recruitment_ignore_bad_movement_(),
Expand Down Expand Up @@ -253,7 +252,6 @@ readonly_context_impl::readonly_context_impl(side_context &context, const config
add_known_aspect("number_of_possible_recruits_to_force_recruit",number_of_possible_recruits_to_force_recruit_);
add_known_aspect("passive_leader",passive_leader_);
add_known_aspect("passive_leader_shares_keep",passive_leader_shares_keep_);
add_known_aspect("recruitment",recruitment_);
add_known_aspect("recruitment_diversity",recruitment_diversity_);
add_known_aspect("recruitment_ignore_bad_combat",recruitment_ignore_bad_combat_);
add_known_aspect("recruitment_ignore_bad_movement",recruitment_ignore_bad_movement_);
Expand Down Expand Up @@ -806,17 +804,6 @@ const std::vector<unit_ptr>& readonly_context_impl::get_recall_list() const
return current_team().recall_list().recall_list_; //TODO: Refactor ai so that friend of ai context is not required of recall_list_manager at this line
}

stage_ptr readonly_context_impl::get_recruitment(ai_context &context) const
{
if (recruitment_) {
ministage_ptr m = recruitment_->get_ptr();
if (m) {
return m->get_stage_ptr(context);
}
}
return stage_ptr();
}


double readonly_context_impl::get_recruitment_diversity() const
{
Expand Down
14 changes: 0 additions & 14 deletions src/ai/contexts.hpp
Expand Up @@ -44,7 +44,6 @@ class unit_map;
class unit_type; // lines 46-46
class variant; // lines 42-42
namespace ai { class ai_context; } // lines 51-51
namespace ai { class ministage; }
namespace ai { class unit_advancements_aspect; }
namespace ai { template <typename T> class typesafe_aspect; }
namespace boost { template <class T> class shared_ptr; }
Expand Down Expand Up @@ -310,9 +309,6 @@ class readonly_context : public virtual side_context {
virtual const std::vector<unit_ptr>& get_recall_list() const = 0;


virtual stage_ptr get_recruitment(ai_context &context) const = 0;


virtual double get_recruitment_diversity() const = 0;


Expand Down Expand Up @@ -834,12 +830,6 @@ class readonly_context_proxy : public virtual readonly_context, public virtual s
}


virtual stage_ptr get_recruitment(ai_context &context) const
{
return target_->get_recruitment(context);
}


virtual double get_recruitment_diversity() const
{
return target_->get_recruitment_diversity();
Expand Down Expand Up @@ -1439,9 +1429,6 @@ class readonly_context_impl : public virtual side_context_proxy, public readonly
virtual const std::vector<unit_ptr>& get_recall_list() const;


virtual stage_ptr get_recruitment(ai_context &context) const;


virtual double get_recruitment_diversity() const;


Expand Down Expand Up @@ -1587,7 +1574,6 @@ class readonly_context_impl : public virtual side_context_proxy, public readonly
aspect_type<bool>::typesafe_ptr passive_leader_;
aspect_type<bool>::typesafe_ptr passive_leader_shares_keep_;
mutable moves_map possible_moves_;
aspect_type< ministage >::typesafe_ptr recruitment_;
aspect_type< double >::typesafe_ptr recruitment_diversity_;
aspect_type< bool >::typesafe_ptr recruitment_ignore_bad_combat_;
aspect_type< bool >::typesafe_ptr recruitment_ignore_bad_movement_;
Expand Down

0 comments on commit ca8cb3b

Please sign in to comment.