Exercises in Formula and Lua AI and AI-demos add-on feedback
Moderator: Forum Moderators
Re: Exercises in Formula and Lua AI
So here is the first of a series of test cases, meant to correspond to the list of Fred's weaknesses.
Today is a test case for:
Since that replay used an old version of Fred that does not have the CA debugging code included, you can't simply load that game to do CA debugging, you must instead painstakingly re-create the scene using a modern version of Fred. That is what I have done in about an hour of monkeying with debug mode. Hopefully future test cases will go easier!
Are we happy with Modern Fred's response to this test case? Old Fred failed to reclaim either of the two villages that blue currently holds, despite having 3 units in range to do that (including 2 grunts). Instead Old Fred moved all of the units on the western front as far east as possible, presumably to prepare to deal with threats to his leader, but I'm not really sure why. Fred had better take those villages back this turn! UPDATE: I used the CA debugger to step Fred through this turn, and he reclaims the two villages, but does not keep a unit in the forward village on 11,9 that the enemy archer is threatening to grab. So this behavior may be acceptable, but I think Fred might be able to do better? The problem is that Fred moves the wolf and grunt that are in front first, and the rear grunt cannot reach the forward village, so he just stays where he is instead of taking the forward village and meleeing the archer.
UPDATE: I posted the wrong file initially, the correct version is there now.
UPDATE 2: We made some changes to the CA debugger, so the old savegame will no longer work in the current Github version of Fred, so I have uploaded a new version that mattsc has fixed. Of course, this new savegame will not work in the currently released version of Fred, so I won't delete the old one yet.
Today is a test case for:
It is meant to be a re-creation of turn 10 from this replay of Ron murdering Fred in an orc mirror.(A) Defending and retaking/reclaiming the NW villages. Fred frequently allows the enemy to steal/take his NW villages, and then has lots of trouble making a concerted effort to clear them. Even once he has killed the units holding his NW villages, he often fails to reclaim them, allowing the enemy to keep their income.
Since that replay used an old version of Fred that does not have the CA debugging code included, you can't simply load that game to do CA debugging, you must instead painstakingly re-create the scene using a modern version of Fred. That is what I have done in about an hour of monkeying with debug mode. Hopefully future test cases will go easier!
Are we happy with Modern Fred's response to this test case? Old Fred failed to reclaim either of the two villages that blue currently holds, despite having 3 units in range to do that (including 2 grunts). Instead Old Fred moved all of the units on the western front as far east as possible, presumably to prepare to deal with threats to his leader, but I'm not really sure why. Fred had better take those villages back this turn! UPDATE: I used the CA debugger to step Fred through this turn, and he reclaims the two villages, but does not keep a unit in the forward village on 11,9 that the enemy archer is threatening to grab. So this behavior may be acceptable, but I think Fred might be able to do better? The problem is that Fred moves the wolf and grunt that are in front first, and the rear grunt cannot reach the forward village, so he just stays where he is instead of taking the forward village and meleeing the archer.
UPDATE: I posted the wrong file initially, the correct version is there now.
UPDATE 2: We made some changes to the CA debugger, so the old savegame will no longer work in the current Github version of Fred, so I have uploaded a new version that mattsc has fixed. Of course, this new savegame will not work in the currently released version of Fred, so I won't delete the old one yet.
- Attachments
-
- 2p_—_The_Freelands_Turn_10_Test_A_take_4_fixed.gz
- This fixed savegame will work for CA Debugging in the current Github version of Fred, but right now will not work in the officially released version.
- (25.17 KiB) Downloaded 501 times
-
- 2p_—_The_Freelands_Turn_10_Test_A_take_4.gz
- My 4th attempt at uploading, this time the AI even has the correct gold amount :P I didn't take into account that when CA debugging you don't get income from villages at the beginning of your turn.
- (24.99 KiB) Downloaded 516 times
Re: Exercises in Formula and Lua AI
We just released AI-Demos v0.11.2 for Wesnoth 1.10 and v0.11.3 for Wesnoth 1.11 on the respective add-ons servers.
Note: As of v0.11.2, development of AI-Demos has been discontinued for Wesnoth 1.10. The reason is that it is becoming increasingly obvious that the next steps in improving the grunt rushes (and some of the other AIs) will be much easier with the new capabilities of 1.11; and in some cases, in fact, impossible in 1.10. To get the most up-to-date version, please use Wesnoth 1.11 from now on. We understand that this might be somewhat inconvenient for some of you at this time, sorry for that, but in the long run it will lead to better AIs. We will make sure that we will use capabilities of released versions of 1.11 only (currently that means 1.11.0), so it should never be necessary to compile the latest trunk version.
As for the current version, the refactoring of the Freelands Grunt Rush AI is completed. Fred now acts on a zone-by-zone rather than on a map-wide basis, which is much more adaptable both for the Freelands map and for eventual generalization. There might not (yet) be huge improvements to Fred's behavior, but on average he should at least not play worse than before.
Ron has seen some more improvements to the recruitment algorithm and is currently being tested against (and is standing up very well to) SeattleDad's ML recruiter. We are also talking about combining the two to see how that works out. All this is still work in progress.
Note: As of v0.11.2, development of AI-Demos has been discontinued for Wesnoth 1.10. The reason is that it is becoming increasingly obvious that the next steps in improving the grunt rushes (and some of the other AIs) will be much easier with the new capabilities of 1.11; and in some cases, in fact, impossible in 1.10. To get the most up-to-date version, please use Wesnoth 1.11 from now on. We understand that this might be somewhat inconvenient for some of you at this time, sorry for that, but in the long run it will lead to better AIs. We will make sure that we will use capabilities of released versions of 1.11 only (currently that means 1.11.0), so it should never be necessary to compile the latest trunk version.
As for the current version, the refactoring of the Freelands Grunt Rush AI is completed. Fred now acts on a zone-by-zone rather than on a map-wide basis, which is much more adaptable both for the Freelands map and for eventual generalization. There might not (yet) be huge improvements to Fred's behavior, but on average he should at least not play worse than before.
Ron has seen some more improvements to the recruitment algorithm and is currently being tested against (and is standing up very well to) SeattleDad's ML recruiter. We are also talking about combining the two to see how that works out. All this is still work in progress.
Changelog v0.11.2 and v0.11.3
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
-
- Posts: 2
- Joined: May 7th, 2012, 2:13 am
Re: Exercises in Formula and Lua AI
Found a couple of quirks. (Wesnoth 1.11.0)
Bottleneck Defense: (AI vs. AI) The human AI sometimes tells its Bowmen to attack the Orcish Grunts in melee. Also, the Orc AI stopped moving at one point, despite having an extra four archers to attack with. As another note, both AIs eventually stop moving. That's bad, because their turns become less than a second long.
Prune Cart: (AI vs. AI, Stationary) The Orc AI frequently attacks skeletons with normal arrows, despite obviously doing more damage with fire arrows. This isn't just on low-health skeletons. The Orc AI still uses fire arrows with counterattacks.
HttT: The Elves Besieged: (Default settings) Konrad's AI agressively attacks the upper-right Orc army with everyone but Konrad and Delfador. Then, when the upper-left Orc army got nearby, Konrad and Delfador slowed down until the elves killed them all. Konrad's army should attack the Orcs in his way, instead.
Other than that, it's good to see that an AI can do something aside from charge and die.
Bottleneck Defense: (AI vs. AI) The human AI sometimes tells its Bowmen to attack the Orcish Grunts in melee. Also, the Orc AI stopped moving at one point, despite having an extra four archers to attack with. As another note, both AIs eventually stop moving. That's bad, because their turns become less than a second long.
Prune Cart: (AI vs. AI, Stationary) The Orc AI frequently attacks skeletons with normal arrows, despite obviously doing more damage with fire arrows. This isn't just on low-health skeletons. The Orc AI still uses fire arrows with counterattacks.
HttT: The Elves Besieged: (Default settings) Konrad's AI agressively attacks the upper-right Orc army with everyone but Konrad and Delfador. Then, when the upper-left Orc army got nearby, Konrad and Delfador slowed down until the elves killed them all. Konrad's army should attack the Orcs in his way, instead.
Other than that, it's good to see that an AI can do something aside from charge and die.
Re: Exercises in Formula and Lua AI
Chaos_Farseer: Thanks much for the feedback! In all the scenarios where you witnessed incorrect weapon choices, you unfortunately found a bug that we had also found (and fixed) recently. We just released v0.11.5 which includes that bug fix, so if you want to go back to those scenarios, you will hopefully see more sensible behavior.
The AIs not moving any more at the end of Bottleneck Defense is not really a bug. It is caused by the orc side, played by the (unmodified) RCA AI, not attacking because it is deemed too dangerous. The pass defenders do exactly what they should in that case: hold the pass and wait. But it's still very frustrating to watch, so we increased the aggressiveness of the RCA AI, which will hopefully prevent a situation like this from happening in the future.
As for the HttT you observed, I've never quite seen it like that. You wouldn't happen to have a replay left from that that you could post here?
Again, thanks much for the comments!
--------------------------
We just released v0.11.5 in order to fix the bug reported by Chaos_Farseer. It contains many changes to both Ron and Fred (see complete changelog below). Unfortunately, it turns out that the changes needed to make Fred play better are more extensive than anticipated. So Fred's behavior is probably about as before, maybe a little better in some detail and a little worse in another. Hopefully we will have this ironed out by the next release...
The AIs not moving any more at the end of Bottleneck Defense is not really a bug. It is caused by the orc side, played by the (unmodified) RCA AI, not attacking because it is deemed too dangerous. The pass defenders do exactly what they should in that case: hold the pass and wait. But it's still very frustrating to watch, so we increased the aggressiveness of the RCA AI, which will hopefully prevent a situation like this from happening in the future.
As for the HttT you observed, I've never quite seen it like that. You wouldn't happen to have a replay left from that that you could post here?
Again, thanks much for the comments!
--------------------------
We just released v0.11.5 in order to fix the bug reported by Chaos_Farseer. It contains many changes to both Ron and Fred (see complete changelog below). Unfortunately, it turns out that the changes needed to make Fred play better are more extensive than anticipated. So Fred's behavior is probably about as before, maybe a little better in some detail and a little worse in another. Hopefully we will have this ironed out by the next release...
v0.11.5 Changelog
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
- Alarantalara
- Art Contributor
- Posts: 786
- Joined: April 23rd, 2010, 8:17 pm
- Location: Canada
Re: Exercises in Formula and Lua AI
Fred's first victory as Undead.
- Attachments
-
- 2p_—_The_Freelands_replay.gz
- (24.84 KiB) Downloaded 530 times
Re: Exercises in Formula and Lua AI
AI-Demos v0.12.0 is out with lots of exciting news and additions (well, if you find things like this exciting, that is):
- SeattleDad's Machine Learning Recruiter and test tools are now part of AI-Demos. This is the main reason why we went to v0.12.
- As Alarantalara hinted on in his post, Fred can now play any faction; although he's still optimized for chaotic factions (meaning that the attack/retreat cycle is horribly wrong for lawful factions; that's next on the list to change)
- Ron has seen significant improvements, in particular to recruiting, which now results in an 86% win percentage against the RCA AI across all factions and all maps. As a result, Ron is now in mainline. Right now, you'd still have to compile trunk to make use of that, but he'll be a default part of Wesnoth starting from Wesnoth 1.11.1.
- Fred has seen lots of improvements. He still makes too many stupid mistakes, but, as Northerners, has an average win percentage around 80% against Ron on Freelands. [We've changed both Ron and Fred since the last patch tests, so the exact current win percentage might be slightly different, but Fred clearly wins much more often than he loses to Ron these days.]
- Not directly related to AI-Demos, we've also put in a patch that removes the 'testing' label from the RCA AI and declares it the default AI.
v0.12.0 changelog
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: Exercises in Formula and Lua AI
Fred's first victory as Loyalists vs. Ron playing Northerners.
Fred's still making plenty of silly mistakes, but he can now play any faction and even win against Ron's strongest faction (not sure of the win % yet). Still restricted to Side 1 on Freelands though. (Note: this is the current development version on github, not v0.12.0)
Fred's still making plenty of silly mistakes, but he can now play any faction and even win against Ron's strongest faction (not sure of the win % yet). Still restricted to Side 1 on Freelands though. (Note: this is the current development version on github, not v0.12.0)
- Attachments
-
- 2p_—_The_Freelands_replay_Fred-Loyalists_Ron-Northerners.gz
- Fred now knows how to play lawful factions
- (38.35 KiB) Downloaded 604 times
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: Exercises in Formula and Lua AI
Thanks Mattsc for expanding on the AI, pretty cool stuff happening here. This is probably in the wrong place, but I thought of a method that may help to control AI a bit- only in theory of course It would involve weightpainting maps and using those weighted maps to do things like make AI avoid certain areas, protect certain areas, or follow specific routes. You could have multiple weight maps in one scenario map that control different groups/types of units, or random placement of units, or even things like aggression. I wonder how well that would work, or how useful it would be.
Re: Exercises in Formula and Lua AI
this is not at all wrong and only in theory: how else do you think Fred managed to be able to hold the west whileattackign the east? its the previous knowledge that you should not lose village X and you should be careful about tod while in area Z.
btw, this replay looks like a mediocre player was beating the AI thoroughly. could you please upload this good stuff on the addon server so its easier to have the correct version? im looking forward to playing under harder circumstances again
btw, this replay looks like a mediocre player was beating the AI thoroughly. could you please upload this good stuff on the addon server so its easier to have the correct version? im looking forward to playing under harder circumstances again
Re: Exercises in Formula and Lua AI
Crow_T: Thanks. As for maps, the different AIs use all kinds of maps. There are sub-maps that simply split up the scenario maps into sections, such as what's happening on Freelands (as Rigor describes). Then there are maps that do ratings based on terrain, own and enemy strength, distance from something, etc. Some of them are pre-defined, some of them the AIs figure out themselves. Ideally, we'll eventually have an AI that can figure it out all by itself to some extent, but where the scenario designer has the option of adding pre-defined maps in order to improve play on a certain map. So I think that (some of) this is along the lines of what you are thinking. If you have more concrete ideas, by all means, please let us know.
Btw, AI-Demos is by far not just my work any more. There are lots of people contributing by now.
Rigor: well, the reason why I hadn't uploaded the new version yet is because that replay was kind of a lucky game. It was the second I tried (Fred lost the first). After that, going through some more games, it's pretty obvious that Fred's still making too many embarrassing mistakes. I started to work on that, but then the Google Code-in (GCI) project started on Monday and I've spent all my available time on that (converting AIs to Micro AIs that, hopefully, will make an appearance in mainline pretty soon). So Fred's still not quite where I'd like him to be ...
However, I know that you've been waiting for us to make these AIs play other factions for a long time -- we do listen to you (and others), it's just been very slow progress for some time. So I just uploaded v0.12.1 with the current "state of the art". Just remember that parts of Fred are still in a state of disarray (he puts units into too vulnerable positions, moves one hex off villages, that kind of stuff). Once GCI calms down, I'll get back to that.
Thanks for sticking with us in spite of all that.
Btw, AI-Demos is by far not just my work any more. There are lots of people contributing by now.
Rigor: well, the reason why I hadn't uploaded the new version yet is because that replay was kind of a lucky game. It was the second I tried (Fred lost the first). After that, going through some more games, it's pretty obvious that Fred's still making too many embarrassing mistakes. I started to work on that, but then the Google Code-in (GCI) project started on Monday and I've spent all my available time on that (converting AIs to Micro AIs that, hopefully, will make an appearance in mainline pretty soon). So Fred's still not quite where I'd like him to be ...
However, I know that you've been waiting for us to make these AIs play other factions for a long time -- we do listen to you (and others), it's just been very slow progress for some time. So I just uploaded v0.12.1 with the current "state of the art". Just remember that parts of Fred are still in a state of disarray (he puts units into too vulnerable positions, moves one hex off villages, that kind of stuff). Once GCI calms down, I'll get back to that.
Thanks for sticking with us in spite of all that.
v0.12.1 changelog
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: Exercises in Formula and Lua AI
mattsc, just worked my way through the whole thread and want to thank you for starting a real push to improve the Wesnoth AI even more. I don't play with humans only AI and I haven't lost a MP game to an AI yet, I always welcome developments in this space. What you're doing here is very exciting
Which version of Ron is being used in 1.11.1? 0.12.0?
Anyway, a few things:
1. On The Clash the version of Ron in 1.11.1 will not capture villages with his leader on the first turn, rather he moves towards the castle above/below him.
2. I'm sometimes getting the following error using AI-Demo 0.12.1:
stack traceback:
...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:540: in function 'find_best_recruit'
...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:408: in function 'recruit_rushers_exec'
[string "(...):recruit_rushers_exec()"]:1: in main chunk
20121228 03:37:35 error scripting/lua: ...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:540: attempt to index local 'efficiency' (a nil value)
I'm trying to track down the conditions which cause this. Once the error happens it occurs each turn thereafter.
Which version of Ron is being used in 1.11.1? 0.12.0?
Anyway, a few things:
1. On The Clash the version of Ron in 1.11.1 will not capture villages with his leader on the first turn, rather he moves towards the castle above/below him.
2. I'm sometimes getting the following error using AI-Demo 0.12.1:
stack traceback:
...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:540: in function 'find_best_recruit'
...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:408: in function 'recruit_rushers_exec'
[string "(...):recruit_rushers_exec()"]:1: in main chunk
20121228 03:37:35 error scripting/lua: ...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:540: attempt to index local 'efficiency' (a nil value)
I'm trying to track down the conditions which cause this. Once the error happens it occurs each turn thereafter.
- Alarantalara
- Art Contributor
- Posts: 786
- Joined: April 23rd, 2010, 8:17 pm
- Location: Canada
Re: Exercises in Formula and Lua AI
Approximately. There may be minor differences though, since the releases are not at exactly the same time.Quitch wrote:mattsc, just worked my way through the whole thread and want to thank you for starting a real push to improve the Wesnoth AI even more. I don't play with humans only AI and I haven't lost a MP game to an AI yet, I always welcome developments in this space. What you're doing here is very exciting :)
Which version of Ron is being used in 1.11.1? 0.12.0?
Indeed. Most of the effort with leader movement has been spent dealing with multiple keeps on 2-player maps. Most testing on 4 player maps has been done on maps where the keeps of the players are well separated (Castle Hopping Isle, Siege Castles). I'll work on fixing this. Most of it is that the leader looks for new keeps even when the present one is a good option. This is good for maps like castle hopping isle, where you might otherwise run out of room to recruit, but it doesn't work nearly as well when the other castle is the ally's and there is plenty of space in the current castle.Anyway, a few things:
1. On The Clash the version of Ron in 1.11.1 will not capture villages with his leader on the first turn, rather he moves towards the castle above/below him.
This shouldn't be a problem any more — the code associated with it was replaced about 5 days after the last release to fix a problem that looked much like what you describe.2. I'm sometimes getting the following error using AI-Demo 0.12.1:
stack traceback:
...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:540: in function 'find_best_recruit'
...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:408: in function 'recruit_rushers_exec'
[string "(...):recruit_rushers_exec()"]:1: in main chunk
20121228 03:37:35 error scripting/lua: ...ata/data/add-ons/AI-demos/lua/generic-recruit_engine.lua:540: attempt to index local 'efficiency' (a nil value)
I'm trying to track down the conditions which cause this. Once the error happens it occurs each turn thereafter.
Re: Exercises in Formula and Lua AI
I assume you mean not a problem any more in the current github version, rather than the addons copy, right?
Also thanks to you, and all the others, working on this as well. People like me greatly appreciate your efforts
Also thanks to you, and all the others, working on this as well. People like me greatly appreciate your efforts
Re: Exercises in Formula and Lua AI
Quitch: Thank you very much for the comments, that's great to hear.
The biggest change this time is that, thanks to the work of the Google Code-in students, there are now 18 AIs available as Micro AIs, most of them with lots of configuration parameters so that they can be applied in a wide range of situations. These MAIs are almost ready for mainlining and should appear in Wesnoth trunk shortly.
There have also been lots of improvements made to the generic rush AI (Ron) and in particular to the rush recruiter (used by Ron, Fred, and the mainline Experimental AI). Unfortunately, Fred's seen no other progress due to the Micro AI work.
That's what it did mean, but not any more. Alarantalara fixed the issue with The Clash as well, so: We just released AI-Demos v0.12.2Quitch wrote:I assume you mean not a problem any more in the current github version, rather than the addons copy, right?
The biggest change this time is that, thanks to the work of the Google Code-in students, there are now 18 AIs available as Micro AIs, most of them with lots of configuration parameters so that they can be applied in a wide range of situations. These MAIs are almost ready for mainlining and should appear in Wesnoth trunk shortly.
There have also been lots of improvements made to the generic rush AI (Ron) and in particular to the rush recruiter (used by Ron, Fred, and the mainline Experimental AI). Unfortunately, Fred's seen no other progress due to the Micro AI work.
Complete changelog v0.12.2
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: Exercises in Formula and Lua AI
That's great news, I'll be sure to give it a whirl. I must admit, while I understand the purpose of Fred, improvements in Ron are much more exciting since I perceive him as the end-goal.
Incidentally, I don't know if this is on the goal list (didn't see it in the topic earlier), but a long-term goal would be smarter teamwork. Does the AI currently account for allied units when forming battlelines, etc.?
Incidentally, I don't know if this is on the goal list (didn't see it in the topic earlier), but a long-term goal would be smarter teamwork. Does the AI currently account for allied units when forming battlelines, etc.?