Advanced Civ

@PieceOfMind: Thanks for the kind words; great that you're liking the mod. Yeah, some of your balance changes have stuck around, I guess most prominently the +1 Farm commerce from Serfdom. (At least it's my guess that karadoc adopted that from PIG.) If any AdvCiv change bothers you (particularly), I'd of course be interested to know about it.
Will do. I just noticed last night the addition of 6 first strikes to subs, the swapping of the two subs in the tech tree and rename etc. Very interesting. My current game has been very land based (and prob heading for space victory) so haven't really got to try them out though.
I feel like the civics have some more interesting choices, particularly the Economy ones.
Regarding AI, I feel like this game I've noticed a lot of times those annoying 1 tile away from coast cities. My guess is a lot of these were due to preferring to settle on hills for defensive reasons. But during some conquests I was razing some of the smaller cities that I wanted to settle 1 tile away so it was on coast. Was especially important because playing as Carthage my UB benefited from being coastal.
It also feels like the first time in ages that late game I was seriously having to think hard about keeping windmills instead of mines. I've lost track of where these changes originated or if they were even vanilla but I think it's down to the windmill getting +1 hammer at Replaceable Parts. That caused me to build a lot of them.

This squares with the previous bug report, where Great Artist had greatly inflated odds. When the projected odds don't add up to 100, my v0.96 code adds 100 minus the sum to the GP with the lowest unit id – among those GP for which any progress has been made. Great Prophet has the lowest id among GP; the next lowest is Great Artist. So I'm hopeful that this is just a display bug and already fixed in the nightly builds. (Which would mean that the first Great Prophet was just bad luck coinciding with the display issue.) Please note that the version Elkad linked to is at best a beta version; it may have worse problems than spurious GP odds.
Yeah, probably was just bad luck. Missed out on founding Mining Inc because of that first great prophet which is why I'd been watching it in the first place. The second time the GP pool was much less contaminated which made it easier to tell something was up.
 
Ironclad upgrades to destroyer, but an ironclad in the queue when you finish combustion (actually when i hooked oil a turn later) is just lost hammers. Don't think it's supposed to be that way?
I think this always happens when a unit goes obsolete through connecting a resource. Will fix.
I just noticed last night the addition of 6 first strikes to subs, the swapping of the two subs in the tech tree and rename etc. Very interesting. My current game has been very land based (and prob heading for space victory) so haven't really got to try them out though.
I haven't really played with it either tbh. It's one of those things that I probably wouldn't have touched if K-Mod hadn't already modified it. (The K-Mod change was +25% attack, implemented as +25% Coast attack and +25% Ocean attack.)
It also feels like the first time in ages that late game I was seriously having to think hard about keeping windmills instead of mines. I've lost track of where these changes originated or if they were even vanilla but I think it's down to the windmill getting +1 hammer at Replaceable Parts. That caused me to build a lot of them.
Had to look it up too; it's actually been like that since the Vanilla release:
+1 F, +1 C initially; +1 P from RP; +1 C from Electricity; +2 C from Environmentalism.
I guess the main reason why Railroad Mines (+3 P) would supplant (some) Windmills is that Biology makes food abundant at a time when bad health is becoming an issue. And the production modifier from Factory. It might be that the mod indirectly changes that balance a bit. For one thing, late-game tech costs are higher; that could make the extra commerce from Windmills more valuable.
Regarding AI, I feel like this game I've noticed a lot of times those annoying 1 tile away from coast cities. My guess is a lot of these were due to preferring to settle on hills for defensive reasons. But during some conquests I was razing some of the smaller cities that I wanted to settle 1 tile away so it was on coast. Was especially important because playing as Carthage my UB benefited from being coastal.
I've tweaked the evaluation of sea access for v0.97, but the AI still isn't going to be as worried as in BtS/K-Mod about having bad tiles (such as 1-food coast) in the city radius and not as interested in sea access. BBAI especially had added generous found value bonuses to coastal sites (comment "Push players to get more coastal cities so they can build navies"), which K-Mod and AdvCiv have been scaling back -- perhaps too much. Was it by any chance a Protective AI leader? K-Mod has given those a special preference for hill sites.
 
I've tweaked the evaluation of sea access for v0.97, but the AI still isn't going to be as worried as in BtS/K-Mod about having bad tiles (such as 1-food coast) in the city radius and not as interested in sea access. BBAI especially had added generous found value bonuses to coastal sites (comment "Push players to get more coastal cities so they can build navies"), which K-Mod and AdvCiv have been scaling back -- perhaps too much. Was it by any chance a Protective AI leader? K-Mod has given those a special preference for hill sites.
2 from Pericles and 2 from Sitting Bull (Protective), though one of Sitting Bull's was the capital so doesn't really count.

I think the windmill thing this game was more noticeable because of the lack of food. I was near the Tundra area with few rivers (so a lot of spots I couldn't farm) and pretty much the only spots with good food resources were the capital cities captured. Also playing as Carthage there's somewhat more incentive to grow cities higher so as to work more cottages and get higher valued trade routes. So perhaps something fairly unique to this playthrough.
 
Attached: the 9th nightly/ pre-release build. (Edit: no longer the latest) Fixes ...
- trade route assignment,
- cancellation of obsolete unit production orders,
- hidden player identities in Event Log (Rise & Fall option),
- minor info leak in GP birth messages.
(Anyone updating a Python/XML mod-mod along with these builds: see the list of files changed since #8 on GitHub.)

2 from Pericles and 2 from Sitting Bull (Protective), though one of Sitting Bull's was the capital so doesn't really count.
Settling the capital one away from the coast is a bit ... unsettling. Probably the values are a little off. I'll keep an eye out in my own tests.
I think the windmill thing this game was more noticeable because of the lack of food. [...]
Sounds plausible.
 

Attachments

  • AdvCiv_v0.97pre9.zip
    10.5 MB · Views: 122
Last edited:
@f1rpo: I got 200ish turns into a game, and all terrain (land and sea) became impassible, to me and at least one other AI. (I assume, to everyone.) After that, previous saves made with the same release developed the same behavior on load. Saves made with previous versions are still fine. Quitting to desktop and re-opening does not fix the issue with the effected saves.

There's a small but non-zero chance that I botched the unzip-over operation this time, so one thing we could try is you post an all-in-one version, and I install that and see what happens.

Also, CvReplayInfo.cpp has an unmatched open parenthesis on line 173.

Edit: Using WB to change a tile (add/remove fallout, change base terrain or topography) makes the affected tile passable, but saving and loading makes it impassible again. So the impassibility itself isn't being saved, but whatever's causing it is, and on load the tiles are set to impassible.
 

Attachments

  • after-6.CivBeyondSwordSave
    130.5 KB · Views: 116
Last edited:
Settling the capital one away from the coast is a bit ... unsettling. Probably the values are a little off. I'll keep an eye out in my own tests.
Spoiler :

I've tried to highlight two cities from Pericles that I razed.

Sitting Bull's capital only has one coastal tile in its radius so it's not that bad. I just was sad to not being able to get any coastal trade routes later in the game when it became my largest pop city.
 
I got 200ish turns into a game, and all terrain (land and sea) became impassible, to me and at least one other AI. [...]
Two booleans were switched when reading savegames – one of them being the impassable flag that I had just added for performance reasons. Embarassing. I did test it, just didn't notice that tiles became impassable after loading. (Also ran several AI Auto Play games actually.) I've reuploaded the archive in my previous post. The included DLL should be able to correctly load all your saves except those that had been saved, loaded and saved again, all with the broken DLL.
Also, CvReplayInfo.cpp has an unmatched open parenthesis on line 173.
There? Compiles just fine for me ...

@PieceOfMind: Thanks. That western razed Greek city is in a pretty terrible spot in general. I wonder how that came about; might have to do with Athens and Cahokia being very close together. I would assume that Poverty Point was founded earlier, meaning that SiBu could've settled one farther west. (Settling at the coast wasn't really an option.) The other razed city: I guess that should've been one farther east (at the coast). For Cahokia, there would've been better spots farther inland, but, if SiBu moved his settler, he may not have had full visibility. It's, unsurprisingly, difficult to say where the AI went wrong exactly, but I agree that it probably did go wrong.
 
The included DLL should be able to correctly load all your saves except those that had been saved, loaded and saved again, all with the broken DLL.
Works as described. Thanks!

There? Compiles just fine for me ...
Ah, I see what happened. The diff you linked compares an earlier state to a later one, describing the time-inverse of the actual change. So, there was an unmatched paren at one point, but you'd already fixed it.
 
Ah, I see what happened. The diff you linked compares an earlier state to a later one, describing the time-inverse of the actual change. So, there was an unmatched paren at one point, but you'd already fixed it.
Oh. I hadn't paid attention to the order of the two commits in the comparison. That's pretty confusing. I'll edit the link. At least the list of modified files is correct either way.
 
f1rpo, (or keldath or whoever).
Anyone ever looked at optimizing workers building rails? Seems like they just randomly pick a nearby square, even if it's a useless desert tile.

Should be working on linking cities, and getting rails on tiles that benefit (mines/mills) first.
 
pre9
Attacking a city. Sent my trebs first for collateral. At the end it stopped showing retreat chance, but would still let my trebs attack, so I sent one more anyway.
There are still land units in the city.


capture.jpg
 
Hey Elkad,
I havnt chabged advc core (mostly) code, so sorry, no.

As for tge trebuchet attacking sea units over land, i had seem strange stuff with siege units picking strange best defenders. I made some changes to that with the ranged attack im working to incorporate in my Doto.
 
Anyone ever looked at optimizing workers building rails? Seems like they just randomly pick a nearby square, even if it's a useless desert tile.

Should be working on linking cities, and getting rails on tiles that benefit (mines/mills) first.
(For reference, from December ...)
Automated railroad construction could use help as well. It's far more useful to team up on rail builds. And they should prefer railroading tiles that get a bonus (mines) first. Then connect all cities by rail. Only after that should they be putting rails on random tiles. (If I need the city connections first, I'm probably micromanaging my workers anyway)
I've taken a look now. As for connecting cities, the AI mainly relies on the trade network. By the time Railroad is discovered, all cities are of course already connected through the trade network. Each AI city stores a "route-to" city though, which is the closest (air distance) city of the same owner on the same landmass for which there is no route connection yet. To my surprise, the AI does distinguish between roads and railroads here once railroads can be built. So that's the extent to which the AI is aware of a railroad network.

The worker routines for improving terrain near cities don't seem to take railroads into consideration. That would come down to CvCityAI::AI_updateBestBuild; I guess that only handles improvements and chopping. So, apparently, the only routines that build railroads are AI_routeTerritory and AI_routeCity, both pretty low priority.

AI_routeTerritory looks for the nearest improvement that would gain production from a railroad and that no other worker is already headed for, and then builds a railroad from the worker's current tile to that target improvement. AI_routeCity (lower priority than AI_routeTerritory) builds a railroad from the worker's current tile to ... apparently simply the first city in the owner's city list (so basically the oldest city) that no other worker is taking care of already. Once that railroad is done, the worker moves into the target city and proceeds to build a railroad to the route-to city of that city.

Perhaps the worst thing about this is that the workers always start railroading from where they stand. Might be inspired by the idea that there should be roads where people naturally walk. :)

Attacking a city. Sent my trebs first for collateral. At the end it stopped showing retreat chance, but would still let my trebs attack, so I sent one more anyway.
I had noticed and fixed this for civilian units; apparently non-land units also need to be explicitly made ineligible as defenders in this situation, i.e. when all land defenders are maximally damaged. Will fix.
 
Draft of the v0.97 release notes. This post might trigger alerts for a bunch of users that are being credited. I hope they don't mind.
Spoiler :
The only major novelty is an overhaul of city trades. Please refer to the manual (p.9) for a summary. Short summary: The AI is willing to trade with and for cities also at peacetime, still won't pay for liberation, may refuse to give up cities for various reasons, and civs need to have sufficient tile culture in order to receive a city.

The rest – lots of tweaks. Fully covered by the commit history from now (May 2020) back to late July 2019; the notes below omit the very minor ones.

The 48-civ DLL[link to be inserted] can now load scenarios created by an 18-civ DLL. More generally, scenarios should work so long as all civ ids in the WorldBuilder save are less than MAX_CIV_PLAYERS in the current DLL. [change id: advc.056]
The two DLLs still aren't savegame-compatible. (And won't be; but if I ever break backward compatibility, I might increase the maximal player count of the standard DLL to some number around 30 and stop providing multiple DLLs.)

Game rules
Spoiler :
Revert the K-Mod changes to German Assembly Plant (+2 production), French Musketeer (15% withdrawal chance), Celtic Dunn (+1 XP for melee units), Mining Inc. corporation (120% maintenance). I had overlooked these when I reverted other low-impact balance changes from K-Mod. Not worth deviating from BtS for I think, at least not until a full balance overhaul is implemented. [advc.200]

Culture and revolts: [advc.101]
• The culture garrison strength of a unit, i.e. its strength against revolts, is now equal to its combat strength with the following modifiers:
- Defensive modifiers (Archery units, Garrison promotions)
- Generic strength modifiers (Combat promotions)
- Minus 50% for non-lethal units (i.e. Siege except Machine Gun).​
Previously, culture garrison strength was determined by the iCultureGarrison values set in Civ4UnitInfos.xml. Those values (now obsolete) weren't shown anywhere in the game, so this change should make the impact of garrison units on revolt probabilitiy more transparent. The nationality bar shows how much garrison strength is needed for zero revolt chance; see under UI changes.
• Adjusted the foreign culture strength formula (the other factor that determines the revolt probability) to balance out the change to culture garrison strength, and to make revolts a bit easier to suppress in the midgame and a bit harder in the late game than in AdvCiv 0.96. Added two XML parameters for fine-tuning this: FOREIGN_CULTURE_STRENGTH_FACTOR and FOREIGN_CULTURE_STRENGTH_EXPONENT (AdvCiv\Assets\XML\GlobalDefines_advc.xml)
• Decreased the impact of hurry and draft anger on foreign culture strength. Details (Git commits 1 2), discussion
• Decreased the impact of game speed on revolt probability. Since culture spread isn't speed-adjusted, I think revolt probabilities should only be partially speed-adjusted. (K-Mod introduced the speed adjustment.)
• Reduced the culture spread range of cities onto other landmasses. This tweak to the K-Mod culture spread rules avoids puzzling border shapes when cities on two different landmasses spread culture onto a third landmass. [advc.098]
• Partisans event (bugfix?): The number of partisans is now equal to the culture level of the razed city's cultural owner, starting with 1 partisan unit at Fledgling culture. Razing a size-1 city never creates partisans (this part is definitely a bugfix). Adopted from @SmokeyTheBear (thread)

Maintenance, research costs:
• Lowered the number-of-cities maintenance modifier on Huge maps a little bit and added a crowdedness modifier to account for the initial player count and sea level. [advc.140]
• The city count in the formula for number-of-cities maintenance is now capped at ca. 40 cities. (This should only be relevant for Huge maps.) The cap can be adjusted through MAX_CITY_COUNT_FOR_MAINTENANCE (AdvCiv\Assets\XML\GlobalDefines_advc.xml). [advc.exp.1] Discussion
• Lowered Ancient-era tech costs by 5% if Tribal Villages are disabled. [advc.910]
• Increased tech costs in Always-Peace games by 5% after the Ancient era. [advc.910]
• Progress toward a tech makes that tech cheaper to steal through espionage. [advc.120i] Idea from the VIP mod

AI civs start with only one free Scout on Immortal. (Basically, I don't think additional exploration units are a good way to ramp up the difficulty. Earlier versions of AdvCiv have already taken away the second free Scout on Emperor, one of the free Archers on Immortal and Deity – and the free Settler on Deity.) [advc.250e]

Terrain features:
• Global Warming (GW) can no longer remove vegetation from Grassland, meaning that only vegetation on Plains can be removed by GW. (Though successive GW events can still remove e.g. a Tundra Forest by first turning the Tundra into Grassland and the Grassland into Plains.) The Grassland protection can be disabled through PROTECT_FEATURE_ON_NON_DRY_TERRAIN (AdvCiv\Assets\XML\GlobalDefinesAlt.xml). An earlier approach was to let Forest Preserve protect vegetation; that's also still possible; see under optional changes. [advc.055] Discussion
• A city can receive (positive) health or happiness from a terrain feature or improvement only if the city owner is able to peacefully enter the tile with the feature or improvement. Meaning that Forest Preserve no longer grants happiness and health to rival cities unless there is an Open Borders agreement. [advc.901]

Barbarians can appear on Plains Hill and Tundra Hill again. The criterion is, as before, a positive food yield, but the -1 food from hills is no longer counted. I think this captures the notion of habitable land better. [advc.300] And the Great Wall graphic is now placed in a way that avoids creating "Gaza strips" wedged between the Great Wall and some other obstacle. [advc.310]

Reverted a change that had prohibited cities with insufficient air capacity from producing air units. However, when a newly completed air unit gets force-moved due to exceeded air capacity, it now has to skip one turn. If a (legal) rally point is set, the unit gets moved there rather than to the nearest legal tile. [advc.001b] Discussion


Standard map generator: These changes affect most of the official map scripts. They don't apply if a map script overrides the respective part of the map generation process.
Spoiler :
Terrain: [advc.129c]
• Slightly increased the overall frequency of plains.
• Plains tend to clump together a bit more.
• Plains can occur in the +/-10 latitude region around the equator (typically covered by Jungle).
• Deserts have a tendency to appear next to plains.
• Increased the frequency of hills a tiny bit.
These changes should make the terrain slightly more Earth-like (tropical soils aren't well suited for food production) and varied without altering gameplay much. They can be disabled by setting bEarthlike to False at the start of AdvCiv\Assets\Python\CvMapGeneratorUtil.py.

Resources: [advc.129]
• Gold, Silver, Gems and Fur are no longer restricted to appear on only one landmass.
• Decreased the probability of Gold resources getting placed in a cluster.
• Resources that are (in principle) restricted to a single landmass can also get placed on multiple small landmasses (think of the Spice Islands).

Starting site optimization ("normalization"): [advc.108]
* The "Balanced resources" map option now causes more aggressive normalization of starting locations, essentially according to the BtS rules. In particular, unrevealed resources are taken into account when deciding how much work a site needs.
* Extra resources placed near starting sites are now considered in a random order instead of the order in Civ4BonusInfos.xml.
* Decreased probability of lake starts. (Should still be more likely than in BtS but not as likely as in K-Mod.)


savemap script by @xyx and @tywiggins for exporting the map of an ongoing game as a map script. More detailed description here. AdvCiv integration:
Spoiler :
• Shortcut: Alt+Shift+M (can be disabled on the BUG menu)
• The file name gets generated from the name of the original map, its dimensions and player count.
• An on-screen message says whether and where the new file was created.
• Tries saving to AdvCiv\PrivateMaps first. If that location can't be written to, My Games\Beyond the Sword\PublicMaps is used. AdvCiv will not be able to load from the latter location unless NoCustomAssets is set to 0 in AdvCiv\AdvCiv.ini. Regardless of the location, Civ 4 needs to be restarted before an exported script can be loaded.


AI:
Spoiler :
Peace negotiation: There were problems with the UWAI component refusing to make peace or unreasonably insisting on reparations. (Some reports in that vein: 1 2 3)
• When multiple AI civs are at war with the same civ, each of them (usually) assumes that it will be the primary target of the shared enemy. (Previously, AI civs often assumed that a stronger enemy posed no immediate danger because it would go after a different target first.)
• The AI may make a small payment for peace to a stronger war enemy that probably poses no immediate danger but could be very dangerous in the medium term. (Offering a token of goodwill might help and can't really hurt.)
• The AI may pay a human player for peace even if it thinks that both sides want peace. (It's not a reasonable position to insist on a square peace treaty when continuing the war is disastrous for one side and merely inconvenient for the other.)
• Made the AI a bit more generous when paying for peace in situations when the war is going badly but not extremely badly. (For extremely bad wars, the AI still assumes that peace is unlikely to last and therefore not worth very much.)

City safety calculation (evacuation): [advc.139] Discussion 1 2 3
• The AI updates the safety status of its cities in response to moves of human war enemies. This way, the UWAI component is always up to date about city safety when asked for a peace proposal.
• The safety calculation now accounts for unassigned promotions of the city defenders and for units in production that will appear at the end of the turn.
• Made the AI less likely to leave behind more than a couple of defensive units when evacuating a city.

In the city safety calculation and most other AI code that evaluates the strength of unit stacks: [advc.159]
Per-unit strength values are taken to the power of 1.25 before getting summed up. For war planning (UWAI component), such an adjustment had long been in place, but, for tactical decisions, the implicit assumption was still that e.g. two Swordsmen are an even match for one Cuirassier.

Increase the impact of NoWarAttitude (Civ4LeaderHeadInfos.xml) probabilities that are near 50%. (UWAI doesn't treat those as probabilities; they get factored into the war utility value as part of an "affection" cost.) This should make about a third of the AI leaders noticeably more reluctant to start wars when Cautious, approximating their BtS personalities more closely. Previously, Cautious vs. Annoyed attitude rarely made a significant difference in AdvCiv apart from worst enemies.

Only AI civs in the upper third of the scoreboard consider stage 2 of the "Domination" victory strategy (was upper half). [advc.115]

Diplo memory decay:
• Simplified and corrected the decay formula for multiple remembered diplo actions. For example, two declarations of war (in short succession) are now fully forgotten by the target after an expected duration of 150+75 turns on Normal speed. Three declarations after 150+75+50 turns, etc. (geometric progression). [advc.130r]
• Memory about tech trades ("you're becoming too advanced", "you shared your discoveries") are exempt from the above, i.e. they decay as in BtS with a per-turn probability that doesn't depend on the memory count. [advc.553]
• "You shared your discoveries" is now easier to get (increased relations modifier per tech) but more difficult to sustain (faster memory decay). [advc.553]
• "You gave us help" now decays faster, i.e. with a (base) probability of 1/150 instead of 1/200. [advc.144]

AI civs contact human players more frequently with offers for resource trades. Several players had reported (mainly here) that the AI made such offers only (very) rarely. I've tweaked the heuristic for deciding whether one side needs a resource (much) more than the other (and more than other potential recipients). [advc.036]

Tribute demands: [advc.104m]
• A tribute demand may consist of multiple resources, and they don't have to be surplus resources.
• The AI takes into account its war utility value when deciding how much tribute it should at least demand.
• The order in which the AI goes through the different types of tribute demands is now properly randomized. This may lead to more demands for gold per turn – I'm not sure that these ever occurred in AdvCiv 0.96.

Air recon: Fixed a BBAI bug that had caused the recon target to be chosen randomly with a bias only for maximal distance from the airbase. And made several tweaks (Git commits 1 2). The modified code isn't used much by the AI, it's mainly for automated human units, so this is really more a UI than an AI change. [advc.650]

City placement:
• Exploration units now prioritize the surroundings of (tentative) city sites. Previously, early AI cities were often founded without exploring the full city radius, which had lead to cities that clearly weren't locally optimal. This change should also make human exploration more rewarding as AI scouts won't reach the human player as quickly and will be slower to find Tribal Villages. [advc.031d]
• AI cities cancel settler production when all city sites are taken. This should lead to fewer AI cities in poor locations that the AI normally doesn't bother to produce settlers for. [advc.031b]
• Numerous tweaks to the evaluation of city sites (Git commits 1 2) [advc.031]

Tech evaluation: slightly higher value for early-game resource yields – to account for the fact that, in the early game, owned resources are almost always workable. Prompted by this post. (More remains to be done on that front.)

Improved the evaluation of the Pyramids ability (was still as in Vanilla Civ 4). The AI will build them much sooner now than in K-Mod. Actually, I had to make the AI underrate them again quite a bit to keep them viable for human players. May still go as early as 1000 BC; seems to vary a lot. [advc.131]

Removed or tweaked various conditions under which workers build roads and railroads while moving toward a target tile – so that improvements (and railroads on Mines, Lumbermills, Quarries) get built earlier. And other tweaks for railroad construction following (some) suggestions by Elkad. [advc.121] Discussion

Placed a limit on the number of units that the AI may delete per turn in response to financial trouble. The AI tries to avoid deleting units that are headed for enemy territory. [advc.110] Discussion

Revised the AI estimate of units needed for revolt suppression. Hopeless cases are disregarded. [advc.099c]

Damaged AI units consider tile defense when deciding whether to heal. Inspired by similar changes by @Tholal in the "More Naval AI" (MNAI) mod. I've also adopted a few other tweaks (AI and other) from that mod, by Tholal and @lfgr: Git commits 1 2
I've only gone through a small portion of the MNAI commit history; there's probably a good deal more that AdvCiv could adopt.


UI:
Spoiler :
The game auto-saves at the start of a human player turn, not at the start of the game turn. This makes a difference when a human player isn't first in the turn order, e.g. in scenarios. [advc.044]

Improved UI support for revolts: [advc.101]
• Added hover text on the main map and city screen (nationality bar) showing how much more garrison strength is needed to reduce a city's revolt chance to 0, or how much garrison strength can be safely removed. Idea by @Elkad
• "Grievances" that increase foreign culture strength, i.e. hurry anger, draft anger and foreign religion (if not countered by the owner's state religion), are stated in the hover text of the nationality bar.

Happiness and health effect in tile hover text: [advc.059]
• Happiness is shown when hovering over a Forest Preserve in the radius of a city owned by the active (human) player or over a tile owned by the active player in the radius of any revealed city. (BtS never shows the happiness effect of Forest Preserve in tile hover text.)
• When hovering over a Worker build button, the change in happiness (Forest Preserve) and health (chopping) that the build will cause is shown. (BULL has a similar feature.)

Sieges:
• When a city owned by the active (human) player gets bombarded, an interface message gets shown immediately (previously: not until the start of the human turn) and (idea from the MNAI mod) the name of the bombarding unit is included. [advc.004g]
• Help text for Walls and Castle says that defense is "raised to" 50% and 100% respectively. (This is implemented through a new XML tag DefenseRaise that replaces the cumulative DefenseModifier tag. Mod-mods can keep using the old tag.) [advc.004c]
• When hovering for combat odds and the only (otherwise) valid defenders are maximally damaged, the combat help text says so and states the attacker's damage limit. [advc.089]
• The number of collateral damage targets (iCollateralDamageMaxUnits in Civ4UnitInfos.xml) gets shown in unit help text. [advc.004]

The pathfinder should no longer propose paths that pass through more tiles than necessary. [advc.pf] Discussion

When hovering for movement into terrain that one of the selected units (e.g. Workboat) cannot enter, help text says which technology, if any, (e.g. Astronomy) would allow the move or if being the owner of the tile would help. [advc.057]

Darkened the color of the Great Person bar; was 100% yellow. [advc.002i]

The Settings tab (Victory screen) and the first replay message both list those custom map options that differ from the default. For example, if "Cylindrical" is the default world-wrap, then "Cylindrical" wouldn't be listed, but "Toroidal" would be listed. [advc.004, advc.106h]

Field-of-view slider: [advc.090]
• Made the bar slightly longer, which makes it a bit easier to set the slider to a particular value. (However, I haven't been able to fix the bug that can make the slider slip away when the mouse button is released.)
• When increased above 75%, the slider becomes more sensitive. This should allow Huge maps to be fully displayed without switching to Globe view (e.g. for AI Auto Play or a screenshot).

When the active player is defeated during AI Auto Play, the player with the next highest id automatically becomes the active player; AI Auto Play continues uninterrupted. [advc.127]

Option for Sea Patrol mission button added to the BUG menu. The button was previously disabled through the DLL; it's still disabled by default. [advc.004k]


Bugfixes: [advc.001]
In pre-AdvCiv code:
Spoiler :
(Vanilla) The Taj Mahal no longer grants an extra Golden Age turn when completed during a Golden Age. Moreover, a Golden Age started by the Taj Mahal doesn't start until the beginning of the owner's next turn. (Previously, it started during the end-of-turn sequence, already affecting the :hammers: and :gp: generated at the end of the turn.) [advc.001x]
(Vanila/ AdvCiv) Great Person birth modifiers from buildings (e.g. National Epic) had not affected birth probabilities. As a result, the birth probabilities displayed by AdvCiv were sometimes way off. [advc.001c] Discussion
(BtS) When deciding whether to monopolize a tech ("don't want to trade just yet"), code that was supposed to check for a war plan against the recipient of the tech had instead checked for a war plan against anyone.
(K-Mod) Erroneous uses of AI strategy bitmasks had lead to (minor?) errors in the AI evaluation of Cottages and commerce yields in general.
(K-Mod 1.44) The AI had used the "Big Espionage" strategy (far) too often because of a feedback loop between that strategy and the espionage commerce weight. I've also made some tweaks that further lower the AI espionage commerce weight. [advc.120]
(K-Mod 1.45) Angry citizens had consumed food even during the production of a worker or settler. (Not how it's supposed to work.)

In older AdvCiv code:
Spoiler :
• AI cities hadn't taken the Apostolic Palace's production bonus into account when evaluating Temples and Monasteries.
• The tech cost adjustment for the "No Tech Trading" option had had no effect. [advc.550d]
• Potential for out-of-sync errors resulting from AI city safety data not being stored in savegames. [advc.139]
• When forming a Permanent Alliance, the allies had lost their vassals.
• One aspect of the war utility computation, "fidelity", had been ignored by UWAI. It's supposed to stop the AI from making peace shortly after bringing in a war ally.
• UWAI had sometimes overestimated the offensive power of an AI civ when units originally produced for offensive purposes were in fact filling in as city defenders.
• Several more or less rare issues with city production getting interrupted upon border expansion, connecting a resource, declaring war or receiving a tech through trade. [advc.064d]
• Issues with the fly-out scoreboard: [advc.085]
- Drop in frame rate and lag in animations while the scoreboard was expanded. (This problem is not 100% fixed. Moving the cursor around in a particular pattern still seems to cause the frame rate to drop.)
- If the scoreboard gets expanded during diplomacy, instead of flickering, it now stays expanded until the diplo screen has been closed. (More a workaround than a bugfix.)​
• Various mixups of player and team ids. Those had some negative effect in team games, but I'm not sure how much trouble they had caused.
• Coastal roads had sometimes established a trade connection with adjacent coastal water. That's only supposed to happen in the special case of tiles workable by a city on a different landmass. [advc.124]
• The AI was able to ask humans for a free technology prior to Alphabet.
• AI units guarding a city site were sometimes (rarely?) moving back and forth between two tiles. [advc.300]
• Possible crash upon force-war votes (Apostolic Palace) affecting dead players.
• The Top Civs popup (e.g. "the most advanced civilizations") should no longer start appearing once half of the civs have been eliminated.


Many thanks to the players and fellow modders who have pointed out these and other issues and offered advice, in particular:
@Elkad, @SuperXANA, @carp, @VDNKh, @keldath, @xyx, @Pepo, @Cruiser76, @devolution, @Nightinggale, @Leoreth, @PieceOfMind

Optional changes (disabled or unused by default):
Spoiler :
Penalty on "ground-breaking" research as a rubber band/ catch-up mechanism. Based loosely upon @Leoreth's getSpreadResearchModifier function (Dawn of Civilization mod). See comments in TechDiffusion_GlobalDefines.xml for most of the specifics. [advc.groundbr] Discussion (on and off over several pages)

Tags added to Civ4ImprovementInfos.xml:
• Terrain improvements can grant health through the HealthPercent tag. (I plan to use this for Forest Preserve eventually.) [advc.901]
• Terrain improvements can protect vegetation from Global Warming through the GWFeatureProtection tag. Based on a suggestion from @Cruiser76. If this is used, then PROTECT_FEATURE_ON_NON_DRY_TERRAIN (GlobalDefinesAlt.xml) should probably be disabled. [advc.055]

The TerrainImpassables and FeatureImpassables tags don't apply to owned tiles even for land units. (Not relevant in BtS/AdvCiv because only sea units have impassable terrain (Ocean). [advc.057] Discussion

Minimap in replay:
REPLAY_TEXTURE_ERA in GlobalDefines_advc.xml allows storing a terrain texture for the replay file before the game is over so that the replay minimap doesn't reflect e.g. terrain changes from global warming. [advc.106n] Discussion
• Added a comment to GlobalDefines_advc.xml about increasing the resolution of the minimap through MINIMAP_RENDER_SIZE. [advc.106m]

Civ4LeaderHeadInfos.xml now contains a special LeaderHeadInfo element "LEADER_DEFAULTS" that sets default values for all non-mandatory elements. The LEADER_DEFAULTS element isn't required; mod-mods with custom leaders shouldn't have to change anything. [advc.xmldefault]


Performance optimizations: Turn times have been reduced to about 2/3 of AdvCiv 0.96 in tests with 18 civs. (But scalability problems of the UWAI component with far more than 18 civs still haven't been addressed.) The saved time is mostly due to low-level optimizations:
Spoiler :
• Function inlining [advc.inl],
• caching, avoiding unnecessary branching, reordering of conditions [advc.opt]
• memory use – collapsing zeroed arrays to avoid CPU cache misses. [advc.003t]
Regarding the last point, I've adopted a couple of ideas by @billw2015 from Caveman2Cosmos, but, more importantly, I've added @Nightinggale's EnumMap from the "We the People" mod, replacing some of the naked arrays in BtS code. It's a major improvement in readability and safety and a notable improvement in performance – despite being used only in a few AdvCiv classes so far.


Refactoring - an overview (maybe) for other modders; not relevant for players. To make the CvGameCore code easier to maintain and extend.
Spoiler :
Much of the code for "info enums" (enum types used for ids of objects storing data loaded from XML) is now generated by the preprocessor. This was helpful for integrating the EnumMap class mentioned under optimizations.
Expanded the use of enum types for ids a bit more, and added a macro for (somewhat) type-safe bitmasks. Through operator overloading, the linker now detects (suspicious) comparisons between certain enum types, in particular between player and team ids. [advc.enum]

The code for caching GlobalDefines (including Python callback guards) also gets generated by the preprocessor. This makes it much easier to cache additional defines. I've tried the same approach for implementing new XML tags on the DLL side. That's currently limited to simple integer and boolean XML elements and not as convenient as I'd like, but still avoids a lot of boilerplate code. I've been using it for the tags added in AdvCiv 0.97. [advc.tag]

Class ScaledInt (yet to be renamed to "ScaledNum") for fixed-point arithmetic, which is safe wrt. network synchronization. (There's not much of a point in that for AdvCiv so long as the mod still uses floating-point math extensively in the UWAI component.) I use ScaledInt in many of the AI calculations that I've added or modified this spring, and I'm quite happy with it in terms of usability and performance.

Most of the frequently needed types of loops can now be written more safely and concisely through
FOR_EACH macros (cities, units, selection groups, areas, deals, enum values) [advc.003s, advc.enum]
• or iterators (players, teams, plots). [advc.agent, advc.plotr]
In some cases, i've updated the entire code base to use the new syntax, in others, the process is ongoing. The FOR_EACH_ENUM macro is mostly @Nightinggale's work.

Made all base class declarations of virtual AI functions private, moved them to the bottom of their header files and created wrapper functions that make it easier and safer to modify the AI functions. Added some getter functions for obtaining references to AI objects in order to get by without the base class declarations. [advc.003u]
Untangled some header dependencies, especially dependencies on AI headers. [advc.003u]

Identified 5 more (total now 7) classes that get allocated by the EXE and therefore must retain their BtS memory layout. Added static assertions as a protection against memory corruptions (which are very difficult to track down). [advc.003k]

Split up CvInfos.h/.cpp into 17 + 17 separate header and implementation files. [advc.003x]

Moved the AI code for city site evaluation out of the CvPlayerAI class. In terms of splitting up large files, especially CvPlayerAI.cpp, a lot more could be done.

Moved bulky, repetitive code that sets up Python calls into a helper class. [advc.py]

Added plenty of const qualifiers and moved toward using references instead of pointers when appropriate.

Local improvements: Removal of duplicate code, removal of unused code, renamed identifiers.


Build system (no major changes) and debugging – both only relevant for developers:
Spoiler :
Build: [advc.make]
• Moved profiler settings to Makefile.project.
• Profiling code based on the Time Stamp Counter adopted from "We the People" (@Nightinggale). [advc.003o]
• Configuration debug-opt (debug symbols + compiler optimizations) added for inspecting optimized disassembly.
• Parallel debug builds (following @billw2015's suggestion)
• Some inlining allowed in debug builds (Ob1 compiler option), making them ca. 30% faster.

Debugging:
• Added code for testing whether an AI Auto Play sequence is reproducible. Mainly for finding uses of uninitialized memory or other non-deterministic code. [advc.repro]
GameFont Display by @Nightinggale added. No immediate use, but might become helpful in the future.
• Can log some basic statistics (land/ sea ratio, terrain, elevation and resource frequencies, resources per player) after map generation. [advc.mapstat]
• Can log a breakdown of the AI evaluation of city sites. [advc.031c]
• The manual includes a crib sheet about the various log files introduced by mods and from the original game (under id "007" in the changelog portion of the manual).
• Some tweaks to assertion popups: [advc.006]
- Include the function name in the error message. From Caveman2Cosmos (@billw2015)
- On a failed assertion while debugging, re-evaluate the condition, so that the user can immediately step through the evaluation. [advc.006h]
- Warn about empty int/bool/float XML elements. (from MNAI) [advc.006d]
- Don't show a spurious "current XML file" in assertion popups when XML loading has already finished. In part from MNAI [advc.006e], in part from @rheinig's mod. I've also adopted some tweaks to modular XML loading from the latter.​

 
Last edited:
AI_routeTerritory looks for the nearest improvement that would gain production from a railroad and that no other worker is already headed for, and then builds a railroad from the worker's current tile to that target improvement. AI_routeCity (lower priority than AI_routeTerritory) builds a railroad from the worker's current tile to ... apparently simply the first city in the owner's city list (so basically the oldest city) that no other worker is taking care of already. Once that railroad is done, the worker moves into the target city and proceeds to build a railroad to the route-to city of that city.

Perhaps the worst thing about this is that the workers always start railroading from where they stand. Might be inspired by the idea that there should be roads where people naturally walk.


And then there is the human way.

Preference to cities with a production focus. (probably. it's more complicated than that, but that's a start)
Preference to tiles that are currently being worked for sure.
If you can't get to a routeTerritory tilewith this turn's movement, stop 1 move short and put a partial rail down (routeCity), cancel, and then move to a production tile. Even if you moved max-1 and built the whole routeCity rail without cancelling, it would be better than building rails the whole way to a routeTerritory tile.
Given a choice between starting a new rail or assisting another worker within your range of movement, ALWAYS assist another worker.

Better to get a hammer now, another next turn, and another the following than to individually rail 3 hills at the same time. 1+2 hammer profit. Same with squares of movement gained.

routeCiv. Route from production cities to disputed borders first. Again, if possible you gang up with another worker, and skip squares to rail adjacent to another rail.

A worker 3 tiles out in the ice wasting time building roads shouldn't be railroading all that ice on the way back to improve a lumbermill.

We can probably skip the multiplayer considerations, because carefully planning your rails to minimize the impact of your enemy getting his Commando Factory online is the kind of thing you do in a game you'd never automate workers for.

Simplifying it down to a starting point.
Unworked tiles are not considered (unless nothing else is available of course)
routeProduction does not route TO a tile building rails along the way, it moves directly to that production tile if in range. (I realize this interferes with building roads to resources earlier in the game, no idea how to fix it)
Edit: Actually it takes care of itself. If the early worker can't get to the copper, he'll road towards it.

Get rid of the "that no other worker is headed for" condition. So workers gang up, even if it's accidental.
Only do routeCity if routeProduction is not available in current movement range, and reconsider that every time a rail is completed.
 
Last edited:
Is it possible to make the resource bubbles scale with Field of View?
I just got a big monitor, so I just noticed. With FoV on 80, a bubble covers about 4 squares.
 
One bugfix added to the release notes:
(Vanilla) The Taj Mahal no longer grants an extra Golden Age turn when completed during a Golden Age. Moreover, a Golden Age started by the Taj Mahal doesn't start until the beginning of the owner's next turn. (Previously, it started during the end-of-turn sequence, already affecting the :hammers: and :gp: generated at the end of the turn.) [advc.001x]​

Is it possible to make the resource bubbles scale with Field of View? I just got a big monitor, so I just noticed. With FoV on 80, a bubble covers about 4 squares.
I wish. Here is the latest thread about the problem that I'm aware of: link
I had meant to bring this topic up again, but I don't really think it'll help, so this may just be for commiseration:
Spoiler :
As far as I can tell, the size is set based on the screen height (as the smaller of the two aspects), apparently by the EXE. The fader settings in Civ4DetailManager.xml work nicely in Globe view but have no effect otherwise. Civ4DetailManager.xml seems to get parsed by the EXE (not by the DLL anyway). One approach could be a sort of DLL injection (the DLL already being injected), but that sounds exceedingly difficult, and billw, perhaps the one modder who might be up to the task, didn't sound like he'd volunteer and hasn't been around for months.

Recently, I've noticed that there is a 6 KB file Shaders\FXO\PlotIndicator.fx in the BtS install directory. Apparently, that file has been compiled into shader bytecode with the Microsoft D3DX9 Shader Compiler. It might be possible to hack that with a hex editor or a program called 3D Ripper DX, but I don't suppose the size is set (could be set?) by the shader.

I've managed to display a resource icon as a yield icon, but that didn't even look good and is probably impossible to do for more than a couple of different resource icons. Embedding the icons in the 3D models of the resources is possible but also doesn't look good enough in a mockup to justify the effort.

I'm attaching a screenshot at my native resolution of 1920x1200 at FoV 38 (and zoomed out). Those bubbles are already clearly too big and zooming out further (at higher FoV) will make it worse. As a reminder what they're arguably supposed to look like, I'm also attaching a screenshot at 1024x768. I've played with a 1280x1024 display for a long time and, really, just for playing Civ 4, I'd like to have it back.

These graphics scaling issues seem like a real problem for the longevity of Civ 4. Not just the plot indicators, also blurry textures of terrain, cursors, yield symbols, game font icons(?), button graphics, a fixed-size HUD and fixed-size Advisor screens. These other things can be and are being addressed by mods, but only to an extent, and the changes are laborious and not easily portable between mods. Eventually, one may have to play in a window that doesn't fill the entire screen.

And then there is the human way. [...] Simplifying it down to a starting point.
Unworked tiles are not considered (unless nothing else is available of course)
routeProduction does not route TO a tile building rails along the way, it moves directly to that production tile if in range. (I realize this interferes with building roads to resources earlier in the game, no idea how to fix it)
Edit: Actually it takes care of itself. If the early worker can't get to the copper, he'll road towards it.

Get rid of the "that no other worker is headed for" condition. So workers gang up, even if it's accidental.
Only do routeCity if routeProduction is not available in current movement range, and reconsider that every time a rail is completed.
Upon further investigation, the AI may set a railroad as a city's best build, and workers assigned to the city will then, through AI_improveCity, build a railroad from where they stand (somewhere in the city radius) to the best-build tile. At that point of the game, there are typically only 0-2 workers assigned per city, so the workers not assigned to any city also get to build some Mine/ Quarry railroads through AI_routeTerritory.

In my earlier test, I had given the Railroad tech to the AI through the WorldBuilder and then ran AI Auto Play for one turn – which meant that the AI moved its workers before updating the best build cache of each city. That's also a problem when the AI receives Railroad through a tech trade. I've fixed that now.

Anyway, so we have three places where railroad builds are (typically) initiated and they all lay down railroads along the way. That should be changed, at least when a worker, ultimately, wants to put a railroad on a Mine or Quarry. Hopefully just a matter of pushing a move-to mission onto the worker's mission queue and then a route mission. I've given higher priority to worked tiles; that was easy enough to do.

As for teaming up, the AI actually only checks for other workers that are already at the target tile or adjacent to it. Still, would be good to relax that, at least on slow game speed.
 

Attachments

  • 1920x1200.jpg
    1920x1200.jpg
    358.2 KB · Views: 174
  • 1024x768.jpg
    1024x768.jpg
    174.5 KB · Views: 125
Two more item added to the release notes (AI changes):

Improved the evaluation of the Pyramids ability (was still as in Vanilla Civ 4). The AI will build them much sooner now than in K-Mod. Actually, I had to make the AI underrate them again quite a bit to keep them viable for human players. May still go as early as 1000 BC; seems to vary a lot. [advc.131]​

Removed or tweaked various conditions under which workers build roads and railroads while moving toward a target tile – so that improvements (and railroads on Mines, Lumbermills, Quarries) get built earlier. And other tweaks for railroad construction following (some) suggestions by Elkad. [advc.121] Discussion

New build (#10) attached. (Edit: No longer up to date – about to upload v0.97 proper)
Other than the above and the Taj Mahal Golden Age fix mentioned earlier, this includes:
+fix ships getting destroyed by siege units
+fix crash in Advanced Start
+minor tweaks

Changed files (for manual update from #9): GitHub.com/f1rpo/AdvCiv/compare/...
 

Attachments

  • AdvCiv_v0.97pre10.zip
    10.5 MB · Views: 104
Last edited:
Been playing the past few days, and no bugs, except today, when a couple showed up. On chapter 2 of a Rise and Fall game, I decided to sabotage my civ - 100% commerce slider, build research everywhere, delete all units, declare war on everybody. Purposefully. As a joke.

My capital, on the same landmass as two other civs, was promptly (5 turns) taken by a modest size-4 stack. Nice. My second (and last) city, Beshbalik, was separated from that landmass by two coast tiles, a one-turn galley drop away, and AFAICT, every AI had a galley or two swimming around the area. It took all 55 turns of the chapter and 3 of the interregnal turns for someone to capture that undefended city, and when they did, it was with 2 longbows, 2 axemen, and 2 archers, even though a single warrior would have sufficed. On a second run of the same scenario, Beshbalik made it into the next chapter, at which point I couldn't prevent it from building defense. I'm attaching a save for context.

The best case I can think of for the AI behavior was that they assigned the city a small negative value, which as the map filled up, eventually turned positive. At that point they already had units to spare, so why not overkill, just in case? Against this interpretation are:
1) That this city was the founded by an AI as its second city, in preference to other available near-overseas sites, and
2) That the oversized attack stack stuck around after taking the city, instead of all but a couple of archers or so returning on the same boats they came in on.

On an earlier run of the same concept, in which I managed an earlier defeat, I saw this:
where_we're_going_we_don't_need_turns.png

At a guess, it's calculating the start of the next chapter as if it were chapter 1, not chapter 3. (EDIT: A defeat in another chapter of another game showed the same "On turn 0 after -$TURN turns" pattern.)

Moving on anyway, I noticed that on turn 110, when I received the civ selection popup, I could see the map, as if I were the civ I'd played Chapter 1 (it may have been chosen on some other criterion). I would rather be in the dark for the decision.
 

Attachments

  • asking_for_it.CivBeyondSwordSave
    79.9 KB · Views: 116
Last edited:
Two more items added to release notes:
Barbarians can appear on Plains Hill and Tundra Hill again. The criterion is, as before, a positive food yield, but the -1 food from hills is no longer counted. I think this captures the notion of habitable land better. [advc.300] And the Great Wall graphic is now placed in a way that avoids creating "Gaza strips" wedged between the Great Wall and some other obstacle. [advc.310]​

Civ4LeaderHeadInfos.xml now contains a special LeaderHeadInfo element "LEADER_DEFAULTS" that sets default values for all non-mandatory elements. [advc.xmldefault] The LEADER_DEFAULTS element isn't required; mod-mods with custom leaders shouldn't have to change anything.​

@carp: The AI for naval landings doesn't have this kind of lightweight mode. It won't set sail without a proper Stack of Doom in cargo.
Code:
bool const bBarbarian = isBarbarian();
// ...
//int iTargetReinforcementSize = (bBarbarian ? AI_stackOfDoomExtra() : 2);
int iTargetReinforcementSize = (bBarbarian ? 2 : AI_stackOfDoomExtra()); // K-Mod. =\
// Cargo to launch a new invasion
int iTargetInvasionSize = 2*iTargetReinforcementSize;
For example, Capac sets iTargetInvasionSize to 10 units. It takes a long time to assemble such a large stack because AI civs have more important priorities in the early game. If I revert the K-Mod bugfix, iTargetInvasionSize gets set to 4 and Rome conquers your city after 23 turns. Still pretty slow because of the two Galleys required. The Galleys that keep passing your island have Unit AI type "explore" or "settler-sea" and they're stuck in those roles unless they entirely run out of things to do.

The fundamental problem is that, beyond looking at the game era, there is no AI evaluation of the adversity that might be encountered after making landfall, and this can't easily be amended because the decision which city to target is made at a later point.

After player defeat, the Rise&Fall code isn't able to tell which chapter has just ended. Perhaps I had only tested that in the initial chapter. Easy enough to fix. I can't easily fix the issue with the map:
Moving on anyway, I noticed that on turn 110, when I received the civ selection popup, I could see the map, as if I were the civ I'd played Chapter 1 (it may have been chosen on some other criterion). I would rather be in the dark for the decision.
I think popups can only appear on the turn of a human civ. The civ selection popup after player defeat is supposed to appear at the start of the game turn, so the earliest player in the turn order needs to be human. Similarly, right after getting defeated, human control switches to the civ whose turn is coming up (Rome) and this also gives away part of the map. I'd have to find a way to suppress updates of the main map and mini map upon switching to another civ – or to keep the human player in control of the defeated civ so that no switch is necessary.
 
Top Bottom