| General | Hosted Sites | Civ5 | CivRev | Civ4Col | Civ4 | Civ3 | Civ2 | Civ1 | Misc | Marketplace |
![]() |
|
|
Welcome to Civilization Fanatics' Center. You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support. |
|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Prince
Join Date: Dec 2005
Posts: 368
|
Better economic AI (V. 0.7 updated!)
This mod fixes most of the bad AI economic behavior by forcing them to make good decisions. It consists 4 updated files: CvGameUtils.py, CvSpellInterface.py, CIV4SpellInfos.xml and PythonCallBackDefines.xml .
Installation Instructions: Simply unzip the zip file into your beyond the sword/mods folder. If you have modified your game, you should make a backup copy of your CvGameUtils.py, CvSpellInterface.py, CIV4SpellInfos.xml and your PythonCallBackDefines.xml files first. The mod is compatible with FFH2 patch 041g and earlier. Suggested settings: For best AI performance I recommend playing with aggressive AI, no Acheron and a Continents-, Lakes- or Pangeae- style map. Features: AI will efficiently spend its available hammers. AI will research Religion Founding techs if appropriate/worthwile. AI will optimally research worker techs in the early game. AI will use efficient civics/ is fully capable of running an aristocracy economy. AI will be forced to research midgame economic techs when appropriate. AI will no longer build forts or build workshops. AI will build a sufficient amount of warriors to defend itself in the very early game. AI will not suffer an economic crash anymore. AI will intelligently use advanced religion beelines to late game heroes. AI will be better able to capture cities AI will better use unique buildings ( Warrens and Governors Manors in particular) Luchuirp tech and build AI improved (hello fireball spamming golems) AI will build mana nodes somewhat intelligently New in 0.7 AI world spell casting improved AI will somewhat adjust its research/production decisions if they are at war. AI can now cast most spells properly, most notably: Crew promotions, feasting, Pirate Coves AI research decisions greatly improved AI production improved, AI will now build heroes and wonders very quickly. AI military production improved, AI will now build one tier2 enabling building in each city AI will build appropriate numbers of adepts (depending on available spells and traits) AI worker building tweaked, AI improves its land now very quickly. AI will aggressively spread and adopt religions of which it has the holy city Civ specific: Illian AI understands when to build their temple of the hand Kuriotates AI will not build settlers after they have reached their max number of allowed cities, drastically improving their AI. It should be easy to use the changes for other mods as I have only modified the following functions in CvGameUtils.py: 1. canbuild 2. cannotResearch 3. cannotDoCivic 4. cannotTrain 5. cannotConstruct 6. cannotCreate 7. AI_chooseTech 8. AI_chooseProduction (new in 0.6) The changes to the Spellfiles should be easily findable with winmerge. The main part of the mod is in CvGameutils.py anyway. Of course I also needed to activate the canbuild and cannotDoCivic functions in PythonCallBackDefines.xml. How much do these changes improve the AI? Check out this screenshots of a Pangeae noble game with aggressive AI, all unique features and no Acheron enabled: Without Changes: Spoiler:
With Changes: Spoiler:
Note the religious diversity (Sandolphon follows Esus), the rather scary Calabim stack and the scores of the top3 civs. Last edited by Turinturambar; Sep 12, 2009 at 08:39 AM. Reason: Updated! |
|
|
|
|
|
#2 |
|
Lord of the Dance
Join Date: Jun 2008
Location: Fane of Lessers
Posts: 1,033
|
I just tested out a game and the AI looks pretty good. Could I use this in Rise of Darkness?
__________________
Rise of Darkness Plus Ruins of Amur: A Dungeon AdventureMember: Fallen Ages - A Journey through the Ages FFH (Download) (Forum) (Wiki) "*Applause.* Aye, there you go! The floor is yours! Please, don't hurt anyone. Too much. Unless it'd be funny."-KillerClowns |
|
|
|
|
|
#3 |
|
Prince
Join Date: Dec 2005
Posts: 368
|
Sure!
I just looked over the changelog for your mod and I couldn't see any compatibilty issues with the changes I made. |
|
|
|
|
|
#4 |
|
WM junkie
Join Date: Dec 2005
Location: Seyda Neen, Vvardenfell
Posts: 7,090
|
awesome!
__________________
" Sheelba does what Charadon't " - Senethro |
|
|
|
|
|
#5 |
|
Warlord
Join Date: Apr 2009
Posts: 271
|
Extremely good work, especially as I was going to be looking at this next (early worker techs in particular) and was trying to figure out a good way to do it. Looks like your results are rather impressive (though it would be nice to be able to see the leaders' scores on the right hand side).
|
|
|
|
|
|
#6 |
|
Overlord
Join Date: Mar 2007
Location: The cutest of cephalopods
Posts: 1,726
|
Monarch, Normal Speed, turn 200:
Top 3 are Beeri Bawl: 1350 Decius of Bannor: 925 Ethne: 800 They're so good at getting gold I would suggest making a custom difficulty level which has raised unit maintenance and unit upgrade costs (i.e. 50% instead of 25%) just to soak up some of their excess. |
|
|
|
|
|
#7 |
|
Warlord
Join Date: Apr 2009
Posts: 271
|
A minor criticism:
Code:
if eBonus == gc.getInfoTypeForString('BONUS_GOLD'):
imining = imining +1
if eBonus == gc.getInfoTypeForString('BONUS_GEMS') :
imining = imining +1
if eBonus == gc.getInfoTypeForString('BONUS_DYE') :
icalendar = icalendar +1
if eBonus == gc.getInfoTypeForString('BONUS_INCENSE') :
icalendar = icalendar +1
You're also not taking into account whether the bonus is blocked by a terrain feature. If you're not an elven civ and you have a calendar resource in a forest, you'll need mining first regardless. If the resource is in a jungle square (common with both dyes and gems), you'll need bronze working before it's useful. |
|
|
|
|
|
#8 | |
|
Prince
Join Date: Dec 2005
Posts: 368
|
Quote:
covered by Forest (Silk). Elven civs default to researching calendar before mining anyway (unless gold/gems are present). Since the code only checks for the Capital and the Capital gets dejunglified in standard mapscripts I don't need to check for features. Wine is also only a marginal resource commercewise. +2 commerce does not make a noticeable difference, however I could see that beelining crafting could be sensible for 2+ wine. However crafting is forced very early anyway in the mining beeline, so it's not as if it goes unimproved for long. Edit: Come to think of it beelining Crafting makes sense as both a food and a commerce tech, so I will include a check for wine resources and force it as first tech if there are 2+ wine resources. Last edited by Turinturambar; Jun 08, 2009 at 06:23 AM. |
|
|
|
|
|
|
#9 |
|
Deity
Join Date: Sep 2008
Posts: 4,284
|
Very interesting changes. I'm eager to start a game with those
![]() (as Cyther, I may end up using them in my own modmod... which, being Orbis, will need a bit of tweak; I hope you wouldn't mind?) |
|
|
|
|
|
#10 | ||||
|
Warlord
Join Date: Apr 2009
Posts: 271
|
Quote:
Also, from a brief look at your code, only the Ljosalfar are hardcoded to pick calendar over mining, not the Svarts (unless I'm missing something obvious). Quote:
Quote:
Quote:
|
||||
|
|
|
|
|
#11 | |||
|
Prince
Join Date: Dec 2005
Posts: 368
|
Quote:
Quote:
If you farm the cotton resources before aquiring calendar and chop forests/build mines earlier, you will have get your settlers/warriors/workers out faster and work more and better tiles than 2/0/3 cottons. Quote:
I have never seen this and I think I read somewhere that the AI is hardcoded to settle its first city immediately. Regardless it would be such a rare case and would not have especially bad consequences if it happens that I don't think adding more checks is sensible. |
|||
|
|
|
|
|
#12 |
|
The Tallest Lilliputian
Join Date: Aug 2006
Location: Heavensent
Posts: 650
|
I see no improvement in Life Expectancy with these changes! Useless!
I mean, great work XD Going to dump this into an FFPlus install and see what happens.
__________________
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine.” - A very ironic statement by Nikola Tesla, the real inventor of electricity! "In war, truth must always be accompanied by a bodyguard of lies." -- Winston Churchill Last edited by Quetz; Jun 08, 2009 at 10:26 AM. |
|
|
|
|
|
#13 | |
|
Warlord
Join Date: Apr 2009
Posts: 271
|
Quote:
|
|
|
|
|
|
|
#14 |
|
Deity
Join Date: Sep 2008
Posts: 4,284
|
Can I suggest that you comment your changes? It's a bit hard to see what's part of vanilla and what's yours. Of course, using WinMerge, for example, is useful but... commenting is handy too
|
|
|
|
|
|
#15 |
|
Deity
Join Date: Sep 2008
Posts: 4,284
|
Line 303: SHEIAM instead of SHEAIM
In fact, it seems you did this mistake more than once... I begin to doubt it's a mistake, now... Why only prevent some civs to build disciples? I mean, if you have a religion Holy City, even though you're not Sheaim, Bannor or whatever, you should spread it, no? Okay, done reading thoroughly your code. Really interesting things in it. It will be a bit tricky to adapt it to Orbis but I'll do it. Congratulations for that, you thought of many things
|
|
|
|
|
|
#16 | |
|
Prince
Join Date: Dec 2005
Posts: 368
|
Quote:
I wanted to make it so that only civs with the Holy cities or the civs which are attuned to the religion build disciples, so that everyone else doesn't waste hammers. In addition this should slow down the spread of religions, leading to more diversity. Corrected Code looks like this: Code:
if eUnitClass == gc.getInfoTypeForString('UNITCLASS_DISCIPLE_THE_ASHEN_VEIL'):
if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DISCIPLE_THE_ASHEN_VEIL')) > 3:
return True
if pPlayer.hasHolyCity(gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL')) == False :
if not pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM') :
return True
Last edited by Turinturambar; Jun 08, 2009 at 01:29 PM. |
|
|
|
|
|
|
#17 |
|
Deity
Join Date: Sep 2008
Posts: 4,284
|
Oh, right. So you want that no civ (apart from attuned ones and holy-city ones) manually spread religions? That's interesting. I remember this, manual spreading through disciples, being a huge factor in non-religiously-diverse games. Thanks for explaining that
![]() By the way, it's really hard to import this to a modmod which change many techs Cartography is much less valuable in Orbis (it's Writing that leads to Open Borders) and Exploration just doesn't exists!
|
|
|
|
|
|
#18 |
|
Deity
Join Date: Sep 2008
Posts: 4,284
|
I've been tweaking your religions check in AI_chooseReligion and came up with that:
Code:
####-----###
## Religion beelines
####-----###
iLeader = gc.getLeaderHeadInfo(pPlayer.getLeaderType())
iFlavor = ileader.getFlavorValue(gc.getInfoTypeForString('FLAVOR_RELIGION'))
iFoL = gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES')
## FoL
if iLeader.getReligionWeightModifier(iFoL) >= 0:
if eTeam.isHasTech(gc.getInfoTypeForString('TECH_MYSTICISM')) \
or eTeam.isHasTech(gc.getInfoTypeForString('TECH_TRACKING')) \
or pPlayer.getNumCities() > 3:
iDiceFoL = CyGame().getSorenRandNum(100, "FoL")
if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
iDiceFoL += 30
if iLeader.getFavoriteReligion() == iFoL:
iDiceFoL += 30
if iFlavor != 0:
iDiceFoL += iFlavor
if iDiceFoL <= iLeader.getReligionWeightModifier(iFoL):
iTech = gc.getInfoTypeForString('TECH_WAY_OF_THE_FORESTS')
|
|
|
|
|
|
#19 |
|
Prince
Join Date: Dec 2005
Posts: 368
|
I really like how religionfounding turned out in my mod. All civs have the possibility of founding religions, not just the attuned ones. In fact they regularly get beaten, but will still research the appropriate techs.
It works like this: If the AI has researched the proper economic techs for its current economic situation and has researched Mysticism (Philosophy for the advanced religions) and has established initial settling (>= 3 cities), the AI will beeline one of the early religions under the following conditions: 1) It does not have a holy city already (doing so under these circumstances would be wasteful and would lead to less religious diversity) 2) The religion has not been founded yet. (again to promote diversity) 3) The civ is not attuned to a specific religion (e. g. the Sheaim don't waste their research on chasing octopus overlords, because they will research Ashen Veil later on anyway.) 4) The civ rolls a 5 or 6 on a six-sided die. (This ensures that different religions get chased by the nonattuned civs,leading to more efficiency and diversity) 5) The alignment fits, meaning no civ will research a religion that shifts it alignment by 2 steps (from good to evil or vice versa) or shifts the alignment to neutral. Each religion has one civ that is attuned to it for flavour/gameplay reasons. Those civs can research the other religious techs, but they are never forced to do so. Once they pass the requirements for their preferred religion they will beeline it. Adding religious flavours to the random roll could be desirable, but I'm not sure if it will have a noticeable effect. |
|
|
|
|
|
#20 |
|
One of Many
Join Date: Mar 2008
Location: Classified.
Posts: 340
|
I've just gotta say, Turin, you've done a GREAT job with this AI mod! Now I can finally get better at Civ while still staying at Noble difficulty!
Thank you, Turin!
|
|
|
|
![]() |
| Bookmarks |
| Tags |
| ai improvement, ffh2, mod |
|
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AI commits economic suicide | Thalassicus | Civ4 - Bug Reports | 1 | Aug 13, 2007 09:21 PM |
| What's going to be the fifth economic civic? | kolpo | Civ4 - General Discussions | 35 | Oct 21, 2005 06:27 PM |
| Economic Victory? | DrMadd | Civ - Ideas & Suggestions | 20 | Oct 19, 2005 05:56 AM |
| Economic Systems | Teabeard | Civ - Ideas & Suggestions | 5 | Oct 28, 2004 06:18 PM |
| The Economic Miracle | blitzy | Civ2 - Strategy & Tips | 12 | Nov 14, 2000 08:28 AM |