AI not recruiting

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: AI not recruiting

Post by ChaosRider »

Thats how i have set ai leader which i want him to be still in castle, he could attack near enemies without moving from fort (but this is not most important), and to recruit when have gold and free castle hex adjected to his fort in which he is:
Spoiler:
with this code ai still sometimes save gold (wesnoth 1.10 version :P, not 1.11).
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: AI not recruiting

Post by mattsc »

ChaosRider wrote:with this code ai still sometimes save gold (wesnoth 1.10 version :P, not 1.11).
Oh... Well, the feature discussed here is 1.11 only (and more specifically, 1.11.7 and later only), so what you are encountering must be something different. It also means that putting that aspect into the AI [side] tag will have no effect at all.

If you post a savegame and/or replay, I could have a look to see what's going on. I don't have enough information to guess at the cause at the moment.
User avatar
Crab
Inactive Developer
Posts: 200
Joined: March 18th, 2009, 9:42 pm

Re: AI not recruiting

Post by Crab »

Velensk wrote:The problem is that there are very few times while in a campaign that it makes sense for the AI to save it's gold at all.
I'd like to hear flixx's (author's) opinion on that (I hope that he will reply, mattsc pinged him about this thread). I don't see a problem with changing the default value, not because one is strictly better than the other, but simply because the current default is not what the scenario creators expect.
justinzane
Posts: 1
Joined: December 7th, 2013, 9:49 pm

Re: AI not recruiting

Post by justinzane »

I'm slowly working on an SDL2 port, so I have not kept up with mainline. Having pulled and build HEADS/master, I was mortified to find that my favorite Campaign LotI is totally horked because of the AI change. Now, since I'm already hacking on Wesnoth, it is a minor annoyance to spend 30 min checking out and building an older tag so I can play. For those who are not part of the development community, this will likely be a very unpleasant surprise. I'm shocked that this was pulled into master and not into its own branch so that it could be thoroughly tested and scripts could be written to semi-automate the process of making existing WML compliant with the new AI.

I guess that, if generally, it improves playability significantly, it would be an excellent addition. I would love, though, to see some effort made at handling non-updated add-ons since there are many nice, though unmaintained addons out in the wild. Even reverting to old behavior without seeing a "save_gold=<num>" tag might help.
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: AI not recruiting

Post by iceiceice »

My 2 cents -- as I noticed when attempting to hack my own AI's into wesnoth, there is now a version checking routine which tries to ensure AI backwards compatibility, set up, if I am not mistaken, by Crab. (See code here, here.) Maybe the AI can use the "save gold enabled" as default for all versions going forward from 1.11.7, but for all previous versions keep the new feature off so as not to break all old campaigns / force rebalancing of everything which appears to be a ton of work.

This way if the new behavior is desired for mainline campaigns, they can be marked with version > 1.11.7 and balanced one at a time, and in the meantime the others will be playable.
tuggyne
Posts: 76
Joined: May 22nd, 2011, 5:52 am

Re: AI not recruiting

Post by tuggyne »

Mabuse wrote:btw, intuition tells me that a human also do better when he doesnt save lots of gold and send his units into battle asap. there are exceptions, but in general, you always do better if you constantly support your frontline with troops (ye earlier you train them, ye earlier they will arive where they are eagerly needed).

beside some rare gold saving tricks AT START (recruit only units nesessary for grabbing the desired villages and save the income of the other units) to save the one or other buck to get one more recruit on turn 2 or 3, i never save gold when i play regular wesnoth (not campaigns).
I'd note that MP play is demonstrably quite different from what I'd consider "classic" Wesnoth (i.e., campaigns), since there it's all about short-term survivability and small shifts in spending/income efficiency. In campaigns, the strokes are considerably broader, and often mid- to late-game income is considerably more restrictive, so even the AI may be able to squeeze a bit of extra effectiveness out of saving gold at times.

Whether that's often enough to justify having this feature on by default, I'm not sure. I should get 1.11.7 and try it out, I guess.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: AI not recruiting

Post by ChaosRider »

As for me when we know what our ai leader should recruit we can accept his gold saving and just add code for his extra recruiting. We have to make code which will works on ai turn end in which first we will search closest to ai castle hexes and store them, later for each stored castle hex we should somehow check is it possible to create there new unit (cause we can have there already some other earlier by ai recruited unit) and if its free then from ai recruit list pick randomly unit id and check is he have enough gold to recruit it, if not then we start checking next stored castle hex, if yes then we create unit and going to another castle hex, such a new unit have to have also 0 mp left and 0 attacks left...
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: AI not recruiting

Post by mattsc »

Hi ChaosRider: if I understand you correctly, what you are suggesting is much more complicated than what is needed. First, you can turn on and off gold saving and customize a lot of other things about recruiting with the parameters described on the wiki page linked to above (as in the example you post yourself up there, but 1.11.7 and later only). If that is not enough, there are already alternative recruiting AIs available that you could use. But maybe I misunderstood what you are saying.

As a general update, we have not forgotten about the discussion in this thread, but we haven't been able to get a hold of flixx yet (he's been really busy with other things lately). Hopefully he'll reappear soon.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: AI not recruiting

