Micro AIs Feedback and Development
Moderator: Forum Moderators
Micro AIs Feedback and Development
A variety of Micro AIs were introduced in Wesnoth 1.11.2 as an easy method to introduce specialized and configurable AI behavior to a scenario.
This thread is set up to collect MAI feedback and development discussions. If you find a bug,1 don't think that the AI is behaving as it should, have a feature request for a new parameter to an existing MAI or for an entirely new MAI etc., please don't hesitate to let us know here. The MAIs have only been tested by a small number of people so far and new MAIs are being introduced with almost every development release. There will inevitably be bugs or situations that we simply did not think about, so we really need your feedback.
A couple notes (more to be added as I come up with them):
1Depending on the bug, we might still ask you to fill out an official bug report after posting it here.
This thread is set up to collect MAI feedback and development discussions. If you find a bug,1 don't think that the AI is behaving as it should, have a feature request for a new parameter to an existing MAI or for an entirely new MAI etc., please don't hesitate to let us know here. The MAIs have only been tested by a small number of people so far and new MAIs are being introduced with almost every development release. There will inevitably be bugs or situations that we simply did not think about, so we really need your feedback.
A couple notes (more to be added as I come up with them):
- Check out the Micro AIs wiki page for more information or, even better, play through some of the demo scenarios.
- While the MAIs were originally developed as part of the AI-demos add-on, that add-on is not required for them to work any more these days. Report feedback about the Micro AIs here, and only feedback specific to the add-on -- such as comments on the MP AIs (Fred & Ron) -- in its feedback thread.
1Depending on the bug, we might still ask you to fill out an official bug report after posting it here.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- Bob_The_Mighty
- Posts: 870
- Joined: July 13th, 2006, 1:15 pm
Re: Micro AIs Feedback and Development
Hi mattsc. I've been playing around a little bit more with micro ai behaviour and had a couple of general thoughts:
1. Can I ask why these behaviours are filtered on a unit's id rather than with a standard unit filter? The latter would be more intuitive and flexible, but perhaps there's hidden problems in using a SUF that I've not considered. I would like to be able to turn micro ais on and off for several units in one go without having to specify each one individually.
2. The patrol and guardian behaviour seems odd to me. A soldier patrolling an area is unlikely to continue on his route if an enemy was spotted. Likewise, a guardian wouldn't necessarily return to his guard post if there was an intruder nearby. I'm not saying this for the sake of realism, I just think it would be a more useful feature if a patrol or guard starting attacking properly in these situations. I know it'd be possible to remove a micro ai when an enemy is nearby, and then reapply it when the coast is clear - but this seems cumbersome (especially in light of the filtering mentioned above). What are your thoughts on this?
1. Can I ask why these behaviours are filtered on a unit's id rather than with a standard unit filter? The latter would be more intuitive and flexible, but perhaps there's hidden problems in using a SUF that I've not considered. I would like to be able to turn micro ais on and off for several units in one go without having to specify each one individually.
2. The patrol and guardian behaviour seems odd to me. A soldier patrolling an area is unlikely to continue on his route if an enemy was spotted. Likewise, a guardian wouldn't necessarily return to his guard post if there was an intruder nearby. I'm not saying this for the sake of realism, I just think it would be a more useful feature if a patrol or guard starting attacking properly in these situations. I know it'd be possible to remove a micro ai when an enemy is nearby, and then reapply it when the coast is clear - but this seems cumbersome (especially in light of the filtering mentioned above). What are your thoughts on this?
My current projects:
MP pirate campaign: The Altaz Mariners
RPG sequel: Return to Trent
MP stealth campaign: Den of Thieves
MP pirate campaign: The Altaz Mariners
RPG sequel: Return to Trent
MP stealth campaign: Den of Thieves
Re: Micro AIs Feedback and Development
Hi Bob. Thanks for testing the Micro AIs and the feedback.
There is, however, an easy way provided to change this, the ca_score= parameter. I don't know how much you know about how the AI works, but in brief, it consists of a number of candidate actions (CAs) that are executed in order of their scores. The CA with the highest score is evaluated first (and executed if a move is found), and we only go on to lower-score CAs when no moves for this CA can be found any more. You can find the default AI CAs and their scores here. Now, the Micro AIs add one or several new CAs to this, often with scores higher than any of the default CAs (the values are listed for each MAI on the wiki page). However, the score can be adjusted for each MAI using the ca_score= parameter. If you want a unit to attack if possible, and only do its MAI move if not, simply set the ca_score= key to a value lower than the combat CA.
Sorry for all the technical detail, I always get carried away with that. To sum this up, if you set ca_score=90000 for an MAI, the affected unit(s) will attack first (combat CA score is 100,000), and only do the MAI behavior if no attack target is available to them.
Hope this helps (and makes some sense at least). Let me know if that works for you, or if it is still not what you are looking for.
I assume that you are talking about the MAIs that attach directly to a unit since most of the others already use SUFs? The main reason for this is that they need to be created individually for each unit (as opposed to a side-wide AI which only is set up once per side), have unique candidate action identifiers etc. But if I remember correctly, there's no reason why this could not be handled inside the MAI code, looping over all units that match the filter. I will look into it. I'll probably keep the id= key as an option though (use SUF if present, otherwise id= must be set, or something) so as to not break backwards compatibility.Bob_The_Mighty wrote:1. Can I ask why these behaviours are filtered on a unit's id rather than with a standard unit filter? The latter would be more intuitive and flexible, but perhaps there's hidden problems in using a SUF that I've not considered. I would like to be able to turn micro ais on and off for several units in one go without having to specify each one individually.
Well, when we first created the guardians (at least some of them) we specifically wanted this behavior, in contrast to the ai_special=guardian option, which is pretty much what you describe. We wanted units that cannot be lured away too far from the guard station. So I believe we could argue it either way which one should be the default.Bob_The_Mighty wrote:2. The patrol and guardian behaviour seems odd to me. A soldier patrolling an area is unlikely to continue on his route if an enemy was spotted. Likewise, a guardian wouldn't necessarily return to his guard post if there was an intruder nearby. I'm not saying this for the sake of realism, I just think it would be a more useful feature if a patrol or guard starting attacking properly in these situations. I know it'd be possible to remove a micro ai when an enemy is nearby, and then reapply it when the coast is clear - but this seems cumbersome (especially in light of the filtering mentioned above). What are your thoughts on this?
There is, however, an easy way provided to change this, the ca_score= parameter. I don't know how much you know about how the AI works, but in brief, it consists of a number of candidate actions (CAs) that are executed in order of their scores. The CA with the highest score is evaluated first (and executed if a move is found), and we only go on to lower-score CAs when no moves for this CA can be found any more. You can find the default AI CAs and their scores here. Now, the Micro AIs add one or several new CAs to this, often with scores higher than any of the default CAs (the values are listed for each MAI on the wiki page). However, the score can be adjusted for each MAI using the ca_score= parameter. If you want a unit to attack if possible, and only do its MAI move if not, simply set the ca_score= key to a value lower than the combat CA.
Sorry for all the technical detail, I always get carried away with that. To sum this up, if you set ca_score=90000 for an MAI, the affected unit(s) will attack first (combat CA score is 100,000), and only do the MAI behavior if no attack target is available to them.
Hope this helps (and makes some sense at least). Let me know if that works for you, or if it is still not what you are looking for.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Micro AIs Feedback and Development
Well, I coded this but have not committed it yet because, while putting together the wiki description, I noticed that we might have been talking about somewhat different things. Below is the current wiki entry for the Patrol MAI. Check out in particular the second note explaining when the filter is applied. My guess is that that is not what you had in mind, and it is also somewhat different from how filters work in the other MAIs.mattsc wrote:But if I remember correctly, there's no reason why this could not be handled inside the MAI code, looping over all units that match the filter. I will look into it. I'll probably keep the id= key as an option though (use SUF if present, otherwise id= must be set, or something) so as to not break backwards compatibility.
Please let me know what you think about this. I can change it so that the filter is applied at the time of each AI move, but it requires that I change these AIs to use side-wide candidate actions (CAs) rather than sticky behavior CAs. It's a bit of work, but for consistency it should probably be done.
Of course, if you have comments on the other notes, please let me know as well.
Edit: Some of this has been changed now. See also the following post.
Current method how [filter] works for patrols, guardians, etc. [s]Should probably be changed.[/s]
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Micro AIs Feedback and Development
Update on the Patrol, Guardian and Hunter Micro AIs:
These AIs have been converted to side-wide AIs and now support either the [filter] tag or the id=key for unit selection (one or the other is required, and [filter] takes priority over id= if both are given).
The [filter] tag works as it does everywhere else in the Micro AIs and Wesnoth in general: it is evaluated at the time of the move, not at the time when the [micro_ai] tag is processed.
Other than that, the other notes given in the previous post still apply.
These AIs have been converted to side-wide AIs and now support either the [filter] tag or the id=key for unit selection (one or the other is required, and [filter] takes priority over id= if both are given).
The [filter] tag works as it does everywhere else in the Micro AIs and Wesnoth in general: it is evaluated at the time of the move, not at the time when the [micro_ai] tag is processed.
Other than that, the other notes given in the previous post still apply.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Micro AIs Feedback and Development
Hi mattsc,
Thank you for working on these AI actions. They make not only players but also creators have fun.
They are really nice attempts.
I have been installing and test-running a couple kind of them on 1.11.7. Then a question came out.
I installed this code on two scenarios:
In this code, Giant Rats are supposed to attack side=2 units, aren't they? The Rats actually don't attack both side=1 and side=2 units (of course they are all different "team_name", and the code has been installed in [event] tags).
Could you tell me that it is a bug or the way it is (or I missed something)? First, I thought the Rats didn't attack because the enemies were higher levels, but the same thing occurs even the units are level=1, that are the same level as the enemies, on another scenario.
If it is the way that is supposed to be, not a problem at all. I am just curious a bit...
thanks
Thank you for working on these AI actions. They make not only players but also creators have fun.
They are really nice attempts.
I have been installing and test-running a couple kind of them on 1.11.7. Then a question came out.
I installed this code on two scenarios:
Code: Select all
[micro_ai]
side=3
ai_type=wolves
action=add
[filter]
type=Giant Rat # tried side=3 here, and the same result
[/filter]
[filter_second]
side=2
[/filter_second]
[/micro_ai]
Could you tell me that it is a bug or the way it is (or I missed something)? First, I thought the Rats didn't attack because the enemies were higher levels, but the same thing occurs even the units are level=1, that are the same level as the enemies, on another scenario.
If it is the way that is supposed to be, not a problem at all. I am just curious a bit...
thanks
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Re: Micro AIs Feedback and Development
Hi SkyOne,
Thanks much for the feedback. The code you have posted and your interpretation of what should be happening look correct to me, so I'm not certain what exactly is going on but here's my guess: The attacks of the Wolves Micro AI are left to the default (RCA) AI, the Micro AI code only takes care of moving the rats toward the "prey" while out of attack range. So maybe the RCA AI considers attacks not worth the risk and doesn't do them? You could check this by replacing rats by a stronger unit type just for the sake of testing whether that's what's going on.
If that is the cause, you should be able to make the rats attack by setting aggression=1.0 for the AI side (see note below though). If that doesn't do it, could you post your scenario code and I will have a look. You should definitely be able to make the rats attack. If you can't, that's a bug that needs to be fixed.
Thanks again.
Note: You should check with :inspect that the change of the aggression value really took effect. There's a feature/bug (depending on one's point of view) that means that AI parameters do not always get set using the [side][ai] tag when Lua AI code is present. In 1.11.7 that should not affect the Micro AIs any more, but that has not been tested widely yet.
Thanks much for the feedback. The code you have posted and your interpretation of what should be happening look correct to me, so I'm not certain what exactly is going on but here's my guess: The attacks of the Wolves Micro AI are left to the default (RCA) AI, the Micro AI code only takes care of moving the rats toward the "prey" while out of attack range. So maybe the RCA AI considers attacks not worth the risk and doesn't do them? You could check this by replacing rats by a stronger unit type just for the sake of testing whether that's what's going on.
If that is the cause, you should be able to make the rats attack by setting aggression=1.0 for the AI side (see note below though). If that doesn't do it, could you post your scenario code and I will have a look. You should definitely be able to make the rats attack. If you can't, that's a bug that needs to be fixed.
Thanks again.
Note: You should check with :inspect that the change of the aggression value really took effect. There's a feature/bug (depending on one's point of view) that means that AI parameters do not always get set using the [side][ai] tag when Lua AI code is present. In 1.11.7 that should not affect the Micro AIs any more, but that has not been tested widely yet.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Micro AIs Feedback and Development
Thanks for answering quickly.
It looks like a bug.
I have changed the Giant Rats to Yetis for testing, but the results is the same. The difference is just enemies (Wolf Riders) don't attack Yetis. So adding aggression=1.0 in their [ai] tag doesn't perform differently on either Giant Rats and Yetis units (tried already just to make sure).
It looks like a bug.
I have changed the Giant Rats to Yetis for testing, but the results is the same. The difference is just enemies (Wolf Riders) don't attack Yetis. So adding aggression=1.0 in their [ai] tag doesn't perform differently on either Giant Rats and Yetis units (tried already just to make sure).
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Re: Micro AIs Feedback and Development
Hmm... I just copied your code into the "Animals" test scenario and it works just fine. (I just wanted to see whether there's a problem with using the side= key inside [filter_second] of the Micro AI. There isn't.) So at this point I cannot say what's going on without testing your actual scenario. As I said, the attacks themselves are not controlled by the Micro AI, so I am wondering if there's something else going on.
Update: Thanks for sending me the scenario file, SkyOne. This is indeed a bug in the wolves MAI. It only happens when the avoid_type key is not set, which is why it doesn't occur in the "Animals" test scenario. And I missed it when I tested it with your code because of the way how I did the test. Anyways, it is fixed in trunk now and should work again in 1.11.8. Thanks for reporting this!
Update: Thanks for sending me the scenario file, SkyOne. This is indeed a bug in the wolves MAI. It only happens when the avoid_type key is not set, which is why it doesn't occur in the "Animals" test scenario. And I missed it when I tested it with your code because of the way how I did the test. Anyways, it is fixed in trunk now and should work again in 1.11.8. Thanks for reporting this!
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Micro AIs Feedback and Development
Update for Wesnoth 1.11.10:
Quite some time ago I had realized that some Micro AIs might cause OOS errors under certain circumstances, but until this week I had not had time to look into this systematically. I have now done so and found two problems:
On a related topic, the MAIs also need to be consistent across save/load cycles. For example, if a patrol unit follows a route of several waypoints, it still needs to head toward the next waypoint after reloading, and not head back to the first. I checked out the MAIs for this too and found no problems with the MAIs themselves. This did however reveal two other problems:
Quite some time ago I had realized that some Micro AIs might cause OOS errors under certain circumstances, but until this week I had not had time to look into this systematically. I have now done so and found two problems:
- One was with the rabbit-type animals in the Forest Animals MAI.
- The second, unfortunately, was in one of the ai_helper functions and thus affected probably about half of the MAIs (although not necessarily always but only under certain circumstances).
On a related topic, the MAIs also need to be consistent across save/load cycles. For example, if a patrol unit follows a route of several waypoints, it still needs to head toward the next waypoint after reloading, and not head back to the first. I checked out the MAIs for this too and found no problems with the MAIs themselves. This did however reveal two other problems:
- There was a problem in the Simple Attack test scenario (the scenario code, not the AI) causing lots of Lua errors to appear after a reload. This is fixed.
- It appears that deleting and changing a Micro AI after reloading a game is not possible (it does work if one starts the scenario from the beginning). This is, however, caused by a general problem in the Wesnoth candidate-action handling code and not specific to the MAIs. So this is not yet fixed, but Crab and I are looking into it and will hopefully have that sorted out soon.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Micro AIs Feedback and Development
Update for Wesnoth 1.11.12:
With this, I am not aware of any bugs in the Micro AIs any more -- but I am sure that there are still some that I haven't found yet, so please keep reporting.
-------
Note: For all I can tell, this bug has been around since the introduction of the RCA AI in Wesnoth 1.7.3 and is not restricted to Micro AIs. So if you have previously had trouble with deleting/modifying candidate actions, it might work now.
This was indeed caused by a problem with the RCA AI itself and is now fixed. Unfortunately, it requires a change to the C++ code, albeit a very small one, so there are no work-arounds for this before 1.11.12 comes out.mattsc wrote:[*]It appears that deleting and changing a Micro AI after reloading a game is not possible (it does work if one starts the scenario from the beginning). This is, however, caused by a general problem in the Wesnoth candidate-action handling code and not specific to the MAIs. So this is not yet fixed, but Crab and I are looking into it and will hopefully have that sorted out soon.
With this, I am not aware of any bugs in the Micro AIs any more -- but I am sure that there are still some that I haven't found yet, so please keep reporting.
-------
Note: For all I can tell, this bug has been around since the introduction of the RCA AI in Wesnoth 1.7.3 and is not restricted to Micro AIs. So if you have previously had trouble with deleting/modifying candidate actions, it might work now.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
- Lord-Knightmare
- Discord Moderator
- Posts: 2376
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Micro AIs Feedback and Development
Hello, I followed the instructions on the Micro AI wiki page and have managed to implement the Fast Micro AI in my campaign. However, it is not working like it is supposed to and I got this error message:
Is there anyway to fix this?Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Micro AIs Feedback and Development
Fast MAI is BfW 1.13.0 + only. (MAI have been developed fast. )Lord-Knightmare wrote:Hello, I followed the instructions on the Micro AI wiki page and have managed to implement the Fast Micro AI in my campaign. However, it is not working like it is supposed to and I got this error message:Is there anyway to fix this?
Did you download the files and installed them as well into your campaign?
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
- Lord-Knightmare
- Discord Moderator
- Posts: 2376
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Micro AIs Feedback and Development
Yeah, I have followed the instructions as specified. The game loads with no error messages. However, when the AI starts a turn, the aforementioned message pops-up 4 to 5 times.SkyOne wrote:Fast MAI is BfW 1.13.0 + only. (MAI have been developed fast. )Lord-Knightmare wrote:Hello, I followed the instructions on the Micro AI wiki page and have managed to implement the Fast Micro AI in my campaign. However, it is not working like it is supposed to and I got this error message:Is there anyway to fix this?
Did you download the files and installed them as well into your campaign?
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Micro AIs Feedback and Development
Yeah, errors in Lua AIs do not keep the game from loading, they only show up during the AI turn.Lord-Knightmare wrote:The game loads with no error messages.
That error message means that you are trying to load a file that does not exist (in line 1 of whatever file that is; unfortunately the file name is truncated, maybe you can get the full one from stdout). So it looks like you missed adjusting one of the paths in step 4 of the instructions.Lord-Knightmare wrote:However, when the AI starts a turn, the aforementioned message pops-up 4 to 5 times.
That's really all I can say just from that error messages by itself. If you want, you can PM me the relevant files and I'll have a look.
As for your question on IRC, no, the [micro_ai] tag does not take a list of sides, you need to specify one for each side.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on