Secret_Squirrel
Chieftain
- Joined
- Jun 19, 2009
- Messages
- 76
This is a small project I undertook in order to learn the basics of python, and so far its going well so I thought I would share it. Suggestions and feedback more than welcome.
Improved FFPlus AI - Version 2 Released!
The object of this modification is to make the AI make informed tech and unit choice decisions that are true to the flavour and playstyle of their race while maintaining a certain level of unpredictability. There is an equal focus on ensuring the AI economy will no longer crash due to poor economic teching.
Installation Instructions: Extract the zip file into your Fall Further Plus installation folder. If you have modified your CvGameUtils.py you should make a backup. The mod also relies on an unmodified PythonCallBackDefines.xml.
Note: If you have Odalrick's Modular Python mod installed, I'm pretty sure it would overwrite this but maybe not.
Changelog:
Teching:
- ALL civs have had their early beelines changed so that they are more "flavourful", biased towards ensuring that each civ leverages its strengths, builds its Unique Buildings and fields its Unique Units and Heroes.
- AI will research the required worker techs if enough resources of that type are present in their territory. ("Stolen" and modified from Turinturambar's Economic AI for FFH)
- Oceanfaring techs researched if the AI has many coastal cities.
- AI will ensure they have early economic techs before teching their preferred Tier 2 military techs.
- Writing beeline no longer based on random numbers, AI will now ensure they have writing before they delve too much into advanced military.
- Archery prioritised for those who have emphasised the recon line and do not have Bronze. (Ensures adequate city defense).
- Education researched early if civ starts near a lot of flood plains.
- Civs will now react to Hell Terrain entering their lands or somebody bringing Hyborem into the world, they can do the following:
- AI will check for opportunities to snatch the free great people at Drama, Military Strategy and Arcane Lore if nobody else has had them.
- War will now make the AI react!:
- Peace will make the AI focus more on economy and (affordable) expansion.
- Better Magic!:
- AI will go for late game civilization/religious heroes with as much zeal as the early ones.
- Some early game blocks for not so useful techs. Stirrups for example is useless if you have no Horse or equivalent resource. (Unless your civ does not require it).
Religion:
- Religion founding now a lot more diverse and unpredictable while maintaining flavour. (Most civs have 2 or more available religions they can consider founding when appropriate).
- If there are unfounded religions and the civ does not have much incentive to remain under a religion they did not found, they are likely to try and found another fitting religion for themselves.
- Priesthood heavily prioritised for those with the Holy City of their state religion.
- No disciple spamming by civs who do not have flavour affinity for their state religion or the holy city.
- Religious techs will not be researched by those with inappropriate alignment (evil civs wont found order, empy, etc).
- Religious Civics adopted asap if civ has the holy city of their state religion.
Unit production:
- Much greater stack diversity. A lot of work has gone into trying to provide variety while remaining effective.
- Limited workers to 3 per city during peace. 1 per city during war. (They will not disband any units, they just wont build more unless they lose a whole lot).
- Very controlled Settler production to ensure limited over/under expansion.
- Scouts limited to 4 (except Svartalfar).
- AI Will no longer build certain low strength units if their rivals have better units. Example: Horsemen limited to 5 for everyone except the Hippus if any neighbouring civ has Iron Working and Iron weapons.
- Will no longer produce their first settler without appropriate military defense.
- Javelin Throwers limited to 2 per city if the civ has Bronze Working.
- Priests limited to 3 per city until Theology. (To stop most notably, the tiger spam!)
- AI will not build Privateers if rivals have superior naval technologies.
- Archers limited to 5 per city for everyone except Ljosalfar and Amurites.
- Once Archery has been researched, total number of warriors allowed limited to 5 per city. (Ensures civs able to build archery ranges will not continue to use warriors as city defenders).
- World Units cannot be built in cities with poor production
- Heroes built as soon as they are available
- Illians get their Temple of the Hand sooner if the terrain around the city is poor.
Building production:
- AI will build more markets in general.
- Infernal AI will no longer build health buildings.
- Many MORE changes to influence how the AI handles building construction.
- Most civs are now quite fond of their unique buildings (Shrouded Woods, Warrens, etc).
- Unit training buildings built more often, and with more variety and intelligence. Taking into account traits, available mana, technologies, etc.
- Commerce and science improving buildings (Library, Money Changer, etc) will be built more often when the civ is not at war, and the AI now only prioritises them in cities with a high science/commerce rate.
- Courthouses built when maintenance is high.
- Forges prioritised in high production cities.
- Theoretically the AI is capable of a tower victory, but only if it acquires enough Mana types.
Improvements:
- Cottages will not be built under Aristocracy if there are other options.
- Workshops will not be built unless Guilds has been researched.
- Elves blocked from building Lumbermills.
Civics:
- Religion civic blocked for those without a state religion.
- Pacifism blocked when at war if leader does not have Philosophical trait, however the switch out of Pacifism is only allowed if the civ can afford the turn of anarchy (has enough defenders).
- Conquest blocked until Sanitation to prevent early adoption stifling growth. Later it can be adopted by AI's if the free XP provided allows them to reach the 5XP mark (or less for Charismatic leaders). For example, civ has or is building Form of the Titan and running the Apprenticeship civic.
- God King cannot be maintained if the civ acquires too many cities and they have the Cartography tech.
- Apprenticeship cannot be maintained once the civ has researched Taxation as by that point there are much better civics available.
- AI will now adopt Foreign Trade if it has lots of coastal cities and can benefit significantly from it.
- All the above changes take into account religious civics and AI's running those civics will not change due to any of the above circumstances.
Bugs/Known Problems:
- Kuriotates have a habit of building their settler unit and then never settling it, even when there are no external threats. I would try to change this using getCityFoundValue but that gets called 5 bazillion times per turn and just isnt viable.
- The supply cost bug in FF affecting summons can sometimes kill the AI's economy now that they are likely to utilise the summons more in general. I hope this bug is fixed soon!
- I had to remove the imported code from the Economic AI mod which gave instructions on when to build less/more adepts. For some reason it was causing certain civs to stop building completely in one or more of their cities. Since I removed this code, it has not happened since and I have no other references to Adepts/Mages at all any more. The AI still use them better than before but I dont strictly control how many they build any more. Not until I can come up with a better system or get this one working.
To Do:
- Specific Infernal/Mercurians AI. They wont do any worse, they just dont have as many instructions as all the other civs.
- Perhaps a more predictive rather than reactive approach in the AI's behaviour. I may have them check their neighbours' attitudes and have them react based on that. If everyone around them is getting along nicely they can be more builder oriented, if everyone hates them then prepare for war. I think this approach would be better than a strict is/is not at war system. (Assuming neighbours' attitudes can be measured using Python!)
- More playtests, its difficult for me to assess where to go with this now until I review their performance more. Its much faster if I just watch the AI play but after recently witnessing an AI clash between Abashi the Black Dragon and Sphener, I think I might just play it a bit more now instead.
Download Version 2:
Improved FFPlus AI - Version 2 Released!
The object of this modification is to make the AI make informed tech and unit choice decisions that are true to the flavour and playstyle of their race while maintaining a certain level of unpredictability. There is an equal focus on ensuring the AI economy will no longer crash due to poor economic teching.
Installation Instructions: Extract the zip file into your Fall Further Plus installation folder. If you have modified your CvGameUtils.py you should make a backup. The mod also relies on an unmodified PythonCallBackDefines.xml.
Note: If you have Odalrick's Modular Python mod installed, I'm pretty sure it would overwrite this but maybe not.
Changelog:
Spoiler :
Teching:
- ALL civs have had their early beelines changed so that they are more "flavourful", biased towards ensuring that each civ leverages its strengths, builds its Unique Buildings and fields its Unique Units and Heroes.
- AI will research the required worker techs if enough resources of that type are present in their territory. ("Stolen" and modified from Turinturambar's Economic AI for FFH)
- Oceanfaring techs researched if the AI has many coastal cities.
- AI will ensure they have early economic techs before teching their preferred Tier 2 military techs.
- Writing beeline no longer based on random numbers, AI will now ensure they have writing before they delve too much into advanced military.
- Archery prioritised for those who have emphasised the recon line and do not have Bronze. (Ensures adequate city defense).
- Education researched early if civ starts near a lot of flood plains.
- Civs will now react to Hell Terrain entering their lands or somebody bringing Hyborem into the world, they can do the following:
- Non Evil civs will research Divination if hell terrain starts to appear and they do not have life mana.
- Evil civs will research Infernal Pact (to adopt AV&StW) if hell terrain starts to take over their lands.
- AI's forced to make a decision on which "side" they take by researching Way of the Wise/Wicked dependant on their alignment and their mana types (Life, Nature, Law increase chance of heading for the Overcouncil. Death, Entropy, Chaos - Undercouncil)
- AI will check for opportunities to snatch the free great people at Drama, Military Strategy and Arcane Lore if nobody else has had them.
- War will now make the AI react!:
- If an early war occurs, the AI will check if it has Copper in its territory, and if it does, it will beeline Bronze Working to get those str 4 warriors. If not then it will tech Archery.
- If the enemy is superior in technology and weapons during an early war, the AI will focus on defensive military techs.
- The AI will now ensure it has sufficient siege to conduct a war if it is able to build them.
- Peace will make the AI focus more on economy and (affordable) expansion.
- Better Magic!:
- Node building techs (Necromancy, Divination, etc) prioritised by alignment.
- Civs with Enchantment mana will pick up KotE once they have Bronze Working.
- Sorcery researched sooner if the AI acquires more mana types.
- AI now has a strategy when building new mana nodes and is fully capable of death mana/spectre spam.
- Everyone will pick up a single enchantment node if they have Alteration.
- Most (living) civs will pick up a single body node if they have Alteration.
- Elves will try to build a fire node asap.
- AI will go for late game civilization/religious heroes with as much zeal as the early ones.
- Some early game blocks for not so useful techs. Stirrups for example is useless if you have no Horse or equivalent resource. (Unless your civ does not require it).
Religion:
- Religion founding now a lot more diverse and unpredictable while maintaining flavour. (Most civs have 2 or more available religions they can consider founding when appropriate).
- If there are unfounded religions and the civ does not have much incentive to remain under a religion they did not found, they are likely to try and found another fitting religion for themselves.
- Priesthood heavily prioritised for those with the Holy City of their state religion.
- No disciple spamming by civs who do not have flavour affinity for their state religion or the holy city.
- Religious techs will not be researched by those with inappropriate alignment (evil civs wont found order, empy, etc).
- Religious Civics adopted asap if civ has the holy city of their state religion.
Unit production:
- Much greater stack diversity. A lot of work has gone into trying to provide variety while remaining effective.
- Limited workers to 3 per city during peace. 1 per city during war. (They will not disband any units, they just wont build more unless they lose a whole lot).
- Very controlled Settler production to ensure limited over/under expansion.
- Scouts limited to 4 (except Svartalfar).
- AI Will no longer build certain low strength units if their rivals have better units. Example: Horsemen limited to 5 for everyone except the Hippus if any neighbouring civ has Iron Working and Iron weapons.
- Will no longer produce their first settler without appropriate military defense.
- Javelin Throwers limited to 2 per city if the civ has Bronze Working.
- Priests limited to 3 per city until Theology. (To stop most notably, the tiger spam!)
- AI will not build Privateers if rivals have superior naval technologies.
- Archers limited to 5 per city for everyone except Ljosalfar and Amurites.
- Once Archery has been researched, total number of warriors allowed limited to 5 per city. (Ensures civs able to build archery ranges will not continue to use warriors as city defenders).
- World Units cannot be built in cities with poor production
- Heroes built as soon as they are available
- Illians get their Temple of the Hand sooner if the terrain around the city is poor.
Building production:
- AI will build more markets in general.
- Infernal AI will no longer build health buildings.
- Many MORE changes to influence how the AI handles building construction.
- Most civs are now quite fond of their unique buildings (Shrouded Woods, Warrens, etc).
- Unit training buildings built more often, and with more variety and intelligence. Taking into account traits, available mana, technologies, etc.
- Commerce and science improving buildings (Library, Money Changer, etc) will be built more often when the civ is not at war, and the AI now only prioritises them in cities with a high science/commerce rate.
- Courthouses built when maintenance is high.
- Forges prioritised in high production cities.
- Theoretically the AI is capable of a tower victory, but only if it acquires enough Mana types.
Improvements:
- Cottages will not be built under Aristocracy if there are other options.
- Workshops will not be built unless Guilds has been researched.
- Elves blocked from building Lumbermills.
Civics:
- Religion civic blocked for those without a state religion.
- Pacifism blocked when at war if leader does not have Philosophical trait, however the switch out of Pacifism is only allowed if the civ can afford the turn of anarchy (has enough defenders).
- Conquest blocked until Sanitation to prevent early adoption stifling growth. Later it can be adopted by AI's if the free XP provided allows them to reach the 5XP mark (or less for Charismatic leaders). For example, civ has or is building Form of the Titan and running the Apprenticeship civic.
- God King cannot be maintained if the civ acquires too many cities and they have the Cartography tech.
- Apprenticeship cannot be maintained once the civ has researched Taxation as by that point there are much better civics available.
- AI will now adopt Foreign Trade if it has lots of coastal cities and can benefit significantly from it.
- All the above changes take into account religious civics and AI's running those civics will not change due to any of the above circumstances.
Bugs/Known Problems:
- Kuriotates have a habit of building their settler unit and then never settling it, even when there are no external threats. I would try to change this using getCityFoundValue but that gets called 5 bazillion times per turn and just isnt viable.
- The supply cost bug in FF affecting summons can sometimes kill the AI's economy now that they are likely to utilise the summons more in general. I hope this bug is fixed soon!
- I had to remove the imported code from the Economic AI mod which gave instructions on when to build less/more adepts. For some reason it was causing certain civs to stop building completely in one or more of their cities. Since I removed this code, it has not happened since and I have no other references to Adepts/Mages at all any more. The AI still use them better than before but I dont strictly control how many they build any more. Not until I can come up with a better system or get this one working.
To Do:
- Specific Infernal/Mercurians AI. They wont do any worse, they just dont have as many instructions as all the other civs.
- Perhaps a more predictive rather than reactive approach in the AI's behaviour. I may have them check their neighbours' attitudes and have them react based on that. If everyone around them is getting along nicely they can be more builder oriented, if everyone hates them then prepare for war. I think this approach would be better than a strict is/is not at war system. (Assuming neighbours' attitudes can be measured using Python!)
- More playtests, its difficult for me to assess where to go with this now until I review their performance more. Its much faster if I just watch the AI play but after recently witnessing an AI clash between Abashi the Black Dragon and Sphener, I think I might just play it a bit more now instead.
Download Version 2: