AI Testing. Adds a command line parameter --ai_config<number>=value...

...(patch #1164 by karlm). This patch allow to specify the exact path
to ai configuration for each of the sides from the command line, which
is very important for batch-testing of various AIs.
This commit is contained in:
Iurii Chernyi 2009-04-17 19:11:11 +00:00
parent 82d3045861
commit 374c1f8d83
5 changed files with 23 additions and 3 deletions

View file

@ -6,6 +6,7 @@ Version 1.7.0-svn:
number generator with.
* new logdomain : uploader to see stat-upload related actions
* AI:
* Added command-line option ai_config<number>=<value>
* Fixed incorrect handling of poisoning attacks when suggesting best attack
in user interface
* Added basic history and hot-redeployment capabilities to in-game console.

View file

@ -852,6 +852,10 @@
[entry]
name = "Joshua Hudson"
[/entry]
[entry]
name = "Karl Miller (karlm)"
email = "karl dot miller dot km at gmail dot com"
[/entry]
[entry]
name = "Laurent Birtz"
[/entry]

View file

@ -181,6 +181,9 @@ The side-specific multiplayer options are marked with
has to be replaced by a side number. It usually is 1 or 2 but depends on
the number of players possible in the chosen scenario.
.TP
.BI --ai_config number = value
selects a configuration file to load for the AI controller for this side.
.TP
.BI --algorithm number = value
selects a non-standard algorithm to be used by the AI controller for
this side. Available values:

View file

@ -682,7 +682,7 @@ bool game_controller::play_multiplayer_mode()
std::string era = "era_default";
std::string scenario = "multiplayer_The_Freelands";
std::map<int,std::string> side_types, side_controllers, side_algorithms;
std::map<int,std::string> side_types, side_controllers, side_algorithms, side_ai_configs;
std::map<int,string_map> side_parameters;
std::string turns = "50";
@ -720,6 +720,8 @@ bool game_controller::play_multiplayer_mode()
era = value;
} else if(last_digit && name_head == "--controller") {
side_controllers[side] = value;
} else if(last_digit && name_head == "--ai_config") {
side_ai_configs[side] = value;
} else if(last_digit && name_head == "--algorithm") {
side_algorithms[side] = value;
} else if(last_digit && name_head == "--side") {
@ -780,7 +782,8 @@ bool game_controller::play_multiplayer_mode()
{
std::map<int,std::string>::const_iterator type = side_types.find(side_num),
controller = side_controllers.find(side_num),
algorithm = side_algorithms.find(side_num);
algorithm = side_algorithms.find(side_num),
ai_config = side_ai_configs.find(side_num);
const config* side = type == side_types.end() ?
&era_cfg.find_child("multiplayer_side", "random_faction", "yes") :
@ -841,6 +844,10 @@ bool game_controller::play_multiplayer_mode()
s["ai_algorithm"] = algorithm->second;
}
if(ai_config != side_ai_configs.end()) {
s["ai_config"] = ai_config->second;
}
config& ai_params = s.add_child("ai");
//now add in any arbitrary parameters given to the side
@ -1757,6 +1764,7 @@ static int process_command_args(int argc, char** argv) {
<< " should be between 1 and 1000, the default is 50.\n"
<< " -m, --multiplayer starts a multiplayer game. There are additional\n"
<< " options that can be used as explained below:\n"
<< " --ai_config<number>=value selects a configuration file to load for this side.\n"
<< " --algorithm<number>=value selects a non-standard algorithm to be used by\n"
<< " the AI controller for this side.\n"
<< " --controller<number>=value selects the controller for this side.\n"

View file

@ -120,7 +120,11 @@ team::team_info::team_info(const config& cfg) :
if (!user_team_name.translatable())
user_team_name = user_team_name.from_serialized(user_team_name);
ai_manager::add_ai_for_side_from_config(side,cfg,true);
if(cfg.has_attribute("ai_config")) {
ai_manager::add_ai_for_side_from_file(side, cfg["ai_config"], true);
} else {
ai_manager::add_ai_for_side_from_config(side, cfg, true);
}
//legacy parameters
const config& global_ai_parameters = ai_manager::get_active_ai_global_parameters_for_side(side);