Skip to content

Commit

Permalink
AI: remove outdated TODOs
Browse files Browse the repository at this point in the history
These are TODOs which have been implemented, are not worth implementing, can be converted to notes (for example because they are obvious or because they are not really TODOs), etc.

Some additional comments are given in Issue #3695.
  • Loading branch information
mattsc committed Dec 8, 2018
1 parent 761b110 commit 5f8b0a3
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 50 deletions.
5 changes: 2 additions & 3 deletions src/ai/actions.cpp
Expand Up @@ -306,8 +306,7 @@ void attack_result::do_execute()


set_gamestate_changed();
//start of ugly hack. @todo 1.9 rework that via extended event system
//until event system is reworked, we note the attack this way
// Rework if extended event system is implemented
get_info().recent_attacks.insert(defender_loc_);
//end of ugly hack
try {
Expand Down Expand Up @@ -381,7 +380,7 @@ bool move_result::test_route(const unit &un)
const pathfind::shortest_path_calculator calc(un, my_team, resources::gameboard->teams(), resources::gameboard->map());

//allowed teleports
pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(un, my_team, true);///@todo 1.9: see_all -> false
pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(un, my_team, true);

//do an A*-search
route_.reset(new pathfind::plain_route(pathfind::a_star_search(un.get_location(), to_, 10000.0, calc, resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports)));
Expand Down
3 changes: 0 additions & 3 deletions src/ai/actions.hpp
Expand Up @@ -448,9 +448,6 @@ static std::map<int,std::string> error_names_;
};


///@todo 1.7.11 important! Add an ai action (and fai function) to set a goto on a unit
///@todo 1.7.11 important! Add an ai action (and fai function) to send a chat message to a player

} //end of namespace ai

std::ostream &operator<<(std::ostream &s, const ai::attack_result& r);
Expand Down
4 changes: 2 additions & 2 deletions src/ai/composite/ai.cpp
Expand Up @@ -174,7 +174,7 @@ std::string ai_composite::get_engine() const
std::string ai_composite::evaluate(const std::string& str)
{
config cfg;
cfg["engine"] = "fai";///@todo 1.9 : consider allowing other engines to evaluate
cfg["engine"] = "fai";
engine_ptr e_ptr = get_engine_by_cfg(cfg);
if (!e_ptr) {
// This should be unreachable, but not entirely sure...
Expand All @@ -186,7 +186,7 @@ std::string ai_composite::evaluate(const std::string& str)

void ai_composite::new_turn()
{
///@todo 1.9 replace with event system
/// Rework if extended event system is implemented
recalculate_move_maps();
invalidate_defensive_position_cache();
invalidate_keeps_cache();
Expand Down
3 changes: 0 additions & 3 deletions src/ai/composite/aspect.cpp
Expand Up @@ -57,7 +57,6 @@ aspect::~aspect()
manager.remove_gamestate_observer(this);
}
if (invalidate_on_minor_gamestate_change_) {
///@todo 1.9 add minor_gamestate_change_observer
//manager::remove_minor_gamestate_observer(this);
}
}
Expand Down Expand Up @@ -85,7 +84,6 @@ bool aspect::redeploy(const config &cfg, const std::string& /*id*/)
manager.remove_gamestate_observer(this);
}
if (invalidate_on_minor_gamestate_change_) {
///@todo 1.9 add minor_gamestate_change_observer
//manager::remove_minor_gamestate_observer(this);
}

Expand All @@ -111,7 +109,6 @@ bool aspect::redeploy(const config &cfg, const std::string& /*id*/)
manager.add_gamestate_observer(this);
}
if (invalidate_on_minor_gamestate_change_) {
///@todo 1.9 add minor_gamestate_change_observer
//manager::add_minor_gamestate_observer(this);
}
return true;
Expand Down
1 change: 0 additions & 1 deletion src/ai/composite/aspect.hpp
Expand Up @@ -299,7 +299,6 @@ class composite_aspect : public typesafe_aspect<T> {

virtual void recalculate() const
{
///@todo 1.9 optimize in case of an aspect which returns variant
for(const auto& f : boost::adaptors::reverse(facets_)) {
if (f->active()) {
this->value_ = f->get_ptr();
Expand Down
1 change: 0 additions & 1 deletion src/ai/composite/component.hpp
Expand Up @@ -30,7 +30,6 @@ class config;
//============================================================================
namespace ai {

//TODO: find a good place for this
struct path_element {
path_element()
: property()
Expand Down
3 changes: 1 addition & 2 deletions src/ai/contexts.cpp
Expand Up @@ -566,7 +566,7 @@ const wfl::variant& readonly_context_impl::get_attacks_as_variant() const
if (attacks_) {
return attacks_->get_variant();
}
static wfl::variant v;///@todo 1.9: replace with variant::null_variant;
static wfl::variant v;
return v;
}

Expand Down Expand Up @@ -642,7 +642,6 @@ engine_ptr readonly_context_impl::get_engine_by_cfg(const config& cfg)
return *en;
}

//TODO: fix, removing some code duplication
engine_factory::factory_map::iterator eng = engine_factory::get_list().find(engine_name);
if (eng == engine_factory::get_list().end()){
ERR_AI << "side "<<get_side()<<" : UNABLE TO FIND engine["<<
Expand Down
6 changes: 0 additions & 6 deletions src/ai/default/attack.cpp
Expand Up @@ -156,7 +156,6 @@ void attack_analysis::analyze(const gamemap& map, unit_map& units,
// Note we didn't fight at all if defender is already dead.
double prob_fought = (1.0 - prob_dead_already);

/** @todo 1.9 add combatant.prob_killed */
double prob_killed = def.hp_dist[0] - prob_dead_already;
prob_dead_already = def.hp_dist[0];

Expand Down Expand Up @@ -228,11 +227,6 @@ void attack_analysis::analyze(const gamemap& map, unit_map& units,
// If we didn't advance, we took this damage.
avg_damage_taken += (up->hitpoints() - att.average_hp()) * (1.0 - advance_prob);

/**
* @todo 1.9: attack_prediction.cpp should understand advancement
* directly. For each level of attacker def gets 1 xp or
* kill_experience.
*/
int fight_xp = game_config::combat_xp(up->level());
int kill_xp = game_config::kill_xp(fight_xp);
def_avg_experience += fight_xp * (1.0 - att.hp_dist[0]) + kill_xp * att.hp_dist[0];
Expand Down
8 changes: 1 addition & 7 deletions src/ai/default/ca.cpp
Expand Up @@ -81,7 +81,7 @@ double goto_phase::evaluate()
unit_map::const_iterator ui = units_.find(*g);
// passive_leader: never moves or attacks
if(ui->can_recruit() && get_passive_leader() && !get_passive_leader_shares_keep()){
continue;//@todo: only bail out if goto is on keep
continue;
}
// end of passive_leader

Expand Down Expand Up @@ -564,12 +564,6 @@ void get_villages_phase::execute()
power_projection(i->first, get_enemy_dstsrc()) >= new_unit->hitpoints() / 4.0)
{
LOG_AI_TESTING_AI_DEFAULT << "found support target... " << new_unit->get_location() << '\n';
//FIXME: suokko tweaked the constant 1.0 to the formula:
//25.0* current_team().caution() * power_projection(loc,enemy_dstsrc) / new_unit->second.hitpoints()
//Is this an improvement?

///@todo 1.7 check if this an improvement
//add_target(target(new_unit->first,1.0,target::SUPPORT));
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/ai/default/contexts.hpp
Expand Up @@ -44,7 +44,6 @@ struct target {
double value;

TYPE type;
///@todo 1.7: ai goals: this is a 'target' marker class which should be expanded with additional information which is generic enough to apply to all targets.
};


Expand Down
2 changes: 1 addition & 1 deletion src/ai/formula/ai.cpp
Expand Up @@ -191,7 +191,7 @@ wfl::variant formula_ai::make_action(wfl::const_formula_ptr formula_, const wfl:
throw formula_error("null formula passed to make_action","","formula",0);
}
LOG_AI << "do move...\n";
const variant var = formula_->evaluate(variables);///@todo 1.9 add formula_debugger
const variant var = formula_->evaluate(variables);
variant res;

if (ai_ptr_) {
Expand Down
2 changes: 1 addition & 1 deletion src/ai/formula/engine_fai.cpp
Expand Up @@ -37,7 +37,7 @@ static lg::log_domain log_ai_engine_fai("ai/engine/fai");
class fai_candidate_action_wrapper : public candidate_action {
public:
fai_candidate_action_wrapper( rca_context &context, const config &cfg, wfl::candidate_action_ptr fai_ca, formula_ai &_formula_ai )
: candidate_action(context,cfg),fai_ca_(fai_ca),formula_ai_(_formula_ai),cfg_(cfg)///@todo 1.7: implement fai_ca->to_config()
: candidate_action(context,cfg),fai_ca_(fai_ca),formula_ai_(_formula_ai),cfg_(cfg)
{

}
Expand Down
11 changes: 0 additions & 11 deletions src/ai/formula/function_table.cpp
Expand Up @@ -692,17 +692,6 @@ DEFINE_WFL_FUNCTION(outcomes, 1, 1)
return variant(vars);
}

/* // TODO: Not really sure what this was meant to do or if there's any reason left to keep it...
DEFINE_FAI_FUNCTION(evaluate_for_position, 2, 2)
{
variant position = args()[0]->evaluate(variables,add_debug_info(fdb,0,"evaluate_for_position:position"));
ai_.store_outcome_position(position);
position_callable* pos = position.convert_to<position_callable>();
position_callable::swapper swapper(ai_, *pos);
return args()[1]->evaluate(variables,add_debug_info(fdb,1,"evaluate_for_position:formula"));
}
*/

DEFINE_FAI_FUNCTION(rate_action, 1, 1)
{
variant act = args()[0]->evaluate(variables,add_debug_info(fdb,0,"rate_action:action"));
Expand Down
1 change: 0 additions & 1 deletion src/ai/formula/stage_side_formulas.cpp
Expand Up @@ -72,7 +72,6 @@ void stage_side_formulas::on_create()
config stage_side_formulas::to_config() const
{
config cfg = stage::to_config();
///@todo 1.7: serialize to config
cfg.append(cfg_);
return cfg;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ai/game_info.hpp
Expand Up @@ -111,7 +111,7 @@ class game_info
{
}

/** hack. @todo 1.9 rework that via extended event system, or at least ensure it hurts no one */
/** Rework if extended event system is imlpemented */
std::set<map_location> recent_attacks;
};

Expand Down
4 changes: 1 addition & 3 deletions src/ai/lua/core.cpp
Expand Up @@ -219,7 +219,7 @@ static int ai_attack(lua_State *L, bool exec)
}
}

//TODO: Right now, aggression is used by the attack execution functions to determine the weapon to be used.
// Note: Right now, aggression is used by the attack execution functions to determine the weapon to be used.
// If a decision is made to expand the function that determines the weapon, this block must be refactored
// to parse aggression if a single int is on the stack, or create a table of parameters, if a table is on the
// stack.
Expand Down Expand Up @@ -280,7 +280,6 @@ static int ai_recruit(lua_State *L, bool exec)
where.set_wml_x(lua_tonumber(L, 2));
where.set_wml_y(lua_tonumber(L, 3));
}
//TODO fendrin: talk to Crab about the from argument.
map_location from = map_location::null_location();
ai::recruit_result_ptr recruit_result = ai::actions::execute_recruit_action(side,exec,std::string(unit_name),where,from);
return transform_ai_action(L,recruit_result);
Expand All @@ -305,7 +304,6 @@ static int ai_recall(lua_State *L, bool exec)
where.set_wml_x(lua_tonumber(L, 2));
where.set_wml_y(lua_tonumber(L, 3));
}
//TODO fendrin: talk to Crab about the from argument.
map_location from = map_location::null_location();
ai::recall_result_ptr recall_result = ai::actions::execute_recall_action(side,exec,std::string(unit_id),where,from);
return transform_ai_action(L,recall_result);
Expand Down
3 changes: 1 addition & 2 deletions src/ai/manager.cpp
Expand Up @@ -604,7 +604,6 @@ const std::string manager::internal_evaluate_command( side_number side, const st
// ADD, CREATE AIs, OR LIST AI TYPES
// =======================================================================

///@todo 1.9 add error reporting
bool manager::add_ai_for_side_from_file( side_number side, const std::string& file, bool replace )
{
config cfg;
Expand Down Expand Up @@ -725,7 +724,7 @@ void manager::play_turn( side_number side ){
last_interact_ = 0;
num_interact_ = 0;
const int turn_start_time = SDL_GetTicks();
/*hack. @todo 1.9 rework via extended event system*/
/* Rework if extended event system is implemented */
get_ai_info().recent_attacks.clear();
ai_composite& ai_obj = get_active_ai_for_side(side);
resources::game_events->pump().fire("ai_turn");
Expand Down
1 change: 0 additions & 1 deletion src/ai/testing.cpp
Expand Up @@ -94,7 +94,6 @@ void ai_testing::log_game_start()
LOG_AI_TESTING << "AI_IDENTIFIER " << side << ": " << ai::manager::get_singleton().get_active_ai_identifier_for_side(side) << std::endl;
LOG_AI_TESTING << "TEAM " << side << ": " << tm->side() << std::endl;
resources::recorder->add_log_data("ai_log", "ai_id" + std::to_string(side), ai::manager::get_singleton().get_active_ai_identifier_for_side(side));
///@todo 1.9: add information about ai_config
}
LOG_AI_TESTING << "VERSION: " << game_config::revision << std::endl;
resources::recorder->add_log_data("ai_log","version",game_config::revision);
Expand Down

0 comments on commit 5f8b0a3

Please sign in to comment.