void ai_composite::new_turn() { ///@todo 1.9 replace with event system recalculate_move_maps(); invalidate_defensive_position_cache(); invalidate_keeps_cache(); clear_additional_targets(); unit_stats_cache().clear(); }
boost::shared_ptr<attacks_vector> aspect_attacks::analyze_targets() const { const move_map& srcdst = get_srcdst(); const move_map& dstsrc = get_dstsrc(); const move_map& enemy_srcdst = get_enemy_srcdst(); const move_map& enemy_dstsrc = get_enemy_dstsrc(); boost::shared_ptr<attacks_vector> res(new attacks_vector()); unit_map& units_ = *resources::units; std::vector<map_location> unit_locs; for(unit_map::const_iterator i = units_.begin(); i != units_.end(); ++i) { if (i->side() == get_side() && i->attacks_left() && !(i->can_recruit() && get_passive_leader())) { if (!i->matches_filter(vconfig(filter_own_), i->get_location())) { continue; } unit_locs.push_back(i->get_location()); } } bool used_locations[6]; std::fill(used_locations,used_locations+6,false); moves_map dummy_moves; move_map fullmove_srcdst, fullmove_dstsrc; calculate_possible_moves(dummy_moves,fullmove_srcdst,fullmove_dstsrc,false,true); unit_stats_cache().clear(); for(unit_map::const_iterator j = units_.begin(); j != units_.end(); ++j) { // Attack anyone who is on the enemy side, // and who is not invisible or petrified. if (current_team().is_enemy(j->side()) && !j->incapacitated() && !j->invisible(j->get_location())) { if (!j->matches_filter(vconfig(filter_enemy_), j->get_location())) { continue; } map_location adjacent[6]; get_adjacent_tiles(j->get_location(), adjacent); attack_analysis analysis; analysis.target = j->get_location(); analysis.vulnerability = 0.0; analysis.support = 0.0; do_attack_analysis(j->get_location(), srcdst, dstsrc, fullmove_srcdst, fullmove_dstsrc, enemy_srcdst, enemy_dstsrc, adjacent,used_locations,unit_locs,*res,analysis, current_team()); } } return res; }
void strategy_formulation_with_rca::init_side() { recalculate_move_maps(); invalidate_defensive_position_cache(); invalidate_keeps_cache(); clear_additional_targets(); unit_stats_cache().clear(); DBG_AI_TESTING_SF_WITH_RCA << "------init_side() begin------" << std::endl; unit_map& units = *resources::units; for(unit_map::unit_iterator ui = units.begin(); ui != units.end(); ++ui){ if(ui->side() == this->get_side()){ ui->new_turn(); } } (*resources::teams)[this->get_side()-1].new_turn(); calculate_healing(this->get_side(), false); DBG_AI_TESTING_SF_WITH_RCA << "------init_side() end------" << std::endl; }