Exercises in Formula and Lua AI and AI-demos add-on feedback

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

Moderator: Forum Moderators

Post Reply
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

khorne-flakes, Rigor: thank you! You are confirming several of the weaknesses I knew or suspected the AI to have (plus a couple points I didn't think about), that's great. Unfortunately, most of these are things that aren't that easy to deal with any more - changing it to work better in one situation often makes it play worse overall (such as the new poisoner behavior does, I think). I'll keep working on it (and studying your replays)...

Rigor, just one thing: the AI does not stop its "smart" (cough!) behavior at Turn 16 under all circumstances, but only if it's much stronger than the opponent (50% stronger in total HP for now). If that's not the case, it will continue with its grunt rush behavior as well as it can (often by then it's pretty much in over its head against a human opponent).
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Exercises in Formula and Lua AI

Post by UnwiseOwl »

I tried out the grunt rush AI last night, and as a not top-level player I found it pretty challenging. I still won with my Saurian/Drake team, but it took 20 turns. I also watched it stomp the RCA AI in a mirror match.
I found the Assassins to be extremely effective against my drakes, but I guess that's normal anyway. There were a number of things that I still felt were sub-optimal, though.
:Most obvious is that the leader rushes out to attack before recruiting, the orcs could have had multiple extra grunts out against the RCA on a number of occasions had the AI simply recruited before their Troll went out to kill the RCA Grunts.
I supect that it's a just not a feature yet, rather than a bug, but the AI, while being good at poisoning, is terrible at protecting itself from poison. In the northerner game it got destroyed by assassins and slayers (getting almost all its assassins and archer poisoned by two guys), there should be a rules that says that if there's not a good chance to kill a more valuable unit with a ranged attack to go for a melee attack or just another target. A 'more valuable unit' would be described by some combination of gold value and remaining HP, I imagine, so that a sorely injured archer would go after the assassin anyway (unless the archer was going to die, in which case it would back off), while a healthy one would look for another target.
The grunts against me in the South-East acted oddly, too, at one point they decided all to hold the vills and good defensive terrain when they could easily have dispatched an injured drake for little cost. I have a replay which I wil post..uh, sometime?

I loved watching the AI game at the point where the AI decided it had an overwhelming majority, and the rush along with the Gobo and Western grunt, suddenly all flew southward. Beautiful to watch.
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

UnwiseOwl: Thanks for testing and sending your comments! And I bet you're a much better player than I am, so this is much appreciated.
UnwiseOwl wrote:Most obvious is that the leader rushes out to attack before recruiting, the orcs could have had multiple extra grunts out against the RCA on a number of occasions had the AI simply recruited before their Troll went out to kill the RCA Grunts
It's funny how some things are so obvious once somebody points them out. :doh: Especially since this one is relatively easy to change. Well, but then, it isn't. Because you want to recruit on the hexes that are closest to wherever you want your units to go; but those are likely occupied at the beginning of the turn because that where you recruited last turn, so you need to move those units away first; but you don't necessarily know in which direction is best unless you do the fill move/attack analysis, so ... you either move the leader last, which is not always ideal; or you move the other units off the keep first in a direction that's potentially not ideal; or it gets a lot more messy... :?
Anyway (please excuse my rambling once again), thanks, this s a really good point. I just figured I also write down the thought process that follows as an example that nothing's ever easy if you want to do it right. But I do need to do something about that and for some reason I seem to think that this is fun. :)
UnwiseOwl wrote:I supect that it's a just not a feature yet, rather than a bug, but the AI, while being good at poisoning, is terrible at protecting itself from poison.
Yeah, that's simply not taken into account yet. I'll check out your suggestions again when I get to that, thanks.
UnwiseOwl wrote:The grunts against me in the South-East acted oddly, too, at one point they decided all to hold the vills and good defensive terrain when they could easily have dispatched an injured drake for little cost. I have a replay which I wil post..uh, sometime?
Having written the code, I am pretty sure I know exactly what's going on, even without seeing the replay. It's again a matter of something still being under development and the "simple" version, while being acceptable at the beginning, not quite cutting it when you're trying to fine tune things. But I'd like to see the replay anyway if you have it.
UnwiseOwl wrote:I loved watching the AI game at the point where the AI decided it had an overwhelming majority, and the rush along with the Gobo and Western grunt, suddenly all flew southward. Beautiful to watch.
:D I can only take partial credit for that though, because a good part of what's going on here (not all, but quite a bit) is simply letting the default AI do what it does best: attack without mercy and compromise.

Thanks again, it's great getting all this feedback! Did I mention that I think this is a lot of fun?!
User avatar
Rigor
Posts: 941
Joined: September 27th, 2007, 1:40 am

Re: Exercises in Formula and Lua AI

Post by Rigor »

for me too '!! :mrgreen: :mrgreen: :mrgreen: i think you have reached a state where it would be helpful to list the remaining issues in a table and give them scores of how easy they are to implement. not only would everybody see whats obvious but you could track the bugs uh normal ai behaviour in a more efficient way. all those new suggestions need a proper digestion by the worker :D
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Exercises in Formula and Lua AI

Post by UnwiseOwl »

Especially since this one is relatively easy to change. Well, but then, it isn't. Because you want to recruit on the hexes that are closest to wherever you want your units to go...
I guess that would make it more complicated, but for the most part a closest spot to enemies recuiting routine should do fine, at least as a placeholder, right?

This is my list. I've only played a few games with it, and I'm not familiar with everything, but...based on its current level, I suspect that this AI is good enough to hold off a newish player. It may never be good enough to beat a Rigor or The Black Sword, but I have no doubt that it'll be beating me soon (it's already making me think about my play- "if the AI doesn't want to do that, maybe I shouldn't try it..."). Before it gets to that point, though, some changes that could be made that would make it more competitive in my eyes (though I'm an average player at best so my advice is not so useful as some).

1. It should think about ZOCing weakened units so that they can't escape even if it fails to kill them due to the dice rolls (in other words, I don't think ZOCing is so important as attacking the right units, but if there's a chance to ZOC as well, the AI should take it). I see this as the biggest difference at the moment between the AI and humans. Protect the wizard seems to do it a bit better, but that could be a coincidence based on good movement values on that map. I understand that it's hard for the AI to know when this might be worth it, but its a very useful strategy that the normal AI is mostly ignorant of. Of particular interest would be the two-unit version that brings back-stab into play.

2. The aforementioned poison issues. Obviously teaching the AI to use abilities properly is going to be extremely difficult, but so worthwhile if it can work :D

3. The strange behaviour of those grunts as we talked about just earlier. If only because it is so obviously the action of a computer. Any human would have charged at that point, I'm sure.

4. I think the village sitting grunt in the West is a liability and the obvious weakness in the chain at the moment. I know that think is a specific implementation for this map, that wouldn't apply to the generic AI, but I think some weight needs to be put at getting a floating unit in there somewhere that can provide additional support there or in the centre if required. It's too easy to get into the good terrain next door and beat down in favourable TOD. It's not up to me to question Rigor, but each time I got after this AI that's where I find myself hitting.

5. The next step is developing a switch between this and the RCA for emergencies (I don't know if it cuts in randomly or if there's triggers based on enemy recruits and positioning), so that players can't adapt to the constant grunt stream. Then of course there's the option of an alternate AI and switching between them all based on some kind of master system, but surely that's where this is heading next...
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
User avatar
Rigor
Posts: 941
Joined: September 27th, 2007, 1:40 am

Re: Exercises in Formula and Lua AI

Post by Rigor »

unwiseowl, you hide behind such a misleading name. questioning the strategies of others is something absolutely fantastic, and disagreements about specific strategies is not wrong but on the contrary the thing we are all looking for when posting our thoughts on a forum - you kind of expect some disagreement in order to talk it out until even an improvement can take place because aspects are taken into account that were not illuminated first.

under this premise, i suggest you tell me your plans for the hard-coded grunt in the village. my idea of his usefulness is as follows: otherwise this village is free, occupied and remodels the p1s unit flow towards this unimportant target while you need to support units for the right side - at least in the beginning of the game. later, of course, p2 will try to launch some few or lots of units to get that position, but to be honest, the grunt rush is so amazingly hard to counter that you will see yourself always sending your fresh recruits to the right side instead of going left. also, if you should manage to get the left, you would be soon dislodged from there, and have nothing, not the right and not the left side to hold up the tide. why? because p1 sees how many units you dedicated to the left, and will know that you are empty-handed in the right, and you as p2 always coem too late!

abotu the generic approach: i have one idea that goes as follows:

first, we need that list of changes for the freelands AI and draw our conclusions what from that is generic and whats map specific, apart of the fact that i think verything is factions specific. then, several strategies for other races could be coded, which would make the AI reconsider its priorities when sending mages to stand in the first line because it was the only unit who could reach an enemy while other supportive spam units are far away or cant protect the exposed units. a big deal of that was already shown to work when coding "grunt or other troops always next to assassins if possible" - if we should get to the point where every unit in the initial recruits woudl get a score how important it is, or what kind of unit this is, then of course it would be easier for the AI to decide what to do with it.

Some points i am thinking about:
cheap units <=14 should be produced in higher numbers than others - except maybe in some special cases (drakes) but lets stick to that right now.
healers should be at least close to one unit, if possible.
ulfs mages adepts and protactable species should be shielded by low cost units (grunts, spears, footpads or the like)
and so on.

those values could be for instance expanded and implemented step-by-step into the RCA AI when the concept has proven to be more effective than otherwise - like we now saw.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

UnwiseOwl, Rigor: this is a great discussion! I am following it with interest, but don't have time to comment on specifics right now. So here are just a few general comments and then the list of issues and their difficulties Rigor asked for. I had that list for myself of course, but without the explanations of why these things are difficult and what exactly the issues are. Let me know if this is useful and if I should include more (or less) detail.

As a general comment, most of the time the difficulty is in setting up criteria when to do something, and when to make an exception from the rule. Once a criterion is defined, the coding more often than not is (comparatively) straight forward (although it might still require 200 lines of code). The exception from this rule are things that involve:
- anticipating what the enemy will do on the next move
- spatial reasoning: pattern recognition is something the human brain is very good at, and computers not at all
- attack combinations (evaluating the effect of attacks by more than one AI unit)

So here it comes. Let me know what you think and what I am missing.
List of open issues for the Freelands Side 1 Grunt Rush:

Code: Select all

General comments about things that are really hard to do:
- "Spatial reasoning" (defensive lines, ZOCing, etc.), other than the simplest strategies
- Anything taking next-turn retaliation by the enemy into account (again, other than in a very simplified way)
- Things requiring evaluation of attack combinations (effect of several units attacking the same enemy) is rather complicated
  - However, the devs have written new code that does that for 1.11/1.12, so this will become much easier in the future

Things that absolutely need to be done:

- Attacks on enemies that have made it too far north
  - This is still at a rather primitive stage and absolutely needs to be refined
  - Currently, units that have made it to (x=1-16,y=1-7) or (x=17-37,y=1-10) are considered serious threats (to either the leader or crucial villages) and are attacked unconditionally and by as many units as can get there
  - This causes for example the grunt running himself to death against the unit in the village seen by Rigor, or the attacks on the gryphon seen by khorne-flakes
  - Need criteria when:
    - not to attack but take a defensive stand
    - not to attack with all units that can reach a given enemy
    - a unit that has made it into this area can be ignored in favor of more important targets
  - Difficulty: coming up with criteria when to attack and with how many units; the coding is comparatively easy (but see exceptions to that under 'General comments')

- Spread poison:
  - This needs to be refined.  I've tried 2 approaches:
    1. Whenever an enemy that's not on a village can be poisoned, do so regardless of position, tod etc.  This results in the assassins exposing themselves too much and being killed too easily by the enemy
    2. Same as 1, but also move another unit next to poisoners.  Fixes part of Problem 1, but also takes units away from the grunt rush.  Overall, I don't know if 1. or 2. is better as a general approach
  - Difficulty: deciding when _not_ to do a poison attack
    - Maybe only when poisoner is not exposed to more than 1 (2?) enemies on the next turn, or if he can attack from >60% defense terrain or village?
    - Doing a full analysis whether poisoner can die on next turn is hard (see 'General comments')
  - A related topic is the question when to poison a unit on a village.  For separate replays, Rigor once "complained" that the assassins did not try to poison the unit in the village, and once that they did.  :-)  (The difference is obvious to us, but not easily explained to the AI)

- When does the leader come out to attack, and how to combine that with recruiting?
  - Currently this is set very conservatively.  If the leader can die on the next turn by all enemies within reach attacking him and all of their hits landing, he does not.
  - Related, he should recruit first, but that requires potentially moving other units off the castle first, even though it is not their turn to attack yet (because we want to attack with the leader).
  - Difficulty:
    - Coming up with a conservative, but not overly restrictive criterion for the leader attack
    - Synchronizing leader attack & recruiting & moving of other units

- In general, when do units take a defensive stand, when do they attack?
  - Currently, the village in the SE is always attacked at night, and never during other times of day:
    - The one exception is when there's an enemy unit on it that has a high chance of being killed by a single unit (this is handled by a separate CA and is always done, anywhere on the map)
  - Also, the units around that village (and the village on the left, in fact), always take up defensive positions around the village.  They never come forward to attack (as was observed by UnwiseOwl) unless:
    - There's a high chance to kill the enemy with a single AI unit
    - Villages can be grabbed
  - Difficulty: the decision when an exception from the general rule is acceptable

- ZOCing weakened units so that they can't escape
  - Doing the 2-unit thing on opposite sites is not trivial, but easier than some of the other stuff in this list
  - Doing a more complex behavior is quite difficult
  - Again, one of the problems is the criterion _when_ to do something like that

- Other things that should be done eventually, but need to wait for now because they are very much not easy and/or there are other things with higher priorities (in no particular order):
  - Come up with a different fall-back routine once the AI considers the game lost
    - I will develop that separately
  - Try blocking enemies from villages
  - Retreat/reform during unfavorable time of day and form defensive lines
    - That's very much non-trivial, at least if we want to do it right
  - Attack strategic targets; e.g., if you can do more damage than enemy
  - Also go for the village in far SE
  - Take enemy abilities and weapon specials (such as healers or poison) into account
User avatar
Rigor
Posts: 941
Joined: September 27th, 2007, 1:40 am

Re: Exercises in Formula and Lua AI

Post by Rigor »

from your reply i had many ideas how to implement it into code, ill go through the points i saw step by step now and you ll let me know if its possible, ok ? :lol2: you adressed many points here, so i will focus on a limited number of topics: generic time of day, first steps of a generic defensive stance, generic conditions for attacking villages. i hope others can fill in on those and the other topics!!

from what i have gathered the ai doesnt even know what time of day is favorable for it to adjust its attacks - we can change that:
tell the ai that in a standard game on map xyz the tod is e.g. dusk - a standard on most maps, at turn 1. if it knows already it needs to know how to behave against an opponent: like that the ai always knows when its powerplay and when its turn tail time! thats a generic approach and applicable on any map, with any faction. of course, the ai has to cheat and know that faction beforehand and check the following list:

well i need a matrix i guess...

Image
i attached the file to make sure it doesnt dissapear sometime - change the extension from gz to xls, i am not allowed to upload such file extensions in the forum.

for isntance, if the TOD is super unfavorable and dont try to dispatch the stealing unit according to your prior knowledge matrix unless your chance to kill makes it a very safe bet.

so according to its evaluation it knows when to use the defensive routine we were talking about (which was hard to code) - maybe its not that hard anymore because....and here it comes:

the ai will know when it is supposed to get lost again and doesnt need a specific position with coordinates but can calculate them on its own. like that, it could even form a rudimentary line, such as "cheap stuff to the front, expensive units in the back (just check unit pricing - 16 is already not so cheap).

as for the line: usually on every map there is more than just open space. look for terrain with bad MP modifiers (water, deep water, mountain peaks, cave, mushroom desert, and all kinds of impassables, walls, void, and such for instance) and position yourself next to it, using a line (unit, free hex, unit, free hex, unit ...) to another point on the map that fulfills such a criterion.

the distance the ai should reach would be e.g. 5 mp to its next own village, which is another criterion it could easily fulfill. why? the spam units you have in the front could be damaged or die, but if they survive you heal them the next turn in exactly these villages.

if the ai doesnt know where the line should be, you could orient yourself according to the initial keep positions. the max hexes necessary to reach it from leader starting position to leader starting position are divided by 5 and the area which should be the area for such lines would be area 3, +-3 hexes, depending on what defense modifiers are close and can be occupied with own troops. for instance for freelands thats the castle formation that should be destined because the defense there is 60% and inside the +- variation.

for freelands this example is : 17 hexes from ldr pos1 19,4 to ldr pos2 19,21. 17 divided by 5 is 3,4 hexes. 3,4*3 is specified central "area 3" with 10 hexes away from the keep, which is great for both the left and the right side. both castle hexes in the middle are included in that calculation. and the ai can choose any good terrain in that region to retreat during an unfavorable tod.

you were talking earlier about threatening units in a certain area, because they come close to your king. this area computation could be as follows: initial leader starting position +- 5 hexes (x or y value) is critical, above that you can completely ignore those units.


when to attack villages:

well, a good human player will not like to expose himself to much damage, and you might face a line. of course, it doesnt make much sense to attack a villaged guard with no chance to kill, but it makes sense to attack and poison this unit. the attack routine during night is quite good already. however, if units attack a village the calculation should go as follows:

does it make sense to attack - calculate the number of units that can attack a target: 2 hexes are free at day because somebody formed a line. you have 2 grunts, 2 assassins, 1 archer and a troll. the villaged unit is a 40 hp dwarfish fighter: the ai will find out it that dealing a max of 7dmg x2 strikes x2 units x (1,00 chance to hit everything - 0,60 chance the target will defend) = 11,2 dmg not really convincing, right? ok lets say there is a thief inside who has some blade malus and it turned night: 25 hp thief: 15dmg x 2 x 2 x (1,00-0,70) is 18, which is not perfect, but more than 60% of the units hp, making it quite useles in the coming turn - so it pays off. besides, a lucky double strike out of 4 strikes is quite probable and kills the unit anyways. you will soon find out that using the wrong tod for attacks will automatically turn off the mood for orcs to attack, and can be used as a generic approach: the same unit during daytime would result 10x2x2x0,3 which is 12 and very little dmg. however, the situation with a lonely dwarf with 40 hp at night, surrounded by 4 grunts looks as follows: 10x2x2x2x2x(1,00-0,50) is 80 so the dwarf pretty surely dies.
Attachments
ai demo matrix.gz
gz-> xls
(23 KiB) Downloaded 173 times
User avatar
Rigor
Posts: 941
Joined: September 27th, 2007, 1:40 am

Re: Exercises in Formula and Lua AI

Post by Rigor »

one crude defensive approach for starters could be added together or without the previously discussed decision helper for the ai:

sometimes players dont really wish to defend the village that will be swarmed with grunts soon and go back. if this happens, the ai could take the village alright, and receive the "return to keep" order (except the hard-glued grunt on the left side) at the beginning of dawn. exactly with the beginning of daytime, all troops on the right go back maximum speed (so they will reach their own villages in 2 turns, sit there on 50&60% terrain, and return only when its dusk again, this time in higher numbers than ever to give those annoying humans a proper beating!
User avatar
UnwiseOwl
Posts: 516
Joined: April 9th, 2010, 4:58 am

Re: Exercises in Formula and Lua AI

Post by UnwiseOwl »

Ooh! There's some stuff to think about there, mattsc, Rigor. Will have a look directly, but though I'd post some recent observations.
I ran and observed 8 simulations last night, with the Specialist Freelands GR AI in the North and the regular Experimental GR AI in the South, and the results were an equal 4/4 split (the difference between a lucky grunt and an unlucky grunt at a crucial time is so important, even if the luck evens out altogether).
In a number of games where the North won it did so by locking down the East side with just one grunt, swapping villages in the SE, and the defender failed to ever send any reinforements to its one unit in the area, so the two units just danced around playing a zero-sum game while the real fight happened in the centre, and the specialist only won when it had built up enough of a majority for the regular AI to take over.

Also, the 'normal' grunt rush AI plays an agressive game in the centre that forces the 'specialist' AI off of its Eastern plan to play defence, then the specialist units get tied up between fighting and going East again. To avoid this, there may need to be some rule that says something like "if a grunt is in the centre and as far or further south than the hill village, have it continue using the 'normal' AI rather than running East"

I still don't know when it's a good time to poison, so I don't blame the AI for being confused.

Also, there's some suboptimal behavior in the South East for the 'normal' grunt rush AI that I noted repeatedly, I'm not sure if it shares this with the regular AI or if it's part of its aggressive behaviour. When first flagging the vills, a lonesome unit on the Westmost of the triangle of villages always moves for the Northmost village, then moves back in the next turn to flag the South-Eastmost. I suspect that this is one of those spatial things that is difficult for the AI, but it would seem logical to me that if there's the choice of two villages and the enemy cannot get either next turn it would be sensible for the unit to pick the village further from the enemy base first, then the closer one, enabling the unit to be closer to the front when the enemy does roll in. Perhaps this could be done by assigning villages differing priorities based on distance from the enemy base?

Edit: Also, either this AI is just really good against drakes or I'm just really lousy with them, as with Northerners and Knlagans I can easily defeat it.
Maintainer of the Imperial Era and the campaigns Dreams of Urduk, Epic of Vaniyera, Up from Slavery, Fall of Silvium, Alfhelm the Wise and Gali's Contract.
But perhaps 'maintainer' is too strong a word.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

UnwiseOwl: Thank you for doing all that testing!! It am not too surprised that the general and the specialized grunt rush come out about the same, since the parts of the AI that deal with an all out assault up the middle (which is what the general version will do at the moment) are pretty much the same. In fact, the Freelands specialized version has a disadvantage in that case as it diverts units to the east (and a couple to the west) that are then not available in the center. So I agree with you that there probably has to be a provision that deals with that case.

FYI, I had a pretty detailed "live" exchange with Rigor today while we watched another MP systematically dismantle the AI, so I won't reply to his specific points here right now. My main conclusion was that a lot of those things are not as easy to put into the AI code as they might seem. So it will take me a little to code those.

However, there were a few things that I was able to change relatively easily, which has been done in v0.9.14, see changelog below. They are not major changes, but I hope that they will at least be noticeable. In particular, I'd like some feedback whether the following things make a (positive) difference:
- Units on right side now retreat a bit during the day, advance more during the night
- Village grabbing and holding was changed so that, e.g., wolf riders in the middle of a bunch of enemies don't leave their village any more - however, maybe there's now an overemphasis on keeping and grabbing villages?
- The endgame is now slightly less embarrassing, but still only very preliminary

UnwiseOwl: your comment about the order of grabbing villages is definitely something to consider. I'll look into that.
UnwiseOwl wrote:Edit: Also, either this AI is just really good against drakes or I'm just really lousy with them, as with Northerners and Knlagans I can easily defeat it.
Somebody else will have to answer that... :)

So, I have lots of things to work on, but I think we're beyond the things that are quick and easy to do. Updates will probably be a little less frequent from now on.

And finally, the changelog:

Code: Select all

0.9.14, 10 July 2012
- Freelands Side 1 Grunt Rush:
  - Leader threats:
    - Only attack unconditionally:
      - Enemies that are within one move of the leader
      - At night: any enemy in northern part of map
    - Other TOD: attack if attackers HP > 20 and if AI can do more damage to enemy than enemy to AI
  - Fallback CA now never moves units off villages
  - Small change causing different behavior based on TOD at eastern village
  - Poisoners will now also attack units on villages, but with low priority
  - Slight change in village grabbing logic, so that the AI does not abandon threatened villages (too much emphasis on villages now??)
  - Reprioritized some CAs again (village grabbing vs. village attacking vs. poisoning)
  - Added assassin complaining about ***censored*** :-)
User avatar
Rigor
Posts: 941
Joined: September 27th, 2007, 1:40 am

Re: Exercises in Formula and Lua AI

Post by Rigor »

hah, so after testing it out i had two very short games due to extreme luck with loys and elves. then i thought ok lets just start over the ai just cant win like that and i went easy on it the third game, doing a counter atack during night, which can be good but is risky.

result: my leader has 9 hp during day and is poisoned,the ai holds 10 vills, and is t.h.r.e.a.t.e.n.i.n.g. me with a leader kill!!! wth did you create here matt???

turn 11: one grunt can one-slash my leader, two times! the priority must have been really low to kill the leader here or else i cant understand why he doesnt go for it. similar situation like in
turn 18: another ctk for the ai, but this time it tries it. although with delay. why is it not attacking the leader straight away, and uses a unit that is freed after another dies? some kind of cat and mouse game? ill just finish your other units first- mp-mentality? :))
turn 24: i got for the easy vills in the N west. with a hardcoded grunt / gobo this wouldnt have happened.
turn 26: the ai follows. good one, there was nothing to win on my side. man, that grunt pillaging me on the other side goes sooo on my nerves!
turn 28: nice that the grunts dont spend all their hp on an attack vs my lvl2 cav but wait until its night (i hope they are not coded like "never attack lvl2s cuz they always deal more counter than the grunt deals to them, even at night")
turn 30: i have to stop, i have not had breakfast, its late and im off to work. :lol2:
Attachments
AI_v0.9.14.gz
9.14 AI
(30.65 KiB) Downloaded 143 times
User avatar
Rigor
Posts: 941
Joined: September 27th, 2007, 1:40 am

Re: Exercises in Formula and Lua AI

Post by Rigor »

assassin behaviour upgrade: ok, dont spread poison at all costs. this leads to assassins running out heroically whilethe main troops body is in the back - nelson has a good approach: dont poison units on villages when other units cant deal damage as well. this should restrain the assassin to run forward and be killed just like that. as for the assassins poisoning single units not on a village, the rule that a unit should stand next to it would be helpful there. at least two units would have to go to hell, and if that condition is not met, the assassin would not go forward at all, which is good and worth to try in the next version.

one more cheat for the left:

the ai knows whats going on the left side without a need to scout. i guess its not too hard to code the condition "if units < coordinate 16,22" = 0, remove the command for the hard coded grunt and send stuff down to grab the south west, because thats a good thing to do. of course, you need at least two units to pillage so better dedicate one more troop to go down, e.g. a wolf.
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

I wasted a lot of time today on something that didn't work out in the end, so just quickly: v0.9.15 is a minor release with only small changes, but I wanted to get it out because two of them might be important:
1. The enemy leader is now attacked with high priority if there's any chance for a kill. This will prevent the issue Rigor found with the grunt not attacking a 9HP enemy leader.
2. I reverted the strict village holding rule, which caused units to sit around too much. This will have a bit of a negative impact on some other, still unfinished parts of the AI (although I tweaked those a bit also), but should improve the grunt rush itself again.

All the other changes will to have to wait for now, but please keep commenting. I'm taking notes!

Edit: Very minor change made and uploaded in v0.9.15-a. Dialog only...
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Exercises in Formula and Lua AI

Post by mattsc »

Apparently I'm in fast release world again, v0.9.16 is out with one of the easier changes suggested by Rigor et al., poisoner control. So the assassins now only try to poison units as follows:

Enemies not on villages are attacked only:
- if they are by themselves
- or if another unit can move with the assassin (that unit will not necessarily attack, but it will place itself next to both the assassin and the enemy)

Enemies on villages are poisoned with lower priority, and only if:
- they are either more than 8 HP down already
- or if another unit will move with the assassin and will attack

Of course, the final situation at the end of the turn sometimes looks a bit different, because everything's always based on the current situation. Anticipating what's going to happen next is one of the harder things to do. (And there's also the standard AI attack stage that takes over at the end of the turn and might still use the assassin.)

That's all for now...

Edit: I should point out that I am currently only making these changes for the Freelands AI.
Post Reply