Post by Anonymissimus »

Giving my 2 cents on this was well.
I think the feature should be deactivated by default; I played a mainline scenario I know well; the AI's gold saving didn't make much sense to me, and it was bad strategy, as it makes it easier for me (the human) to finish the waves off, each all at once, and then stay out of reach of the next wave once that's done. Thus it makes the AI play worse.
1 or 2 mainline campaigns using the feature should be enough for testing, just as LoW is the testing ground for changes to the "MP campaigns" developing area.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: AI not recruiting

Post by mattsc »

Hello everybody, just a brief update: 1.11.8 was just released and the gold saving is still in it as the default because we have not been able to get a hold of everybody involved with its development yet. We will, however, make a decision for 1.11.9 one way or another, whether everybody has weighed in by then or not.

In the meantime, we really appreciate the many thoughtful comments that have been made in this thread and ask you to keep them coming. Particularly useful are those that describe results of actual tests in specific scenarios. And independent of the question what the gold saving default should be, feedback on how all aspects of the new recruiting work in different situations would be extremely useful. Thanks, everybody.

Having said that, there is definitely the possibility that the default will be reverted to the old method (no gold saving), so if you don't want to rebalance your scenarios before 1.11.9, there are (at least) two methods of doing this:
  • Disable gold saving on a scenario-by-scenario basis (you probably really only have to do this for a few scenarios, as most of them should not be affected in a significant way) by putting this

    Code: Select all

    [ai]
        {AI_ASPECT recruitment_save_gold {AI_DEACTIVATE_SAVE_GOLD} }
    [/ai]
    into the AI [side] tag(s). You can also change many other recruitment parameters as described on the wiki. Note that you won't have to change this back if the default gets reset to the old behavior, as it then simply sets the behavior to what's the default anyway - which is unnecessary but does no harm.
  • You could locate the AI aspects default settings file in your data directory and hack it to change the default behavior. However, changing your core files is generally not recommended (and will make your version of Wesnoth behave differently from everybody else's), so I cannot recommend doing that. :D
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: AI not recruiting

Post by mattsc »

Another quick update: The following will be in the release notes when 1.11.9 comes out:
RCA (default) AI gold saving default is reverted back to 'off'
Based on the feedback we have gotten, we turned gold saving off by default for the RCA AI. There is no clear overall benefit to having it turned on and it would require many scenarios to be rebalanced. There are, however, individual scenarios which definitely benefit from enabling gold saving. Help with identifying such scenarios will be much appreciated.
I am making this a separate post as it is a significant update and so that it does not get lost in the rather lengthy previous post.
Post Reply