Command-line game: get default ai_algorithm from config

Do not use a hard-coded value set to the RCA AI.
This commit is contained in:
mattsc 2018-11-16 12:36:51 -08:00
parent a80d39e3d7
commit 8beece659b
3 changed files with 6 additions and 5 deletions

View file

@ -508,7 +508,7 @@ void connect_engine::start_game()
send_to_server(config("start_game"));
}
void connect_engine::start_game_commandline(const commandline_options& cmdline_opts)
void connect_engine::start_game_commandline(const commandline_options& cmdline_opts, const config& game_config)
{
DBG_MP << "starting a new game in commandline mode" << std::endl;
@ -550,9 +550,10 @@ void connect_engine::start_game_commandline(const commandline_options& cmdline_o
}
}
// Set AI algorithm to RCA AI for all sides,
// Set AI algorithm to default for all sides,
// then override if commandline option was given.
side->set_ai_algorithm("ai_default_rca");
std::string ai_algorithm = game_config.child("ais")["default_ai_algorithm"].str();
side->set_ai_algorithm(ai_algorithm);
if(cmdline_opts.multiplayer_algorithm) {
for(const mp_option& option : *cmdline_opts.multiplayer_algorithm) {

View file

@ -63,7 +63,7 @@ public:
bool can_start_game() const;
void start_game();
void start_game_commandline(const commandline_options& cmdline_opts);
void start_game_commandline(const commandline_options& cmdline_opts, const config& game_config);
void leave_game();

View file

@ -763,7 +763,7 @@ void start_local_game_commandline(const config& game_config, saved_game& state,
ng::connect_engine_ptr connect_engine(new ng::connect_engine(state, true, nullptr));
// Update the parameters to reflect game start conditions
connect_engine->start_game_commandline(cmdline_opts);
connect_engine->start_game_commandline(cmdline_opts, game_config);
}
if(resources::recorder && cmdline_opts.multiplayer_label) {