Hi FAAB. Thank you very much, this is great! The AI plays much better after the changes you made! I have some comments and questions back:
FAAB wrote: - move the village protection lower than the attack (to avoid situation 2.)
- however, keep the enemy village stealing higher than attack (*)
Maybe I misunderstand you, but I thought one of the main points of what Rigor suggested was to have grunts sit on villages so that the enemy wastes a lot of hitpoints trying to get rid of them. If I only make villages stealing higher priority than attacks, we're (almost) back to the default behavior (after reachable villages have been taken). I have tried this and I think it makes the custom AI play worse, so I took it out again, but left the code for it in the file. If you want to try it, comment out the line 'return 290000' and uncomment the one following it.
However, what you said made me do another change to that part of the code. Previously, I had number of enemy units that can reach a village set as higher priority than whether the village is owned by the AI. I have now switched that, which I think is better.
FAAB wrote:A remaining improvement to me would to activate the grunt recruitment only on turn 2 (to get more scouts on turn 1 for village grabbing)
Done. An alternative would be to force recruiting of a couple (2, 3?) scouts on Turn 1, before starting the grunt recruiting. By simply starting on Turn 2, the AI recruits whatever it wants, not necessarily scouts, on Turn 1.
FAAB wrote:(*) actually a potential unit kill is usually better than a village steal
Agreed. So the way I have done that: if any
of the units with moves left has a >50% chance of making a kill, then the village grabbing/holding action for all
units has lower priority than attack, otherwise it's the other way around. Does that sound right?
FAAB wrote:(**) with a change the logic on 60% grunt recruit to insure getting one more grunt when we have 3 out of 5 units (60%)
I have nothing against the new version at all, but wasn't that already done by using '>' rather than '>='. But then, that 60% was pretty much a random choice anyway, so if you have another preference, just let me know.
One other thing I have noticed: most often when the custom AI loses, it has more units (and villages) than the enemy, but some enemy units managed to sneak around the defenses and take out the leader while some grunts sit on close villages and watch. I could add something that does priority targeting of those enemies. E.g. 2 AI units for any enemy that is closer to the AI's leader than any AI unit; or for any enemy unit within attack range of the leader. Or something. Suggestions?
Also: in having the AI's play against each other (on Freelands), there seems to be a huge difference depending on who goes first (this is with 200 gold). With the old version, the custom AI almost always lost when it was playing Side 2. With the new version, it wins most of the time no matter which side it plays. (If you just want the outcome, you can add '--nogui' to the command-line and just get the result very quickly.)
Thank you very much again for the detailed comments. This is great! If you're interested, The new orcs_engine.lua is attached. Or, if you give me a few minutes,
you can download it in v0.9.5 from the add-ons server. (Edit: more than one file was changed, so I deleted the attachment. Download the latest version instead.)
Finally, something I noticed that is not directly related to this AI, but that caused "mystery crashes" of my code several times. If several sides in a MP game use the same faction, their leaders have the same id. So checking for a unit's id is not enough in some functions, you also need to check for the side of the unit. (This is just a note for other people interested in writing their own AI code, not directly related to this discussion.)