Exercises in Formula and Lua AI and AI-demos add-on feedback
Moderator: Forum Moderators
Re: Exercises in Formula and Lua AI
Just so you don't get discouraged, here's one where Fred defeats RCA drakes with 150 +2 gold. Mostly it is because Fred succeeds in stealing all of the eastern villages, negating all of his other mistakes, as well as some nice luck.
8. Center: Trapping the burner is good, but leaving the village next to him empty is a TERRIBLE MISTAKE! Putting even an injured unit in that village would be better.
8. Center: Trapping the burner is good, but leaving the village next to him empty is a TERRIBLE MISTAKE! Putting even an injured unit in that village would be better.
Re: Exercises in Formula and Lua AI
oh my! well, nelson, seems you are a good story teller, thats good . but you know whats better - if you could cut yourself short and transform the fred does this and fred does that (which are observations) into fred "code" which could look like this or like that in order to deal with ....the things you just described!!! i try to think like the machine which receives these bits of information to form a powerful engine that can deal with smartass players like you and me but be aware that some of your suggestions are on a level far above the ais orders such as:
"if the fencer wants to move...then you should block the good terrain" how should the ai know what you want to do?
"Fred should..." why should he, whats the trigger, whats the reason, how to tell?
"either attack or heal..." when to attack, when to heal, try to find a generally good approach todo this or that, use examples and think of the general usability.
"focus fire" that might be a good idea in one situation and a very bad one in another. example: good use during night, bad use during day: you could deliver unspecific damage with assassins and archers to a lot of units, while focus fire would make all the assassins and archers go for just one unit. see what i mean? perhaps make it tod dependent, in which case you again need additional parameters to work rather good.
"should have taken the risk" oh yeah? and why should he have done that? is fred losing, how to tell? is there some mathematical equation you can think of that would help making the all or nothing decision to risk attacking a leader in a bad game?
"terribe mistakes" hopefully only one or not more than 2 terrible mistakes that decide the game happen in one, those might be good points to start from to reshape the AI.
so, once again, battle reports will have the value they deserve when the testing players have an extremely interesting kind of behaviour that can possibly be changed with just a few lines of code.
focus on those rare (?) events - post screens if you can, and describe how you propose to change this weird behaviour into good behaviour. ok?
machine tactics follow a reasoning. units dont just attack hopelessly because they are silly, they probably have the ulterior motive to kill a threat to the king. however, if you dont know you just see the lousy result. a more helpful approach would be to give the ai directions in which mostly a certain pattern (heal units even though your king is in grave danger) is a good idea. probably in certain cases this will be exactly the opposite of a good idea and then again we all will think "what a truly dumb move."
"if the fencer wants to move...then you should block the good terrain" how should the ai know what you want to do?
"Fred should..." why should he, whats the trigger, whats the reason, how to tell?
"either attack or heal..." when to attack, when to heal, try to find a generally good approach todo this or that, use examples and think of the general usability.
"focus fire" that might be a good idea in one situation and a very bad one in another. example: good use during night, bad use during day: you could deliver unspecific damage with assassins and archers to a lot of units, while focus fire would make all the assassins and archers go for just one unit. see what i mean? perhaps make it tod dependent, in which case you again need additional parameters to work rather good.
"should have taken the risk" oh yeah? and why should he have done that? is fred losing, how to tell? is there some mathematical equation you can think of that would help making the all or nothing decision to risk attacking a leader in a bad game?
"terribe mistakes" hopefully only one or not more than 2 terrible mistakes that decide the game happen in one, those might be good points to start from to reshape the AI.
so, once again, battle reports will have the value they deserve when the testing players have an extremely interesting kind of behaviour that can possibly be changed with just a few lines of code.
focus on those rare (?) events - post screens if you can, and describe how you propose to change this weird behaviour into good behaviour. ok?
machine tactics follow a reasoning. units dont just attack hopelessly because they are silly, they probably have the ulterior motive to kill a threat to the king. however, if you dont know you just see the lousy result. a more helpful approach would be to give the ai directions in which mostly a certain pattern (heal units even though your king is in grave danger) is a good idea. probably in certain cases this will be exactly the opposite of a good idea and then again we all will think "what a truly dumb move."
- Alarantalara
- Art Contributor
- Posts: 786
- Joined: April 23rd, 2010, 8:17 pm
- Location: Canada
Re: Exercises in Formula and Lua AI
Adding a replay of a game where nelson demonstrates how a grunt rush should be done so we have a positive example to work from.
- Attachments
-
- 2p_—_nelson_rush_replay.gz
- (23.63 KiB) Downloaded 334 times
Re: Exercises in Formula and Lua AI
Hey Rigor, I'm aware of the need for more "rigorous" testing/analysis Right now I'm more trying to get an overview of the classes of problems that the AI has, and a feel for what its highest-priority mistakes are. I just had a long discussion in IRC (#wesnoth-umc-dev) with mattsc about specific test cases and how Fred should deal with a few precise situations, and we will have more of those as we move forward. I welcome more posts like your last one, that was very helpful!
- Alarantalara
- Art Contributor
- Posts: 786
- Joined: April 23rd, 2010, 8:17 pm
- Location: Canada
Re: Exercises in Formula and Lua AI
Rigor (or anyone else who cares to answer), if you didn't need scouts, what are the reasons you might buy Wolf Riders early in the game?
Edit: Added two games vs drakes which prompted the question.
Edit: Added two games vs drakes which prompted the question.
- Attachments
-
- 2p_—_drakes_2_replay.gz
- (20.53 KiB) Downloaded 338 times
-
- 2p_—_drakes_1_replay.gz
- (30.57 KiB) Downloaded 296 times
Re: Exercises in Formula and Lua AI
u woke my ambition...
the game is far from lost what is this for a give up mentality
as to the exemplatory grunt rush where i took the replay from, well of course human players dont really need to do the gobo recruit so early in game because they mostly can control the other human player by placing units in front of his left vills in such a way that his opponent will for a longer time not get the opportunity to steal anything - but code that for the ai, it could take longer than anything else. it is a prevention of getting owned too early at the cost of half a lacking reinforcement on the right or elsewhere and worth the money.
about scouts: they not only scout, they deal three strikes, and when its night not too bad kind of dmg. whats more, they force the opponent to be careful about the stealing opportunities they could get away with too! the ai can steal villages, therefore its good to have scouts in the first recruits. i imagine the following unit composition on the left to be ok when actually focusing on the right: 2 grunts, 1 assassin 1 wolf. together with the gobo who joins the crowd, you have a batallion that can effectively threaten to attack anything on the left from multiple hexes with a good chance to kill while all troops are needed on the other. that means there wont be more than 2 at most 3 units to defend.
getting those recruits might require fred to play so good that he will survive not only his own grunt rush but the following counter.
in the replay we saw nelson doing what i suggested about grunts: deal unspecific damage with archers, assassin, and place a grunt/troll that does not attack right next to those specialists so they dont get hurt. when you attack, you could do the same by placing units next to a village and not attack with the meatshields while the specialists deal their safe damage. its a good strategy.
the game is far from lost what is this for a give up mentality
as to the exemplatory grunt rush where i took the replay from, well of course human players dont really need to do the gobo recruit so early in game because they mostly can control the other human player by placing units in front of his left vills in such a way that his opponent will for a longer time not get the opportunity to steal anything - but code that for the ai, it could take longer than anything else. it is a prevention of getting owned too early at the cost of half a lacking reinforcement on the right or elsewhere and worth the money.
about scouts: they not only scout, they deal three strikes, and when its night not too bad kind of dmg. whats more, they force the opponent to be careful about the stealing opportunities they could get away with too! the ai can steal villages, therefore its good to have scouts in the first recruits. i imagine the following unit composition on the left to be ok when actually focusing on the right: 2 grunts, 1 assassin 1 wolf. together with the gobo who joins the crowd, you have a batallion that can effectively threaten to attack anything on the left from multiple hexes with a good chance to kill while all troops are needed on the other. that means there wont be more than 2 at most 3 units to defend.
getting those recruits might require fred to play so good that he will survive not only his own grunt rush but the following counter.
in the replay we saw nelson doing what i suggested about grunts: deal unspecific damage with archers, assassin, and place a grunt/troll that does not attack right next to those specialists so they dont get hurt. when you attack, you could do the same by placing units next to a village and not attack with the meatshields while the specialists deal their safe damage. its a good strategy.
- Attachments
-
- 2p_—_The_Freelands_Turn_16R.gz
- alantara..tsk tsk tsk
- (38.2 KiB) Downloaded 359 times
Re: Exercises in Formula and Lua AI
by the way seems there is an AI arena out there since version 1.11 is out:
http://svn.gna.org/viewcvs/*checkout*/w ... /changelog
http://svn.gna.org/viewcvs/*checkout*/w ... /changelog
Re: Exercises in Formula and Lua AI
I'm not sure what this replay means, but I think fred might be able to learn something from it. (github fred on a week-old wesnoth trunk)
- Attachments
-
- Freelands_Overrun_Fred.gz
- (15.44 KiB) Downloaded 313 times
Re: Exercises in Formula and Lua AI
Hey folks, I've been playing some games as P1 Orcs on Freelands just so I could give you some sample replays to show you how orcs should be played (and how orcs should NOT be played). Here are some games I lost:
- YAMADA's picked Loyalists with picked Red Mage leader beat me. I believe I lost because I rushed a Red Mage. He just killed everything and leveled his units, eventually offsetting my income advantage. Against a scary leader like that, you have to wait until you have enough units to attack multiple sides at once, so that he has to choose what front to use his Red Mage on. We have to teach Fred to be cautious when facing deadly leaders. - Alarantalara's Drakes beat me. This is partly because he said he would attack like an overly aggressive AI, and I believed him and went defensive, which threw off my initial rush. We have to teach Fred to not commit units to defending the center if there is not a serious threat, it's better to send units on to the rush on the right and use reinforcements to shore up the center if a real enemy attack develops there. Also, retreat as day approaches
UPDATE: Oh, Alarantalara already posted our drake games, oh well.
- YAMADA's picked Loyalists with picked Red Mage leader beat me. I believe I lost because I rushed a Red Mage. He just killed everything and leveled his units, eventually offsetting my income advantage. Against a scary leader like that, you have to wait until you have enough units to attack multiple sides at once, so that he has to choose what front to use his Red Mage on. We have to teach Fred to be cautious when facing deadly leaders. - Alarantalara's Drakes beat me. This is partly because he said he would attack like an overly aggressive AI, and I believed him and went defensive, which threw off my initial rush. We have to teach Fred to not commit units to defending the center if there is not a serious threat, it's better to send units on to the rush on the right and use reinforcements to shore up the center if a real enemy attack develops there. Also, retreat as day approaches
UPDATE: Oh, Alarantalara already posted our drake games, oh well.
Last edited by nelson on September 9th, 2012, 2:07 am, edited 3 times in total.
Re: Exercises in Formula and Lua AI
And here are some games I won as P1 orcs on Freelands:
- I defeat Alarantalara's Drakes. Partly it is because I got a bit lucky in my initial attack and took out his village-holding clasher quickly, but I had 3 hexes at night so it wasn't shocking. I also took the center village from an augur that first night, and from then on my income advantage was punishing. Also I poisoned his leader and trapped him outside of a village, and he couldn't afford an augur to keep him alive - I defeat darkiller's Rebels. I killed his village-holding elf archer while it was still dusk, and then at first watch took two villages on the right and stole a village on the left. Then I trapped his leader outside his keep, and went and recruited on his keep just to rub it in - I defeat Edicka's Knalgans. His biggest mistake was surrendering villages to me when it was not absolutely necessary to do so. I got him to do that by threatening to kill a mortally injured unit that was about to level, which caused him to shield it, and by generally threatening to grab as many villages as possible so that when he moved off of a village to fight, I was able to steal it. I gained a deadly income advantage and poisoned his leader (and many other units), which ultimately led to his assassination when he ran out of shields. - I defeat Schlamarcel's picked Undead. Schlamarcel spammed low-damage units like ghosts and zombies, but these were decent shields for his DAs I must admit. I was able to take villages, however, and once I stole 3-4 villages he was pretty doomed. Luck was on his side initially, but when it swung back to my side he surrendered. Note that I initially put my forces on the left instead of rushing the right, because I expected him to rush me the first night.
- I defeat Alarantalara's Drakes. Partly it is because I got a bit lucky in my initial attack and took out his village-holding clasher quickly, but I had 3 hexes at night so it wasn't shocking. I also took the center village from an augur that first night, and from then on my income advantage was punishing. Also I poisoned his leader and trapped him outside of a village, and he couldn't afford an augur to keep him alive - I defeat darkiller's Rebels. I killed his village-holding elf archer while it was still dusk, and then at first watch took two villages on the right and stole a village on the left. Then I trapped his leader outside his keep, and went and recruited on his keep just to rub it in - I defeat Edicka's Knalgans. His biggest mistake was surrendering villages to me when it was not absolutely necessary to do so. I got him to do that by threatening to kill a mortally injured unit that was about to level, which caused him to shield it, and by generally threatening to grab as many villages as possible so that when he moved off of a village to fight, I was able to steal it. I gained a deadly income advantage and poisoned his leader (and many other units), which ultimately led to his assassination when he ran out of shields. - I defeat Schlamarcel's picked Undead. Schlamarcel spammed low-damage units like ghosts and zombies, but these were decent shields for his DAs I must admit. I was able to take villages, however, and once I stole 3-4 villages he was pretty doomed. Luck was on his side initially, but when it swung back to my side he surrendered. Note that I initially put my forces on the left instead of rushing the right, because I expected him to rush me the first night.
Re: Exercises in Formula and Lua AI
AI-Demos v0.11.0 is on the add-ons server, featuring the introduction of [wiki]Micro AIs[/wiki]. From the wiki page:
"Mirco AIs add specific functionalities to a side's AI that can be added to a scenario easily using only a few lines of WML code. Adding (or deleting) a Micro AI is done via the [micro_ai] tag, which also lets the campaign designer configure the AI behavior to the specific need of the scenario."
Currently, there are 2 Micro AIs:
For those of you mostly interested in the MP grunt rush AIs, I'll have to ask you for a little more patience. Ron is almost unchanged and while Fred has seen a lot of changes, most of them (except the changes to recruitment; see the changelog below) have been internal refacturing in order to enable real improvements to the AI that were not possible with the previous code structure. So Fred's in a bit of disarray at the moment, with some parts of his tactics improved and some slightly worse than before. Be warned, taking him for a real test run right now is probably not too useful and might lead to frustration. I have another busy week coming up, but after that I will get back to helping poor little Fred stand up to those nasty MP players.
"Mirco AIs add specific functionalities to a side's AI that can be added to a scenario easily using only a few lines of WML code. Adding (or deleting) a Micro AI is done via the [micro_ai] tag, which also lets the campaign designer configure the AI behavior to the specific need of the scenario."
Currently, there are 2 Micro AIs:
- The 'Pass Defense' scenario (now called 'Bottleneck Defense') has been generalized to work on any map (well, any map with a bottleneck). Configuring it to the map requires only the WML [micro_ai] tag, no changes whatsoever to the AI code are necessary.
- A new scenario called 'Healer Support', which demonstrates the use of healers to back up injured or threatened units rather than having them attack unconditionally (some of them might still attack, depending on the settings chosen). The aggressiveness (or lack thereof) of the healers can be set via the [micro_ai] tag. Note that an AI with healer support will not necessarily beat one without in an even game, as the AI takes healers away from attacks. It's up to the scenario designer to choose what works best in a given situation.
For those of you mostly interested in the MP grunt rush AIs, I'll have to ask you for a little more patience. Ron is almost unchanged and while Fred has seen a lot of changes, most of them (except the changes to recruitment; see the changelog below) have been internal refacturing in order to enable real improvements to the AI that were not possible with the previous code structure. So Fred's in a bit of disarray at the moment, with some parts of his tactics improved and some slightly worse than before. Be warned, taking him for a real test run right now is probably not too useful and might lead to frustration. I have another busy week coming up, but after that I will get back to helping poor little Fred stand up to those nasty MP players.
Complete 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
very nice!
i immediately tried it with undead of course, here some points to be considered:
orcs do well during day, during night too, but its better if they try to do somethign during day i guess, especially if there are trolls involved. those are often fearless and do most damage during the downtime of the ud. one peculiarity of ud v orcs is that ghosts can be quite the pest. try to attack those wiht two archers if possible, and mostly not melee unless u r on some very high defence ground .
i noticed that the ai emphasizes on healing before calculating a ctk on a unit respectively when it calculates how to attack. i mean, this is somethign that no mp player does: retreat an injured unit just because its injured with poison before deciding to attack a villaged ghoul. first should be: can i kill this unit, and if so, use the injured unit if it doesnt die first. if it could die, use another and try to get the vilalge with the injured vilalge which is free after success.
i also saw a ctk on my leader at some point, does the ai know about the leaders value or nto coded yet? if higher than.../or if about to lose the game...attack!
something that is very important in AI improvement: sometimes players like to lure others into attacking a unit which is placed in a manner that its not only disadvantageous to do it but completely displaces the ensnared unit. its is a common multiplayer tactics to do that, and therefore the ai must know about it! so when i put a skeleton on 20% water and there s a troll around, im pretty sure not only the ai but also any noob would take the bait. the ai should follow its own direction and try to have units in the location it wants to be strong in. not on 30% after attacking me and eating all the retaliation while my skel can withdraw and recover in a village. i dont know yet how i would translate this in machine-lingo,could someone plz help?
below the savegame.
i immediately tried it with undead of course, here some points to be considered:
orcs do well during day, during night too, but its better if they try to do somethign during day i guess, especially if there are trolls involved. those are often fearless and do most damage during the downtime of the ud. one peculiarity of ud v orcs is that ghosts can be quite the pest. try to attack those wiht two archers if possible, and mostly not melee unless u r on some very high defence ground .
i noticed that the ai emphasizes on healing before calculating a ctk on a unit respectively when it calculates how to attack. i mean, this is somethign that no mp player does: retreat an injured unit just because its injured with poison before deciding to attack a villaged ghoul. first should be: can i kill this unit, and if so, use the injured unit if it doesnt die first. if it could die, use another and try to get the vilalge with the injured vilalge which is free after success.
i also saw a ctk on my leader at some point, does the ai know about the leaders value or nto coded yet? if higher than.../or if about to lose the game...attack!
something that is very important in AI improvement: sometimes players like to lure others into attacking a unit which is placed in a manner that its not only disadvantageous to do it but completely displaces the ensnared unit. its is a common multiplayer tactics to do that, and therefore the ai must know about it! so when i put a skeleton on 20% water and there s a troll around, im pretty sure not only the ai but also any noob would take the bait. the ai should follow its own direction and try to have units in the location it wants to be strong in. not on 30% after attacking me and eating all the retaliation while my skel can withdraw and recover in a village. i dont know yet how i would translate this in machine-lingo,could someone plz help?
below the savegame.
- Attachments
-
- AI11.0.gz
- 11.0
- (19.97 KiB) Downloaded 307 times
Re: Exercises in Formula and Lua AI
Hey Rigor,
Thanks much for the comments. I'm still pretty busy throughout this week, but hopefully I'll be able to spend a little more time on poor old neglected Fred after that...
I did notice in your replay that the AI spent a huge amount of resources on that ghost in the NW and never got rid of it. But then, you can't just let it roam or it will grab all the villages. So Fred should send archers its way, that's what you're saying, right?
No, specifically attacking the leader is not part of the AI yet. It's in the plan, but not done yet. As are so many other things...
As for your last paragraph, the AI does take retaliation into account when it moves the leader away from the keep, but not for other units yet. So the code is there, but I'll have to think about whether that can be implemented in a more general sense. It's very expensive (in terms of computation time). Also, the whole automated decision process is always a problem, of course.
But on a more basic level, I don't think that I have worked out the attack/retreat/defensive line thing yet in a way that I am happy with. That's what I need to do first, I think...
Noted your point about village grabbing vs. retreating as well.
Btw, you said a while ago that you'd be interested in experimenting with other AI applications to MP, but I don't remember you telling me any specifics. I might have just forgotten...
Thanks much for the comments. I'm still pretty busy throughout this week, but hopefully I'll be able to spend a little more time on poor old neglected Fred after that...
I did notice in your replay that the AI spent a huge amount of resources on that ghost in the NW and never got rid of it. But then, you can't just let it roam or it will grab all the villages. So Fred should send archers its way, that's what you're saying, right?
No, specifically attacking the leader is not part of the AI yet. It's in the plan, but not done yet. As are so many other things...
As for your last paragraph, the AI does take retaliation into account when it moves the leader away from the keep, but not for other units yet. So the code is there, but I'll have to think about whether that can be implemented in a more general sense. It's very expensive (in terms of computation time). Also, the whole automated decision process is always a problem, of course.
But on a more basic level, I don't think that I have worked out the attack/retreat/defensive line thing yet in a way that I am happy with. That's what I need to do first, I think...
Noted your point about village grabbing vs. retreating as well.
Btw, you said a while ago that you'd be interested in experimenting with other AI applications to MP, but I don't remember you telling me any specifics. I might have just forgotten...
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
Ron has a new recruit CA on github.
Here Ron loses to Fred in 30 turn game. It should be reasonably representative of how both AIs play at the moment. Edit: To be fair, I also have a game where Ron beats Fred.
Here Ron loses to Fred in 30 turn game. It should be reasonably representative of how both AIs play at the moment. Edit: To be fair, I also have a game where Ron beats Fred.
Re: Exercises in Formula and Lua AI
And so that you do not have to go to github, we just released v0.11.1 which includes that new recruit CA for the generic grunt rush AI (Ron). Alarantalara has made a lot of improvements to it, most notably with the result that it now works not only with any of the mainline factions, but with any recruit list.Alarantalara wrote:Ron has a new recruit CA on github.
Rigor: this means that it should now be possible to use Ron as is for World Conquest.
Fred has mostly seen refactoring, and only minor changes to his behavior since the last release.
Changelog for v0.11.1
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