Skip to content

Commit

Permalink
Command-line game: get default ai_algorithm from config
Browse files Browse the repository at this point in the history
Do not use a hard-coded value set to the RCA AI.
  • Loading branch information
mattsc committed Nov 16, 2018
1 parent 073f70b commit fcc22a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/game_initialization/connect_engine.cpp
Expand Up @@ -490,7 +490,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;

Expand Down Expand Up @@ -532,9 +532,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) {

Expand Down
2 changes: 1 addition & 1 deletion src/game_initialization/connect_engine.hpp
Expand Up @@ -63,7 +63,7 @@ class connect_engine

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();

Expand Down
2 changes: 1 addition & 1 deletion src/game_initialization/multiplayer.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit fcc22a3

Please sign in to comment.