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 23 Nov 2013 03:06:22 PM UTC  
 
Category: BugSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Artificial Intelligence
Status: NonePrivacy: Public
Assigned to: Iurii Chernyi <crab>Open/Closed: Open
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.

 

Tue 26 Nov 2013 05:05:25 PM UTC, comment #3:

P.S. to Nov 24 post:

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

Anonymous
Sun 24 Nov 2013 07:00:44 AM UTC, 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:

http://wiki.wesnoth.org/WritingYourOwnAI#C.2B.2B

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

[code]
ai_ptr manager::create_transient_ai(const std::string &ai_algorithm_type, const config &cfg, ai_context *ai_context )
{
assert(ai_context!=NULL);

//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()){
[/code]

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 24 Nov 2013 12:59:29 AM UTC, comment #1:

I'll take a look

Iurii Chernyi <crab>
Project MemberIn charge of this item.
Sat 23 Nov 2013 03:06:22 PM UTC, 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;
break;
}
}
}

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):
   
   
Comment:
   

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 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.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 27 Nov 2013 12:36:44 AM UTCmattscCategoryFeature Request=>Bug
    Mon 25 Nov 2013 12:58:16 AM UTCmattscCategoryBug=>Feature Request
    Sun 24 Nov 2013 12:38:30 AM UTCmattscAssigned toNone=>crab
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup