How to make AI less aggressive

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.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: How to make AI less aggressive

Post by mattsc »

Starlight wrote:I have been looking at the depend_pass lua and I must say hats off to you for the amount of effort that has gone into it.

While coding is very dependent on the capabilities of the programmer, could you give an estimate of the time that would have gone into creating the Defend_pass AI.
Umm, that was quite some time ago, so I don't quite remember. It was also my first "real" AI scenario, so I am sure I was slower than I could do it now. But if I should guess, "a few weeks", probably.
Starlight wrote:This is because I am planning on coding a version of Capture the Flag myself (after I learn a few more things)
Great.
Starlight wrote:I tried playing the Prune Cart scenario. I was focusing on broad strategy, rather than tactics.
...
Thanks for the feedback! The Prune Cart AI is definitely not finished yet. Once I have figured out the grunt rushes a bit more, I am planning to come back to it. Any feedback like this helps a lot for that.
Starlight wrote:In the first playthrough (not attached) - I did nothing for four turns, which made the AI send its Healer (Saurian Soothsayer) to me to attack. I easily finished it off - the AI ideally does not want to risk its healers in attacks against Level 4 units.
That sounds like a bug. I'll check it out.
Starlight wrote:3. A final suggestion is more long-term - I am sure you have more immediate things to look at.
In terms of demoing / impressing people with the diffference that these AI's make it would be great if you would have a scenario where *both* opposing sides are coded with micro-AI's.
Noted. That's a good idea but as you said, it will have to wait until later...
Starlight wrote:I will look at the two things that you mentioned above - Protect the Wizard, and Elves Besieged.
Just FYI, that's really the same AI, just in different settings.
Starlight wrote:Scenario 17 (replay attached) was an improvement over the previous behaviour. I got the AI to behave in a way that is more human.
However, I also introduced one issue which I think is related to the pathfinding in the AI. The AI only ends up using two of the three avialable bridges. Ideally it should be using all available bridges.
Yeah, the AI will generally try to take the shortest route to whatever it considers its goals (the enemy leader, in this case). If you want it to split up its forces and come in from the other side also, you'll have to do that manually. That could be done either with a custom candidate action, or with WML events. Without having tried it, I expect that you only have to move them until the path across the third bridge is shorter than across the others, after that you can let the normal AI take over. There might also be a way of setting up a temporary [goal] tag to entice units to get "behind" the castle and then deleting that tag to let it go back to default behavior.
Starlight
Posts: 40
Joined: September 11th, 2012, 11:04 am
Location: Mumbai, India

Re: How to make AI less aggressive

Post by Starlight »

Mattsc wrote:Umm, that was quite some time ago, so I don't quite remember. It was also my first "real" AI scenario, so I am sure I was slower than I could do it now. But if I should guess, "a few weeks", probably.
I will be quite happy if I can get something like this out in a few weeks. I don't think I will get to work on this other than weekends.
Starlight wrote:This is because I am planning on coding a version of Capture the Flag myself (after I learn a few more things)
Mattsc wrote:Great.
I am a bit of a lazy programmer - and all for re-using code. For example, if I took your prune cart AI (once it is all nice and done) and then prefixed a "target AI" I think I have a capture the Flag AI.
I am sure it will not be as simple as that - but it is a start.

At a very broad level, do you think that the Prune Cart AI will work for the second part of Capture the Flag - where you have the flag and wish to move it back to the home base.
Mattsc wrote:Thanks for the feedback! The Prune Cart AI is definitely not finished yet. Once I have figured out the grunt rushes a bit more, I am planning to come back to it. Any feedback like this helps a lot for that.
It still looks pretty polished to me though I am sure there are areas of improvement - what are the places that you want you want to work on?
Starlight wrote:Scenario 17 (replay attached) was an improvement over the previous behaviour. I got the AI to behave in a way that is more human.
However, I also introduced one issue which I think is related to the pathfinding in the AI. The AI only ends up using two of the three avialable bridges. Ideally it should be using all available bridges.
Mattsc wrote:Yeah, the AI will generally try to take the shortest route to whatever it considers its goals (the enemy leader, in this case). If you want it to split up its forces and come in from the other side also, you'll have to do that manually. That could be done either with a custom candidate action, or with WML events. Without having tried it, I expect that you only have to move them until the path across the third bridge is shorter than across the others, after that you can let the normal AI take over. There might also be a way of setting up a temporary [goal] tag to entice units to get "behind" the castle and then deleting that tag to let it go back to default behavior.
I am planning on fixing this in a couple of ways:
1. Adding one more bridge with a two-hex width on the side where there is currently none.2
2. Adding some "targets" to a few units to get them near the bridge (as suggested above) and then hopefully the AI should take up from there.

I am potentially toying with the idea of putting a Defend Pass AI on the bridges, which will force the human player to either:
1. Break the Pass
2. Attack via the water
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: How to make AI less aggressive

Post by mattsc »

Starlight wrote:I am a bit of a lazy programmer - and all for re-using code.
If you ask me, that's the way to go: Steal Often
Starlight wrote:For example, if I took your prune cart AI (once it is all nice and done) and then prefixed a "target AI" I think I have a capture the Flag AI.
I am sure it will not be as simple as that - but it is a start.

At a very broad level, do you think that the Prune Cart AI will work for the second part of Capture the Flag - where you have the flag and wish to move it back to the home base.
In a broad sense, yes, that might be a way to get started. The devil's always in the details, but you have to begin somewhere...
Starlight wrote:It still looks pretty polished to me though I am sure there are areas of improvement - what are the places that you want you want to work on?
It's been so long I forgot the details, but I think I often found that things start falling apart later in the scenario, when the enemy starts spreading out or the AI has lost some units. I am not sure what the exact reason for this is though, so I'll have to dig into it at some time.
Starlight wrote:I am planning on fixing this in a couple of ways:
1. Adding one more bridge with a two-hex width on the side where there is currently none.2
2. Adding some "targets" to a few units to get them near the bridge (as suggested above) and then hopefully the AI should take up from there.
Sounds like a plan.
Starlight wrote:I am potentially toying with the idea of putting a Defend Pass AI on the bridges, which will force the human player to either:
1. Break the Pass
2. Attack via the water
Interesting. The one thing that might be a problem with that is that the Pass Defense is really set up for a situation when there's no way around. It probably won't work very well once the enemy starts making its way around (through the water in your case).

Btw, I just finished turning the Pass Defense (now called Bottleneck Defense) into a Micro AI that can be used with the new [micro_ai] WML tag on any map. It's not been released on the add-ons server yet because I am still having some trouble with Fred (the Grunt Rush AI) and don't want to release a version with a broken AI in it. If you want to test it right away, you can get the current development version from the AI-Demos github site. You can see in file scenarios/bottleneck-defense.cfg how to use the [micro-ai] tag. I haven't quite had time to update the Micro AI wiki page fully yet, but I hope to get to that tomorrow.

Edit: Documentation added to the wiki page.
Starlight
Posts: 40
Joined: September 11th, 2012, 11:04 am
Location: Mumbai, India

Re: How to make AI less aggressive

Post by Starlight »

Starlight wrote:I am potentially toying with the idea of putting a Defend Pass AI on the bridges, which will force the human player to either:
1. Break the Pass
2. Attack via the water
mattsc wrote:Interesting. The one thing that might be a problem with that is that the Pass Defense is really set up for a situation when there's no way around. It probably won't work very well once the enemy starts making its way around (through the water in your case).
Very valid. Let me try out and see what if you say happens.
mattsc wrote: Btw, I just finished turning the Pass Defense (now called Bottleneck Defense) into a Micro AI that can be used with the new [micro_ai] WML tag on any map. It's not been released on the add-ons server yet because I am still having some trouble with Fred (the Grunt Rush AI) and don't want to release a version with a broken AI in it. If you want to test it right away, you can get the current development version from the AI-Demos github site. You can see in file scenarios/bottleneck-defense.cfg how to use the [micro-ai] tag. I haven't quite had time to update the Micro AI wiki page fully yet, but I hope to get to that tomorrow.

Edit: Documentation added to the wiki page.
I have put on hold Fellowship of the Clay. With my not being the author, I may not be able to story elements - which may be required if I introduce your AI. However, I do intend to make changes to Fellowship at a later date.

However, I have taken up responsibility for Knights of the Silver Spire - porting from 1.5. A working first scenario has been uploaded to 1.10 add-on server. I will have more control over the development of scenarios in that campaign, and I intend to highlight MIcro AI's in some of the scenarios.
Post Reply