AI refactoring: dfool::dfool_ai -> ai::dfool::dfool_ai

This commit is contained in:
Iurii Chernyi 2009-06-04 21:34:37 +00:00
parent b359b1f227
commit a89bc9c53c
2 changed files with 21 additions and 12 deletions

View file

@ -21,10 +21,13 @@
#include "../log.hpp"
#include "../formula_string_utils.hpp"
namespace ai {
namespace dfool {
static lg::log_domain log_ai("ai/dfool");
#define LOG_AI LOG_STREAM(info, log_ai)
namespace dfool {
void dfool_ai::play_turn(){
int team_num = get_side();
const config& parms = current_team().ai_parameters();
@ -242,8 +245,8 @@ bool dfool_ai::moveto(const config &o, unit_map::const_iterator m)
map_location target(atoi(o["target_x"].c_str()) - 1, atoi(o["target_y"].c_str()) - 1);
LOG_AI << "\tmoving to:(" << target.x << ',' << target.y << ")\n";
if(m->second.movement_left()){
ai::moves_map possible_moves;
ai::move_map srcdst, dstsrc;
moves_map possible_moves;
move_map srcdst, dstsrc;
unit_map known_units;
// unit_memory_.known_map(known_units, get_info().state.turn());
@ -260,7 +263,7 @@ bool dfool_ai::moveto(const config &o, unit_map::const_iterator m)
std::pair<map_location,map_location> closest_move;
/** @todo 2.0 This undoubtedly could be done more cleanly */
for(ai::move_map::const_iterator i = dstsrc.begin(); i != dstsrc.end(); ++i) {
for(move_map::const_iterator i = dstsrc.begin(); i != dstsrc.end(); ++i) {
// Must restrict move_map to only unit that is moving.
if(i->second==m->first){
const int distance = distance_between(target,i->first);
@ -674,4 +677,6 @@ bool dfool_ai::moveto(const config &o, unit_map::const_iterator m)
t<<distance;
return(t.str());
}
} // end namespace dfool
} // end of namespace dfool
} // end of namespace ai

View file

@ -33,6 +33,8 @@
#include <map>
#include <string>
namespace ai {
namespace dfool {
typedef std::vector<size_t> unit_list;
@ -99,12 +101,12 @@ namespace dfool {
* does not target units that it has not "seen",
* and does not make decisions based on unseen units.
*/
class dfool_ai : public ai::readwrite_context_proxy, public ai::interface {
class dfool_ai : public default_ai_context_proxy, public interface {
public:
dfool_ai(ai::readwrite_context &context)
: recursion_counter_(context.get_recursion_count()), unit_memory_(current_team().ai_memory())
dfool_ai(default_ai_context &context)
: recursion_counter_(context.get_recursion_count()), unit_memory_(context.current_team().ai_memory())
{
init_readwrite_context_proxy(context);
init_default_ai_context_proxy(context);
}
void play_turn();
virtual std::string describe_self();
@ -112,11 +114,11 @@ namespace dfool {
return recursion_counter_.get_count();
}
private:
ai::recursion_counter recursion_counter_;
recursion_counter recursion_counter_;
// std::map<std::string,target> target_map_;
unit_list all_units();
unit_list visible_units();
void switch_side(ai::side_number /*side*/)
void switch_side(side_number /*side*/)
{}
unit_list my_units();
unit_list filter_units(const config& filter,unit_list& ul, unit_map& um);
@ -127,6 +129,8 @@ namespace dfool {
};
} // end namespace dfool
} // end of namespace dfool
} // end of namespace ai
#endif