AI configuration: new optional parameter mp_rank=
This parameter determines in which order the available AIs are shown in the MP computer player selection menu. This can be used for eras, modifications or cores to change which AI is first in the list.
This commit is contained in:
parent
a96487a837
commit
a2c30ea665
7 changed files with 16 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
id=ai_default_rca
|
||||
description=_"Multiplayer_AI^Default AI (RCA)" # wmllint: no spellcheck
|
||||
# RCA := Register Candidate Action; more info at https://forums.wesnoth.org/viewtopic.php?p=419625#p419625
|
||||
mp_rank=1010
|
||||
[stage]
|
||||
id=main_loop
|
||||
name=ai_default_rca::candidate_action_evaluation_loop
|
||||
|
|
|
@ -8,5 +8,6 @@
|
|||
[ai]
|
||||
id=experimental_ai
|
||||
description=_"Multiplayer_AI^Experimental AI" # wmllint: no spellcheck
|
||||
mp_rank=1000
|
||||
{EXPERIMENTAL_AI}
|
||||
[/ai]
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
id=ai_default_rca_alternate_recruiting
|
||||
description=_"Multiplayer_AI^Dev AI: Default AI (RCA) with Alternate Recruiting" # wmllint: no spellcheck
|
||||
# RCA := Register Candidate Action; more info at https://forums.wesnoth.org/viewtopic.php?p=419625#p419625
|
||||
mp_rank=100
|
||||
[stage]
|
||||
id=main_loop
|
||||
name=ai_default_rca::candidate_action_evaluation_loop
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
[ai]
|
||||
id=formula_ai # id is needed to uniquely identify a MP AI, it is not needed in the scenario AI
|
||||
description=_"Multiplayer_AI^Dev AI: Default + Experimental Recruitment (Formula AI)" # wmllint: no spellcheck
|
||||
mp_rank=100
|
||||
# this description is, again, needed for MP AI (it shows in AI list under this description
|
||||
|
||||
[stage]
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
[ai]
|
||||
id=formula_ai_poisoning
|
||||
description=_"Multiplayer_AI^Dev AI: Default + Poisoning (Formula AI)" # wmllint: no spellcheck
|
||||
mp_rank=100
|
||||
[stage]
|
||||
id=main_loop
|
||||
name=ai_default_rca::candidate_action_evaluation_loop
|
||||
|
|
|
@ -69,6 +69,7 @@ void configuration::init(const config &game_config)
|
|||
|
||||
description desc;
|
||||
desc.id=id;
|
||||
desc.mp_rank=ai_configuration["mp_rank"].to_int(0);
|
||||
desc.text = ai_configuration["description"].t_str();
|
||||
desc.cfg=ai_configuration;
|
||||
|
||||
|
@ -95,6 +96,7 @@ void extract_ai_configurations(std::map<std::string, description> &storage, cons
|
|||
description desc;
|
||||
desc.id=id;
|
||||
desc.text = ai_configuration["description"].t_str();
|
||||
desc.mp_rank = ai_configuration["mp_rank"].to_int(0);
|
||||
desc.cfg=ai_configuration;
|
||||
|
||||
storage.emplace(id, desc);
|
||||
|
@ -143,6 +145,13 @@ std::vector<description*> configuration::get_available_ais()
|
|||
add_if_not_hidden(&m_config.second);
|
||||
}
|
||||
|
||||
// Sort by mp_rank. For same mp_rank, keep alphabetical order.
|
||||
std::stable_sort(ais_list.begin(), ais_list.end(),
|
||||
[](const description* a, const description* b) {
|
||||
return a->mp_rank > b->mp_rank;
|
||||
}
|
||||
);
|
||||
|
||||
return ais_list;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,12 +46,14 @@ public:
|
|||
description()
|
||||
: text()
|
||||
, id()
|
||||
, mp_rank()
|
||||
, cfg()
|
||||
{
|
||||
}
|
||||
|
||||
t_string text;
|
||||
std::string id;
|
||||
int mp_rank;
|
||||
config cfg;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue