FfH2 AI Mod (Highly Experimental!)

The problem with the Sheaim is that they have very bad economic traits and have basically only one winning strategy: Spam deathnodes and death2 mages combined with pyrezombies. Obviously the AI does not understand this yet.
Planar gates are actually a reason why the AI is bad with them. They aren't hammer efficient. At 300 hammers you have to get 3+ creatures out of before you regain your hammers and the AI would be better off just by spamming pyre zombies.

There is one other killer strategy for Sheaim though. After bronze working spam warriors and upgrade them to Pyre zombies. Since the AI gets a huge discount of upgrading stuff this makes the AI really really powerfull. I have tweaked the choose production and upgrade function a bit so that the Sheiam spam warriors after researching bronze working and upgrade all warriors except those needed for military happiness in cities. Even the noble AI manages to get stacks of 15 UNITAI_CITY_ATTACK pyre zombies by turn 150. More than enough to keep them competetive against other AIs thanks to the explosion effect from pyre zombies.
 
There is one other killer strategy for Sheaim though. After bronze working spam warriors and upgrade them to Pyre zombies. Since the AI gets a huge discount of upgrading stuff this makes the AI really really powerfull. I have tweaked the choose production and upgrade function a bit so that the Sheiam spam warriors after researching bronze working and upgrade all warriors except those needed for military happiness in cities. Even the noble AI manages to get stacks of 15 UNITAI_CITY_ATTACK pyre zombies by turn 150. More than enough to keep them competetive against other AIs thanks to the explosion effect from pyre zombies.

Yeah that's the midgame tactic they should pursue. However the problem with that tactic is that it's not much fun to play against ;) . For what it's worth I have run a testgame with a block on planar gates until AC hits 40 and some forced adept building, so that those get used for city defense and the Tebryn Abrandi AI performed much better. I think it's really the investing 300 hammers for (almost) nothing that's killing them.
 
Hello, i just tried my first game with your AI mod, playing as Sheelba.

Firstly, i started at peace with animals too (bears and lions didn't attack my units). That's not intentional is it?

Secondly, when i used For the Horde, shortly after Orthus appeared, i was gifted exactly four (4) units (on a huge map swarming with raging barbarians). After i closed the worldbuilder (entered to verify the amount of barbarians) the game crashed.

So i quickly played another Sheelba game until Orthus appeared, casted the worldspell, got 6 units and the game crashed upon entering the worldbuilder this time.

Keep up the good work!
Can you post a save?

EDIT: Looks like Sheaim consensus is 'build Planar Gates later'? This is probably the simplest way to improve them, I think.
 
Some feedback on the new version for Skyre:

I like the adaptions you made to my cvgameutils.py changes. I couldn't find anything that looked out of place. It also showed me that I'm just an amateur when it comes to programming ;) . The only thing that seems a bit weird are the functions that you labeled #Minimum requirements for defence. I don't think that researching horseback riding is a good move for the hippus or hunting for the svarts when they get rushed early. Generally bronze working or archery is the way to go for everyone.

I noticed that you used my cannotdocivic functions to enable the AI to use aristocracy effectively. But since you modify the dll anyway, it would be more elegant to adjust the civics weighting system.

You seem to have put some weird code regarding the temple of the hand into the besttech function. That seems misplaced. I find that the Illians build their temples quite smartly in base ffh anyway, which is not very often.

I recently went over your modified spellinterface.py file and noticed some things that could still be improved.
1) The svartalfar world spell should be blocked for the AI. It's hard to find a worthwile use for a human, the AI just wastes its units.
2) The spread council of esus spell should also be allowed when the AI only has the holy city and not only when the state religion is esus.
3) The luchuirp, Grigori and balseraph world spells should have their thresholds increased to 7 cities/ 7 great people/ ~50 population. Right now they tend to blow those spells too early.
4) The give hammer to craftsmen spell should have his AI weight increased. a free engineer specialist is much more useful to the AI than a +1 strength promotion on a random warrior. Alternatively block taking the hammer for units which are not heroes.
5) The Illians would be improved if they cast their worldspell as soon as they are in a state of war instead of just going with a number of cities. 20 turns of beating up someone who can't build reinforcements is nice.
6) The Sheaim should also only use their worldspell when at war. Damaging stuff during peacetime does not help a lot.
 
3) The luchuirp, Grigori and balseraph world spells should have their thresholds increased to 7 cities/ 7 great people/ ~50 population. Right now they tend to blow those spells too early.

Really don't agree with the luchuirp holding their spell for that long. It definitely helps them to have those engineers for a longer time, rather than in a couple more cities. 4 or 5 is always my number of cities when playing them.


There is one other killer strategy for Sheaim though. After bronze working spam warriors and upgrade them to Pyre zombies. Since the AI gets a huge discount of upgrading stuff this makes the AI really really powerfull. I have tweaked the choose production and upgrade function a bit so that the Sheiam spam warriors after researching bronze working and upgrade all warriors except those needed for military happiness in cities. Even the noble AI manages to get stacks of 15 UNITAI_CITY_ATTACK pyre zombies by turn 150. More than enough to keep them competetive against other AIs thanks to the explosion effect from pyre zombies.

I'm not comfortable with programming the AI to actively try to exploit what's supposed to be a crutch that compensates for its old stupidity. Let them get their pyre zombie hordes the fair way. Sure, let them upgrade what warriors they had before BW, but forcing them to have an unusually high preference for warriors to build a strategy around that upgrade bonus is lame.
 
I'm not comfortable with programming the AI to actively try to exploit what's supposed to be a crutch that compensates for its old stupidity. Let them get their pyre zombie hordes the fair way. Sure, let them upgrade what warriors they had before BW, but forcing them to have an unusually high preference for warriors to build a strategy around that upgrade bonus is lame.
I probably should have been more clear. The strategy is not around some upgrade bonus. They use the same strategy that I as a human player use. basically they trade a discount on :hammers: for a discount on :gold:

Skyre, since you have written a very nice function for pirate coves, maybe you want to make Lanun found cities at the coast more often?
 
Really don't agree with the luchuirp holding their spell for that long. It definitely helps them to have those engineers for a longer time, rather than in a couple more cities. 4 or 5 is always my number of cities when playing them.

Hmm agreed if they actually use the hammers for craftsmen earlier is better. But if the AI still keeps using them as +1 attack promotions waiting would make more sense.
 
Can you post a save?

I had no older save, so i've been experimenting a bit more. Maybe it was my own fault For the Horde wasn't working properly. I've made some changes in Handicapinfo.xml to make raging barbarians a bit more raging and that might be a cause. And i use huger than huge weird maps. On a test on a large pangea map everything seemed to work correctly. Still, here's a save that crashes after you click the warrior in Braduk, cast the worldspell, greet several leaders and fortify the warrior.

Being at peace with animals seems to be intentional though. If it is, i really don't like it.
 

Attachments

I like the adaptions you made to my cvgameutils.py changes. I couldn't find anything that looked out of place. It also showed me that I'm just an amateur when it comes to programming ;) . The only thing that seems a bit weird are the functions that you labeled #Minimum requirements for defence. I don't think that researching horseback riding is a good move for the hippus or hunting for the svarts when they get rushed early. Generally bronze working or archery is the way to go for everyone.
Well, I guess what I actually mean there is 'get a second tier unit of some sort'. I don't mean for them to actually sit their horsemen or hunters in their cities, but horselord horsemen or sinister hunters are certainly a lot better than warriors for attacking enemy units in the field, and more flavourful than axemen or archers for those civs.

I noticed that you used my cannotdocivic functions to enable the AI to use aristocracy effectively. But since you modify the dll anyway, it would be more elegant to adjust the civics weighting system.
Probably, but it would take longer. :p If it can be done in Python, it doesn't really need to be moved to the DLL unless the performance of that function becomes an issue. Plus, you need to be a lot more creative in the DLL, since it's considered bad practice to refer to things like civics by name as it interferes with modding and such.

You seem to have put some weird code regarding the temple of the hand into the besttech function. That seems misplaced. I find that the Illians build their temples quite smartly in base ffh anyway, which is not very often.
That was ages ago. I need to redo the algorithm for placing them completely, pretty much. :)

I recently went over your modified spellinterface.py file and noticed some things that could still be improved.
1) The svartalfar world spell should be blocked for the AI. It's hard to find a worthwile use for a human, the AI just wastes its units.
*shrugs* I'm not a fan of blocking things completely just because the AI can't use them optimally. It's good for flavour if nothing else.

4) The give hammer to craftsmen spell should have his AI weight increased. a free engineer specialist is much more useful to the AI than a +1 strength promotion on a random warrior. Alternatively block taking the hammer for units which are not heroes.
Noted.
5) The Illians would be improved if they cast their worldspell as soon as they are in a state of war instead of just going with a number of cities. 20 turns of beating up someone who can't build reinforcements is nice.
6) The Sheaim should also only use their worldspell when at war. Damaging stuff during peacetime does not help a lot.
Agreed with both of these.

Sephi said:
Skyre, since you have written a very nice function for pirate coves, maybe you want to make Lanun found cities at the coast more often?
A good idea, although balancing the city founding function is pretty difficult due to its complexity. I'd also really like to improve the AI placement of their starting cities. They'll sometimes move their starting settler one or two squares, but they often still miss obvious good city spots. One reason seems to be that they value cows/pigs/sheep too highly, when Animal Husbandry is fairly expensive and they should be focusing on squares they can farm instead. They also don't value flood plains highly enough.
 
I had no older save, so i've been experimenting a bit more. Maybe it was my own fault For the Horde wasn't working properly. I've made some changes in Handicapinfo.xml to make raging barbarians a bit more raging and that might be a cause. And i use huger than huge weird maps. On a test on a large pangea map everything seemed to work correctly. Still, here's a save that crashes after you click the warrior in Braduk, cast the worldspell, greet several leaders and fortify the warrior.

Being at peace with animals seems to be intentional though. If it is, i really don't like it.
I've found the problem with the animals. That was a real Homer Simpson style "D'oh!" moment right there. Patch in the first post.

Your other stuff I couldn't figure out. For the Horde gave me a whole load of units (not just four or so like you were suggesting in your first post), but also gave me a Python exception I couldn't find a cause for. Also, the dump file from the crash didn't obviously point towards anything I've changed and I got some error about missing a "SnighlandsBigRocky" Python module when I moused over land squares while holding the Shift key in debug mode.

It looks like you've been doing a lot of your own modifications. Do you still get the same problems (the animal thing aside) if you start a new game without your changes?
 
Some feedback on the new version for Skyre:
1) The svartalfar world spell should be blocked for the AI. It's hard to find a worthwile use for a human, the AI just wastes its units.
Not sure if something like this already exists in the AI, but what it needs is some sort of function that creates a specialized raiding party. A small (4-8) stack of units specifically tasked to enter enemy lands and pillage improvements. Then you can have the Svartalfar AI trigger Veil of Night as soon as they have such a raiding party stack prepared. Raiding parties would help all the Civs, not just the Svarts. Leaders with the Raiders trait especially.

Such a raiding party should follow certain rules such as:
  • don't pillage roads if they have the Commando promotion
  • pick a target neighbor based on what units it has access to, give preference to neighbors with weakest units and lots of villages
  • don't declare war to enter enemy lands if the stack has Hidden Nationality
  • don't attack anything with a defense above zero
  • keep the stack together, defenders need to stay on top of the pillagers
  • when possible use the Mobility promotion to give all units a movement of at least 2
  • try and stay away from units/stacks that have a good chance to kill a defender

Some good early raiding parties might consist of:
  • 4-6 archers with Mobility (pillage and defense all in one)
  • 4 hunters (defense) and 3-4 warriors with Mobility (pillage)
  • 4 hunters (defense) and 3-4 adepts with Mobility or Body I (pillage)
  • 4-6 horsemen (pillage)

Anyway, just throwing around ideas. Great job on whipping the AI into shape guys. Its been an amazing transformation.

One potential bug to report. I get a CtD when I try to play a scenario, though I can still load them directly by opening the scenario's worldbuilder file.
 
A good idea, although balancing the city founding function is pretty difficult due to its complexity. I'd also really like to improve the AI placement of their starting cities. They'll sometimes move their starting settler one or two squares, but they often still miss obvious good city spots.

The starting settler will never move at the start of the game unless he can't found a city at the plot he is at. This is from (your) cvunitai:settlemove

if (GET_PLAYER(getOwnerINLINE()).getNumCities() == 0)
{
if (canFound(plot()))
{
getGroup()->pushMission(MISSION_FOUND);
return;
}
}

it takes quite a few hacks to get it to work (for example Khazad cause a CTD if they don't found a city in the first turn, some weird ffh code somewhere...), but the result is sometimes pretty nice (even without modifying the AI_value founding function).

in the screenshot the grigori settler startet at the position where the units stack is and moved north to a much bettler position with a lot less forests.
 

Attachments

  • Civ4ScreenShot0080.JPG
    Civ4ScreenShot0080.JPG
    422.9 KB · Views: 114
I've found the problem with the animals. That was a real Homer Simpson style "D'oh!" moment right there. Patch in the first post.

Thanks!

I got some error about missing a "SnighlandsBigRocky" Python module when I moused over land squares while holding the Shift key in debug mode.

SnighlandsBigRocky.py is my slightly modified Highlandsmapscript, which probably causes the 'For the Horde' error, so don't bother about it.
 
It seems to me that the Tower of Necromancy would be a great build for the Sheaim AI. It only requires one shadow node in addition to the starting mana and the entropy mana from the AV shrine (and on completion will give the death mana you might normally have built). It's a big investment, but gives +1 strength to skeletons, pyre zombies, diseased corpses, and spectres.
 
Just wanted to share a couple pictures of why I love this modmod.

In the game I'm playing right now, noble difficulty, the Lanun started very strong. I've finally mapped out Falamar's territory and though I knew you had implemented the AI's ability to use coves, I was still very impressed to see it in action.

aipirateports.jpg

Not only is he guarding some of his pirate ports with ships, but he's using bucaneers to do it! Awesome!

aibuccaneers.jpg

I was convinced that the Lanun would be a run away success and that they would be my only significant competition, but lately Kandros Fir has come on very strong with a large and robust arete, financial, aristograrian kingdom. I'm just not used to seeing this from the AI.

aikandrosaristograrian.jpg


aikhazad.jpg

I'm at turn 206 and am leading the pack, but the AI is doing a pretty good job of keeping up for noble difficulty. Decius suffered from a less robust starting location. Kandros beat him to all the fertile land. Tasunke is snuggled up next to the cultural behemoth of Falamar and has suffered for it. The Elohim are my neighbors and have suffered for it. Amelanchier doesn't seem to be living up to his potential. No wars yet, though I did send a hidden nationality raiding party through Elohim lands. For some reason everyone has avoided researching cartography so I am currently getting a large advantage by being the only one exploiting a vibrant trade route economy. The Lanun could of probably benefited from researching it since they built the great lighthouse early and had made contact with everyone long before anyone else.

aiturn206score.jpg

Can't wait for more improvements from you guys. I love this stuff!
 
Yeah that's the midgame tactic they should pursue. However the problem with that tactic is that it's not much fun to play against ;) . For what it's worth I have run a testgame with a block on planar gates until AC hits 40 and some forced adept building, so that those get used for city defense and the Tebryn Abrandi AI performed much better. I think it's really the investing 300 hammers for (almost) nothing that's killing them.

Could it be that the Planar Gate is just overpriced? I remember a good bit of discussion on that line a while ago. Why not just reduce it's hammer cost?
 
OK, opinion time...

I've been monitoring the bug thread and v0.41b seems to have some quite major problems that need to be ironed out due to the new BTS patch. So, should I be porting the mod to the new version yet or concentrating on some more minor changes for 0.41a, such as the world spell stuff above? It's a question of what people want, really.
 
I won't give an opinion one way or another, but I'll point out this: Kael's got his hands real full with work. If you decide to wait until he fixes all those bugs before adapting your mod to 3.19, you will probably be waiting a while.
 
The bugs that people are reporting in the main forums seem so gamebreaking that I think waiting would be the best option. Even though I would love to store my disc away; not being able to switch my traits while adaptive, trigger lentum frigus, or having Kuro settlements cost upkeep (and thats what I read in just 2 mins) will just keep me from patching anything.
 
Yep, that's what I was thinking. I could try to fix some of these bugs myself, but changes in 3.19 don't seem significant enough for it to be worth all the pain. Most of them are from either the unofficial patch or the Better BTS AI mod, both of which are included in my mod, anyway. I just don't want to get left behind when everyone else switches over.
 
Back
Top Bottom