bugBattle for Wesnoth - Bugs: bug #21294, undocumented "backwards...

Show feedback again

bug #21294: undocumented "backwards compatability" code silently strips out custom ais

Submitted by:  Chris Beck <involution>
Submitted on:  Sat Nov 23 15:06:22 2013  
Category: BugSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Artificial Intelligence
Status: FixedPrivacy: Public
Assigned to: Iurii Chernyi <crab>Open/Closed: Closed
Release: 1.11.7Operating System: linux

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Sun Jul 31 05:59:23 2016, comment #4:

The backwards compatibility code has actually been removed (though some of its functionality - converting simple aspects to the full form - is still present in a different form) and the version key is no longer used. Furthermore, the old AI interface class has also been removed, so this issue is basically very obsolete.

Celtic Minstrel <celticminstrel>
Project Member
Tue Nov 26 17:05:25 2013, comment #3:

P.S. to Nov 24 post:

The version numbers not being parsed correctly is almost certainly a bug though.

Sun Nov 24 07:00:44 2013, comment #2:

Yeah so in the time since I posted this bug report, I have learned new information.

When I wrote this I basically assumed that functionality to derive a new AI from ai::interface and add it to regsistry was supported, like mentioned here:


and in comments in registry.cpp, manager.cpp, for instance below line 656 of manager.cpp:

ai_ptr manager::create_transient_ai(const std::string &ai_algorithm_type, const config &cfg, ai_context *ai_context )

//to add your own ai, register it in registry,cpp
ai_factory::factory_map::iterator aii = ai_factory::get_list().find(ai_algorithm_type);
if (aii == ai_factory::get_list().end()){

It looks like all of this code has basically been disabled. For one there is this issue mentioned here about the version which blocks it, and also the "create_transient_ai" method is unreachable in current wesnoth build, and probably has been for years.

So this is only actually a bug if it was not intended to disable custom wesnoth C++ ais. In this case, consider this a feature request to go back to supporting that again.

Chris Beck <involution>
Project Member
Sun Nov 24 00:59:29 2013, comment #1:

I'll take a look

Iurii Chernyi <crab>
Project MemberIn charge of this item.
Sat Nov 23 15:06:22 2013, original submission:

From /src/ai/configuration.cpp:

The function configuration::parse_side_config, which converts config structures to ais, currently runs a check for an ai parameter "version". If version.to_int() < 10703, then it runs the following function which strips out any custom ai config info, replacing with idle_ai or default_rca_ai.

This is quite counter intuitive as the wiki for AIwml does not document the "version" field anywhere, and also version is not parsed properly. I should be able to type "version=1.11.7" in my ai-cfg files to ensure that they are protected against this, but that doesn't work (leads to version.to_int() = 1), and I must type "version=11107" in my ai configs instead.

I think that at the least a note should be put on the wiki about the version flag and what it does, but ideally configuration.cpp could be made to parse version strings correctly. This is quite a pain for anyone who tries to make a custom ai in C++, I had to read most of /src/ai before I figured out what was going on.

bool configuration::upgrade_side_config_from_1_07_02_to_1_07_03(side_number side, config &cfg)
LOG_AI_CONFIGURATION << "side "<< side <<": upgrading ai config version from version 1.7.2 to 1.7.3"<< std::endl;
config parsed_cfg;

bool is_idle_ai = false;
if (cfg["ai_algorithm"]=="idle_ai") {
is_idle_ai = true;
} else {
BOOST_FOREACH(config &aiparam, cfg.child_range("ai")) {
if (aiparam["ai_algorithm"]=="idle_ai") {
is_idle_ai = true;

if (!is_idle_ai) {
parsed_cfg = get_ai_config_for("ai_default_rca");

Chris Beck <involution>
Project Member


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by celticminstrel (Posted a comment)
  • -unavailable- added by crab (Posted a comment)
  • -unavailable- added by mattsc (Updated the item)
  • -unavailable- added by involution (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun Jul 31 05:59:23 2016celticminstrelStatusNone=>Fixed
    Wed Nov 27 00:36:44 2013mattscCategoryFeature Request=>Bug
    Mon Nov 25 00:58:16 2013mattscCategoryBug=>Feature Request
    Sun Nov 24 00:38:30 2013mattscAssigned toNone=>crab
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup