From 101af19730aa6a7c9dd269b6999a37b3806f8c13 Mon Sep 17 00:00:00 2001 From: Iurii Chernyi Date: Fri, 24 Apr 2009 18:38:47 +0000 Subject: [PATCH] Added ai_testing logs to log information about the winner, ...including information about AI indentifier --- src/actions.cpp | 13 ++++++++++++- src/actions.hpp | 2 +- src/ai/ai.cpp | 2 +- src/mouse_events.cpp | 2 +- src/playsingle_controller.cpp | 2 +- src/replay.cpp | 4 ++-- src/team.cpp | 5 +++++ src/team.hpp | 1 + 8 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index 43b5080b187..18c29ea0e7f 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -41,6 +41,7 @@ #define LOG_NG LOG_STREAM(info, engine) #define ERR_NG LOG_STREAM(err, engine) +#define LOG_AI_TESTING LOG_STREAM(info, ai_testing) struct castle_cost_calculator : cost_calculator { castle_cost_calculator(const gamemap& map) : map_(map) @@ -1903,7 +1904,7 @@ void advance_unit(unit_map& units, game_events::fire("post_advance",loc); } -void check_victory(unit_map& units, std::vector& teams, display& disp) +void check_victory(const gamestatus& status, unit_map& units, std::vector& teams, display& disp) { std::vector seen_leaders; for(unit_map::const_iterator i = units.begin(); @@ -1962,6 +1963,16 @@ void check_victory(unit_map& units, std::vector& teams, display& disp) std::cout << *i << " (using " << ai << ") "; } std::cout << "\n"; + for(std::vector::const_iterator i = seen_leaders.begin(); i != seen_leaders.end(); ++i) { + LOG_AI_TESTING << "WINNER: "<< *i <::const_iterator tm = teams.begin(); tm != teams.end(); ++tm) { + int side = tm-teams.begin()+1; + LOG_AI_TESTING << "AI_IDENTIFIER"<ai_algorithm_identifier() <& teams, display& disp); +void check_victory(const gamestatus& status, unit_map& units, std::vector& teams, display& disp); /** * Gets the time of day at a certain tile. diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp index 451f5e6c368..b738473a7b7 100644 --- a/src/ai/ai.cpp +++ b/src/ai/ai.cpp @@ -1273,7 +1273,7 @@ void ai_interface::attack_enemy(const location u, } } - check_victory(get_info().units,get_info().teams, get_info().disp); + check_victory(get_info().state,get_info().units,get_info().teams, get_info().disp); raise_enemy_attacked(); } diff --git a/src/mouse_events.cpp b/src/mouse_events.cpp index 0bf21fdeeab..ce8c43b2564 100644 --- a/src/mouse_events.cpp +++ b/src/mouse_events.cpp @@ -680,7 +680,7 @@ bool mouse_handler::attack_enemy_(unit_map::iterator attacker, unit_map::iterato dialogs::advance_unit(map_,units_,defender_loc,gui(),!defender_human); } - check_victory(units_, teams_, gui()); + check_victory(status_, units_, teams_, gui()); gui().draw(); diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index 2c517a9ce3f..0d8d25a8c19 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -581,7 +581,7 @@ void playsingle_controller::play_turn(bool save) std::endl; } - check_victory(units_, teams_, *gui_); + check_victory(status_, units_, teams_, *gui_); } // Time has run out diff --git a/src/replay.cpp b/src/replay.cpp index 7ec72be70b1..894eeb2fd8c 100644 --- a/src/replay.cpp +++ b/src/replay.cpp @@ -796,7 +796,7 @@ bool do_replay_handle(game_display& disp, const gamemap& map, //if there are no more advancing units, then we check for victory, //in case the battle that led to advancement caused the end of scenario if(advancing_units.empty()) { - check_victory(units, teams, disp); + check_victory(state, units, teams, disp); } continue; @@ -1174,7 +1174,7 @@ bool do_replay_handle(game_display& disp, const gamemap& map, //check victory now if we don't have any advancements. If we do have advancements, //we don't check until the advancements are processed. if(advancing_units.empty()) { - check_victory(units, teams, disp); + check_victory(state, units, teams, disp); } fix_shroud = !get_replay_source().is_skipping(); } diff --git a/src/team.cpp b/src/team.cpp index cf956268c31..d1b21d90c6b 100644 --- a/src/team.cpp +++ b/src/team.cpp @@ -627,6 +627,11 @@ const std::string& team::ai_algorithm() const return ai_manager::get_active_ai_algorithm_type_for_side(info_.side); } +const std::string& team::ai_algorithm_identifier() const +{ + return ai_manager::get_active_ai_global_parameters_for_side(info_.side)["ai_identifier"]; +} + const config& team::ai_parameters() const { return ai_manager::get_active_ai_effective_parameters_for_side(info_.side); diff --git a/src/team.hpp b/src/team.hpp index 79bcf973ec2..f9e52f61f19 100644 --- a/src/team.hpp +++ b/src/team.hpp @@ -246,6 +246,7 @@ public: const std::string& flag_icon() const { return info_.flag_icon; } const std::string& ai_algorithm() const; + const std::string& ai_algorithm_identifier() const; const config& ai_parameters() const; const config& ai_memory() const; void set_ai_memory(const config& ai_mem);