Preventing AI from hunting/capturing villages?

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.
Post Reply
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Preventing AI from hunting/capturing villages?

Post by kurt751 »

As far as I read in the AiWML, putting village_value=0 in a side's "AI" declaration makes it ignore villages.
The problem is the side will still capture villages despite this, even if (indeed) it doesn't make village hunting a priority anymore.
Is there a way to make a given side ignore villages totally? Even if they happen to stop right besides an enemy/free village?

Here is what I've tried (inside the [side] declaration):

Code: Select all

	[ai]
	   aggression=0.50
	   caution=0.4
	   village_value=0
	[/ai]
As I said, it kind of works, as it puts village hunting very low on the priority scale, but when a unit comes near a village it will go take it nevertheless. I want them to be totally oblivious to villages, they don't need them, they should leave them alone.
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Preventing AI from hunting/capturing villages?

Post by Tad_Carlucci »

I played with this a few days ago and came to the conclusion it was good enough.

On a tall/thin map the enemies started up north and my heros down south. To test I just watched the enemies advance. They marched past a dozen or so villages without problem. But, when they got close to my heroes they started taking villages. I concluded it was for the defense and declared that 'good enough' but would have preferred they get a bit closer.

In normal play, the forces would be much closer and my concern was simply that the enemies not start out by saying, "Sure, I see you there, wait a moment while I capture a few villages, then we can rumble!" .. which was their original behavior.
I forked real life and now I'm getting merge conflicts.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: Preventing AI from hunting/capturing villages?

Post by kurt751 »

Yes, in your case it makes sense (though they could only capture villages if/when they need to heal). But in my case it doesn't make any sense: Wildlife capturing villages looks a little silly and is also rather annoying, for it means the player has to run back re-capture his villages every now and then...

I need a way to totally cure the AI of its village obsession... I'm sure there must be some means to do this. Everything is tweakable in this game, I can't imagine they overlooked this quite obvious case.
Spixi
Posts: 91
Joined: August 23rd, 2010, 7:22 pm

Re: Preventing AI from hunting/capturing villages?

Post by Spixi »

Have you tried using the [avoid] aspect for the locations of the villages?

Code: Select all

[avoid]
terrain=*^V*
[/avoid]
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Preventing AI from hunting/capturing villages?

Post by Tad_Carlucci »

That prevents the AI from stepping on the terrain. Works well enough if it's just one hex and there's no other reason to step there, like defense or attacking someone on the other side.
I forked real life and now I'm getting merge conflicts.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: Preventing AI from hunting/capturing villages?

Post by kurt751 »

Spixi wrote:Have you tried using the [avoid] aspect for the locations of the villages?
No, that's worth a try. Villages are sparse and out of the way, so it should work. Thanks, I'll try that as soon as I have some free time.

I'm just a little worried about how the AI might react to not being able to enter a village. Will it be intelligent enough to accept its fate and move on, or will it just keep trying and trying, round after round, in an endless loop of "A village, capture it! Oh, can't get in. A village, capture it! Oh, can't get in. A village, capture it! Oh, can't get in." (and so on)?
The second, similar problem will be wounded units who would want to run to a village for healing. Being unable to get into it, I'm afraid there might be an ever-growing ring of wounded critters lingering around villages... :shock: :lol:
Needs some testing.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Preventing AI from hunting/capturing villages?

Post by mattsc »

kurt751 wrote:As I said, it kind of works, as it puts village hunting very low on the priority scale, but when a unit comes near a village it will go take it nevertheless. I want them to be totally oblivious to villages, they don't need them, they should leave them alone.
The village grabbing once a village is in range is done by the villages candidate action (CA). You can remove that CA as described here. Just replace combat by villages (or if you need the id of another CA at some point, follow the link for the cpp engine here). If you do it that way, units will still move onto villages if another action takes them there, but will not specifically grab them any more.

[And you still need village_value=0, of course, so that the AI does not go for far away villages.]
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Preventing AI from hunting/capturing villages?

Post by Tad_Carlucci »

Missed it by 'that' much .. the PR I would have tried this on was just merged. I'll give it a try.

The problem I'm having is there are a lot of places in mainline where avoiding villages like this makes a lot of sense but when I try it, the result is so un-balanced the poor player won't have a chance, and I'm trying to avoid that kind of change. So, usually, I just sigh and move on; wishing I could tell the AI to act more logically but not wanting to open the 'balance' can of worms.

ETA works pefectly in my test case

Snipping out a LOT ...

Code: Select all

    [side]
        side=3
        [ai]
            leader_ignores_keep=yes
            village_value=0
        [/ai]
    [/side]

    [event]
        name=prestart

        [modify_ai]
            side=3
            action=delete
            path=stage[main_loop].candidate_action[villages]
        [/modify_ai]
    [/event]
The side=3 enemies marched down the long/thin map, only capturing villages which were exactly at the end of a move, bypassing all others, and headed after my side=1 units without distraction.
I forked real life and now I'm getting merge conflicts.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: Preventing AI from hunting/capturing villages?

Post by kurt751 »

mattsc wrote:The village grabbing once a village is in range is done by the villages candidate action (CA). You can remove that CA as described here.
Very interesting! Thanks a lot. :D
Post Reply