HOW TO force AI build new buildings

Its a difficult Probmen.

You can try to use the old ways that are implemented or use some alternative things (farther down).

Old Ways: You have to consider the following:

The AI builts buildings not after their flavours but after its use.
Eg. First it wants to build something that gives culture. It checks all buildings which give culture and does then some valuing between those buildings and chooses the best one. If the city alreadz has a culture building it checks for the next thing. EG if its maintaince is greater than 6 gold. If that is true it builds a building reducing maintaince and so on.

So to get the Ai to even consider the building it has to have worth in a specific area the AI recognizes.
Alternativeley you can add another area that the AI checks. (I have code for this for FfH wher buildings are needed to produce some troops.)
Therfor you will have to look in CvCityAI.cpp:
AI_chooseProduction(),
AI_chooseBuilding() and
AI_bestBuilding()

Alternative Way: is to force the AI to built a building via Python. The problem with that is that you can easily cripple the AI in that way, eg when you force it to built a building alwas first in a city and this buildings in not good there or needs several hundred turns to be constucted or similar things.
The function you are looking for in Python would be: AI_chooseProduction

Ther emight be of course other ways as well but those two are the ones that came to my mind first.
 
for the mod i do and use, we configure the AI in dll with SDK..;
the AI actually build city in water (it was the problem for my mod), at the begining, AI didn't use settler_sea...
I think it's the same way for building, you had to teach the AI in dll...

for more information about dll configuration, ask Major, with mail, not pm...
http://forums.civfanatics.com/member.php?u=70413
 
Well, I suppose it could be done in XML (CIV4BuildingInfos).

1) iAIWeight - to make this building more important for AI players.

and 2) Flavors - to make this building important for every flavor.
 
