Question about AI and ships...

Discussion of all aspects of the game engine, including development of new and existing features.

Moderators: Forum Moderators, Developers

Post Reply
User avatar
junoslord
Posts: 82
Joined: June 11th, 2012, 3:13 pm
Location: Enveloping your left flank.

Question about AI and ships...

Post by junoslord »

I have been working for a few weeks on some ideas I've had for naval combat... until a couple of days I haven't really tried to play test anything. Just snippets here and there to see if things work the way they should.

That's when I realized I have a big problem... the CPU doesn't recruit ships... nor does it appear to know what to do with ships I supply for it in start events... I give it six ships (to my three) and it literally sends one ship out, while the rest just sit there doing nothing, waiting for me to find them (in the place I put them!). Keep in mind I have tried to change unit type from fighter, to archer, to mixed fighter, to scout... nothing!

This leads me to a couple of questions:

1, is my assumption about the AI being dumb about shipping correct? Or am I not doing something I should be? Seems like it should just work, like with all the other unit/scenarios.

2, how do I get the CPU to recruit ships? If I give a recruit list will this fix this problem? If this works how do I 'teach' the AI to use them properly? (This leads to #3.)

3, I was looking at the Macro AI's page on the wiki (here) and the wolves, and multi-pack wolves, look like they might have some use in getting the AI to deploy ships. I also think that the herd/herders macro might work for convoy duty. The only problem I see is that neither of the first two macros seems to say "attack! and don't stop till their sunk." Is there a way to tweak these to be more aggressive?


Thanks, in advance, for any help!
Last edited by junoslord on January 21st, 2013, 9:31 am, edited 1 time in total.
America-- Land of the Free, home of the Brave! "And now that we've taken care of the Braves we're coming after the Free."

"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"

User avatar
terrorbot276
Posts: 67
Joined: January 21st, 2010, 10:45 pm

Re: Questiuon about AI and ships...

Post by terrorbot276 »

1. I have created various custom units for myself, but I have never encountered a problem with the ai like this. One possibility is that something in the unit code (e.g. a under- or overpowered attack) is messing up the ai's ability to judge how to attack. If the unit deals no damage, it might just hang back and defend.

2. Do you mean you don't have a recruit list for the ai in the scenario, or that you have it and it's not working? If you don't have a recruit list in the ai side's [side] code (or any gold for it to spend) it won't be able to recruit anything. As for 'teaching' it, I believe the default ai is made to handle non-default units, so long as they don't completely break the norm (e.g. having 9999 HP).

3. You can actually change aggressiveness without micro-ai tags. The ai has a set level of aggressiveness. This balances the ai's moves by having it consider how much damage it might take, not just how much it will give. If this really is the reason the ships are hanging back, you can change the aggressiveness like so:

Code: Select all

[side]
    ...
    [ai]
        ...
        aggression=(-infinity to 1.0)
        ...
    [/ai]
    ...
[/side]
Maybe you could set it to 1 and see if that fixes it? If so, you could mess with the setting until they attack, but also aren't suicidal.
There are 11 types of people in the world: those who know binary and those who don't.
You just lost the game.

User avatar
junoslord
Posts: 82
Joined: June 11th, 2012, 3:13 pm
Location: Enveloping your left flank.

Re: Questiuon about AI and ships...

Post by junoslord »

1 & 2 seem to have been the result of some bad scenario coding. I made some tweaks and it seems to work better... it's recruiting and deploying now.

I think for #3 I wasn't specific enough (my fault)... As it is now the AI is sending out ships alone, what I am looking for is a way to get the AI to send out fleets, or at least flotillas, that will basically stay together and fight and support each other. When the player is moving ships in groups of 3-5 and the CPU is in groups of 1 there isn't much of a fight, it just takes longer to hunt them all down. But if they where in 3-5 ship groups it would make the battles much more epic-- and much more important in the overall scheme of a scenario. If loosing a ship is no big deal because the enemy is dispersed, there's a problem. When going into battle might end up loosing you 2+ ships every time you may be a bit more cautious, which gives the CPU more time to build it's strength.
Last edited by junoslord on January 21st, 2013, 9:23 am, edited 1 time in total.
America-- Land of the Free, home of the Brave! "And now that we've taken care of the Braves we're coming after the Free."

"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"

mattsc
Posts: 1166
Joined: October 13th, 2010, 6:14 pm
Location: Hidden on the hex behind Fred

Re: Questiuon about AI and ships...

Post by mattsc »

junoslord wrote:3, I was looking at the Macro AI's page on the wiki (here) and the wolves, and multi-pack wolves, look like they might have some use in getting the AI to deploy ships. I also think that the herd/herders macro might work for convoy duty. The only problem I see is that neither of the first two macros seems to say "attack! and don't stop till their sunk." Is there a way to tweak these to be more aggressive?
Have you tried that they are not aggressive enough? I'm just wondering because I think the multi-pack wolves shold be pretty close to what you are looking for - assuming that I understand what you want correctly. The pack really goes after anything that comes into its range. The one thing it does not do is actively searching out the enemies. Instead, it wanders randomly until enemies come into attack range somewhere. That part could probably be changed quite easily.

By contrast, the wolves AI seeks out its enemies (prey), but the pack might split up if attacks are possible in different directions by different wolves. I'd suggest that you watch a few rounds of both AIs using either the test scenarios or the AI Demos add-on and see if that would work for you - and if not, let us know what changes would make it closer to what you imagine. Even better, add it into your scenario and see how it does. The more specific your comments, the more likely it is that we can do something about it.

User avatar
junoslord
Posts: 82
Joined: June 11th, 2012, 3:13 pm
Location: Enveloping your left flank.

Re: Question about AI and ships...

Post by junoslord »

Matt, thanks for the interest, I will try to put them in a couple of test scenarios I have and see what they do. It was one of your posts that actually led me to the macro page on the first place.
America-- Land of the Free, home of the Brave! "And now that we've taken care of the Braves we're coming after the Free."

"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"

User avatar
junoslord
Posts: 82
Joined: June 11th, 2012, 3:13 pm
Location: Enveloping your left flank.

1.11.2

Post by junoslord »

I finally got to download the AI campaign and take a look at it after the server came back up. (It was down for everybody, right?)

I tried to install the macro and was given an error, and then realized that I need v11.2 and I am only running 11.1.

I looked for another version but couldn't find one. Is this not mainlined yet, or am I looking in the wrong place? Is there a copy of the macro I could include?
America-- Land of the Free, home of the Brave! "And now that we've taken care of the Braves we're coming after the Free."

"BANNED!!! What the hell do you mean BANNED? All I did was call one narrow-minded, power-hungry Nazi moderator a narrow-minded, power-hungry Nazi!"

mattsc
Posts: 1166
Joined: October 13th, 2010, 6:14 pm
Location: Hidden on the hex behind Fred

Re: 1.11.2

Post by mattsc »

junoslord wrote:I finally got to download the AI campaign and take a look at it after the server came back up. (It was down for everybody, right?)
Yes, it was.
junoslord wrote:I tried to install the macro and was given an error, and then realized that I need v11.2 and I am only running 11.1.

I looked for another version but couldn't find one. Is this not mainlined yet, or am I looking in the wrong place? Is there a copy of the macro I could include?
Yeah, that's true. The Micro AIs will not be in mainline until Wesnoth 1.11.2 (and just in case that's not clear, with 1.11.2 you do not need to download the AI Demos campaign for them to work). If you want to use them now, you can use the macros from inside the add-on. Put the following into your _main.cfg:

Code: Select all

{~add-ons/AI-demos/micro_ais/activate_micro_ais.cfg}
That activates the [micro_ai] tag and includes the macros you need.

Post Reply