k, i was testing my game with new building yesterday evening. i gave it flavours to production and military ( to let AI think it's good for both ).
and AI finaly started to build it but didn't really rush for it :((((

<Flavors>
<Flavor>
<FlavorType>FLAVOR_MILITARY</FlavorType>
<iFlavor>10</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_PRODUCTION</FlavorType>
<iFlavor>10</iFlavor>
</Flavor>
</Flavors>
 
Chalid said:
That does not work as it might seem Nevermind. The flavours and AI weight come only into play if the AI has decided which kind of building it wants to generate.

Oh, I see. AI treats these tags as secondary factors. How stupid of him! :D
 
@Max. Would it be unbalancing if you give the building another ability. For example +1XP or +1% city defense? this way you could trick the Ai into considering the building earlier (as it would be valid as defensive or XP building). And then bump those FLAVOURS up to 20 or 30. This might work.
 
Im not sure if Im reading this thread right... but it seems odd to me...

I invented several new buildings and the AI builds them...sometimes right away...

I even put in new nation and world wonders and the AI builds them too

sometimes much quicker then I'd like :rolleyes:

I basically modified all the buildings/wonders off of existing ones (just changing the XML stats to make it more "unique" then existing vanilla verisons)

I only change/edit XML files... (works better in MP)

at first it sounded like the buildings were missing from the buildingclassinfos.xml file because that file determines whetther a building is a regular building/national/world wonder... and therefore determining whether you can build it once for the world/once for the civ/unlimited (one per city that is) ....

however then I read this:


MaxRiga said:
k, i was testing my game with new building yesterday evening. i gave it flavours to production and military ( to let AI think it's good for both ).
and AI finaly started to build it but didn't really rush for it :((((


so that probably was not the case... :(

I dont know too much about this stuff... but I'd like to help if I can...

were your new buildings based off an existing one?

what files did you edit to add your buildings?

what characteristics (tagline input) did you use?

I am really curious because I have also made buildings that are required to make certain troops....and want to know if I get the same problem! :blush:


(I havent play test to modern era that often (that's where my troop buildings come into play) because I am correcting any problems that arise and most of the time I have to restart before I get to those buildings)
 
Officer thx for willing to help
this is taken from buildinginfos.xml

BuildingInfo>
<BuildingClass>BUILDINGCLASS_HEAVYDOCK</BuildingClass>
<Type>BUILDING_HEAVYDOCK</Type>
<SpecialBuildingType>NONE</SpecialBuildingType>
<Description>HEAVYDOCK</Description>
<Civilopedia>TXT_KEY_BUILDING_HEAVYDOCK_PEDIA</Civilopedia>
<Strategy>TXT_KEY_BUILDING_HEAVYDOCK_STRATEGY</Strategy>
<Advisor>ADVISOR_MILITARY</Advisor>
<ArtDefineTag>ART_DEF_BUILDING_HEAVYDOCK</ArtDefineTag>
<MovieDefineTag>NONE</MovieDefineTag>
<HolyCity>NONE</HolyCity>
<ReligionType>NONE</ReligionType>
<StateReligion>NONE</StateReligion>
<PrereqReligion>NONE</PrereqReligion>
<GlobalReligionCommerce>NONE</GlobalReligionCommerce>
<VictoryPrereq>NONE</VictoryPrereq>
<FreeStartEra>NONE</FreeStartEra>
<MaxStartEra>NONE</MaxStartEra>
<ObsoleteTech>NONE</ObsoleteTech>
<PrereqTech>TECH_INDUSTRIALISM</PrereqTech>
<TechTypes/>
<Bonus>BONUS_IRON</Bonus>
<PrereqBonuses/>
<ProductionTraits>
<ProductionTrait>
<ProductionTraitType>TRAIT_AGGRESSIVE</ProductionTraitType>
<iProductionTrait>100</iProductionTrait>
</ProductionTrait>
</ProductionTraits>
<PowerBonus>NONE</PowerBonus>
<FreeBonus>NONE</FreeBonus>
<iNumFreeBonuses>0</iNumFreeBonuses>
<FreeBuilding>NONE</FreeBuilding>
<FreePromotion>NONE</FreePromotion>
<CivicOption>NONE</CivicOption>
<GreatPeopleUnitClass>NONE</GreatPeopleUnitClass>
<iGreatPeopleRateChange>0</iGreatPeopleRateChange>
<bTeamShare>0</bTeamShare>
<bWater>1</bWater>
<bRiver>0</bRiver>
<bPower>0</bPower>
<bDirtyPower>0</bDirtyPower>
<bAreaCleanPower>0</bAreaCleanPower>
<bDiploVote>0</bDiploVote>
<bForceTeamVoteEligible>0</bForceTeamVoteEligible>
<bCapital>0</bCapital>
<bGovernmentCenter>0</bGovernmentCenter>
<bGoldenAge>0</bGoldenAge>
<bMapCentering>0</bMapCentering>
<bNoUnhappiness>0</bNoUnhappiness>
<bNoUnhealthyPopulation>0</bNoUnhealthyPopulation>
<bBuildingOnlyHealthy>0</bBuildingOnlyHealthy>
<bNeverCapture>0</bNeverCapture>
<bNukeImmune>0</bNukeImmune>
<bPrereqReligion>0</bPrereqReligion>
<bCenterInCity>0</bCenterInCity>
<iAIWeight>1</iAIWeight>
<iCost>280</iCost>
<iHurryCostModifier>0</iHurryCostModifier>
<iMinAreaSize>20</iMinAreaSize>
<iConquestProb>66</iConquestProb>
<iCitiesPrereq>0</iCitiesPrereq>
<iTeamsPrereq>0</iTeamsPrereq>
<iLevelPrereq>0</iLevelPrereq>
<iMinLatitude>0</iMinLatitude>
<iMaxLatitude>90</iMaxLatitude>
<iGreatPeopleRateModifier>0</iGreatPeopleRateModifier>
<iGlobalGreatPeopleRateModifier>0</iGlobalGreatPeopleRateModifier>
<iAnarchyModifier>0</iAnarchyModifier>
<iGlobalHurryModifier>0</iGlobalHurryModifier>
<iExperience>0</iExperience>
<iGlobalExperience>0</iGlobalExperience>
<iFoodKept>0</iFoodKept>
<iAirlift>0</iAirlift>
<iAirModifier>0</iAirModifier>
<iNukeModifier>0</iNukeModifier>
<iNukeExplosionRand>0</iNukeExplosionRand>
<iFreeSpecialist>0</iFreeSpecialist>
<iAreaFreeSpecialist>0</iAreaFreeSpecialist>
<iGlobalFreeSpecialist>0</iGlobalFreeSpecialist>
<iMaintenanceModifier>0</iMaintenanceModifier>
<iWarWearinessModifier>0</iWarWearinessModifier>
<iGlobalWarWearinessModifier>0</iGlobalWarWearinessModifier>
<iHealRateChange>0</iHealRateChange>
<iHealth>0</iHealth>
<iAreaHealth>0</iAreaHealth>
<iGlobalHealth>0</iGlobalHealth>
<iHappiness>0</iHappiness>
<iAreaHappiness>0</iAreaHappiness>
<iGlobalHappiness>0</iGlobalHappiness>
<iStateReligionHappiness>0</iStateReligionHappiness>
<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
<iMilitaryProductionModifier>0</iMilitaryProductionModifier>
<iSpaceProductionModifier>0</iSpaceProductionModifier>
<iGlobalSpaceProductionModifier>0</iGlobalSpaceProductionModifier>
<iTradeRoutes>0</iTradeRoutes>
<iCoastalTradeRoutes>0</iCoastalTradeRoutes>
<iGlobalTradeRoutes>0</iGlobalTradeRoutes>
<iTradeRouteModifier>0</iTradeRouteModifier>
<iGlobalPopulationChange>0</iGlobalPopulationChange>
<iFreeTechs>0</iFreeTechs>
<iDefense>0</iDefense>
<iAllCityDefense>0</iAllCityDefense>
<iAsset>1</iAsset>
<iPower>2</iPower>
<fVisibilityPriority>1.0</fVisibilityPriority>
<SeaPlotYieldChanges/>
<GlobalSeaPlotYieldChanges/>
<YieldChanges/>
<CommerceChanges/>
<ObsoleteSafeCommerceChanges/>
<CommerceChangeDoubleTimes/>
<CommerceModifiers/>
<GlobalCommerceModifiers/>
<SpecialistExtraCommerces/>
<StateReligionCommerces/>
<CommerceHappinesses/>
<ReligionChanges/>
<SpecialistCounts/>
<FreeSpecialistCounts/>
<CommerceFlexibles/>
<CommerceChangeOriginalOwners/>
<ConstructSound>AS2D_BUILD_DRYDOCK</ConstructSound>
<BonusHealthChanges/>
<BonusHappinessChanges/>
<BonusProductionModifiers/>
<UnitCombatFreeExperiences/>
<DomainFreeExperiences/>
<DomainProductionModifiers/>
<BuildingHappinessChanges/>
<PrereqBuildingClasses/>
<BuildingClassNeededs/>
<SpecialistYieldChanges/>
<BonusYieldModifiers/>
<Flavors>
<Flavor>
<FlavorType>FLAVOR_MILITARY</FlavorType>
<iFlavor>10</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_PRODUCTION</FlavorType>
<iFlavor>10</iFlavor>
</Flavor>
</Flavors>
<HotKey/>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>0</iHotKeyPriority>
</BuildingInfo>

i think this can explain everything :))
 
I would recommend giving it +1 XP for DOMAIN_WATER units and an FLAVOUR_MILITARY of 25. Right now the AI will only start building it when it has built most of the other buildings, as it has no advantage that the AI can see.
 
I'll have to look at it tomorrow.... busy modding myself ;)

but is the CIV4BuildingClassInfos.xml edited correctly too?

maybe you can post that entry for that building too :D

i'll check it out later :mischief:

but be warned I only know that my buildings work...

I am fairly familiar with XML but not the best or brightest modder here :D
 
This seems like an interesting topic. I'm curious to know more, myself. How does the AI know what to build? It would be pretty lame if they hardcoded some kind of build order. Is the 'flavors' stuff in the xml the main thing?
 
They semi-Hardcoded some kind of build order.

Its as i wrote. First it chwcks if the city does generate Culture and if not, they check if it can built an Culture Building in below 30 turns or something.
Than it checks how much production it has and if it is enough it builds a building that increases production (like forge, if it can built it in 20 turns or so)
Than it checks how much maintenance that city costs...
and so forth. There is a real long list of jobs that the buildings can have...
Thats not the exact order but i think it can provide an idea how it works.

If it has decided it wants to build a special kind of building it seraches all buildings for how good they are for the selected job of the building. Thats the point were the AI_Weights are considered.
 
Chalid said:
They semi-Hardcoded some kind of build order.

Its as i wrote. First it chwcks if the city does generate Culture and if not, they check if it can built an Culture Building in below 30 turns or something.
Than it checks how much production it has and if it is enough it builds a building that increases production (like forge, if it can built it in 20 turns or so)
Than it checks how much maintenance that city costs...
and so forth. There is a real long list of jobs that the buildings can have...
Thats not the exact order but i think it can provide an idea how it works.

If it has decided it wants to build a special kind of building it seraches all buildings for how good they are for the selected job of the building. Thats the point were the AI_Weights are considered.


well if we can find out the exact order which the AI's check list we can then tailor our buildings to the the AI's priority...

...since it is hard-coded and cannot be changed by normal means :sad:


this would be really helpful to balance game play with custom stuff :blush:
 
so how'd you finally get it to work?

military flavour 25


There is a real long list of jobs that the buildings can have...

i also believe that every civilization needs it's own buildings, so, actually i think it's pretty hard to force all civilizations build same stuff. from another way all civs are trying to build wonders as fast as possible ...
 
Top Bottom