Advanced Civ

I intend to first go through the savegames provided by civ4-advciv-oracle-bug. Maybe some other to-do will have cropped up by then. At any rate, I'll want to run some tests eventually, hopefully play a little too. So probably a few weeks at best. There's always the development version on GitHub (zip download; folder will need to be renamed to just "AdvCiv"), which lacks such testing. And the manual isn't kept up to date on GitHub. The GameCore DLL usually is up to date or almost; should certainly be consistent with the other assets and thus playable. GitHub can also compare v1.11 and 1.12 for a change log.
Edit: Link to savegames added because they're no longer in this thread.
 
Last edited:
I mostly concern about that change about Brius talking about, that iron doesn't have a chance to appears on mine. Is there a way to change it myself ? I not very good at modding Civ IV. :)
 
Oop, I hadn't even committed that yet. I've done so now: Git commit (the DLL gets updated in the next one). It's very easy to cherry-pick – if you're able to recompile the DLL (under "for developers" in the manual; involves installing Visual Studio). If not, the updated DLL on GitHub includes all v1.12 changes and will require all other assets to be updated to v1.12 as well. (To that end, the zip link I posted earlier should still work. It targets the latest state of the 1.12 branch.)
 
hey f1,

came across an odd assert,

in : bool CvSelectionGroup::groupRoadTo(int iX, int iY, MovementFlags eFlags)
// advc.pf: Don't want the AI to route through foreign territory
FAssert(eFlags & MOVE_SAFE_TERRITORY);
return groupPathTo(iX, iY, eFlags);
}

in cvselectiongroup.

i debugged and checked to from and to plots,
well what do you know, its a worker i gave a build road path to.
funny thing is, that the road is from city to city with 1 unowned plot.

isnt this weird?
a wild guess here, shouldn't it be : MOVE_NO_ENEMY_TERRITORY
edit i tried a few of the flags as well as the commented move_to_route.

its 100% my worker (stopped the mission before the assert and it was fine).

here is the path and the situation of the assert,
 

Attachments

  • Screenshot 2025-02-04 215845.png
    Screenshot 2025-02-04 215845.png
    732.1 KB · Views: 19
Last edited:
I think this is just me not testing recent changes much at all other than through AI Auto Play. (Since I've just given some encouragement to use the untested GitHub version: This particular issue won't cause problems; assertions are disabled in the DLL on GitHub.) It's probably normal that human workers on a route-to mission don't use any pathfinding flag. Hm, I don't actually know where this is set in the code. I guess it's this constructor:
Code:
CvNetPushMission::CvNetPushMission() :
	CvMessageData(GAMEMESSAGE_PUSH_MISSION), m_ePlayer(NO_PLAYER), m_iUnitID(-1),
	m_eMission(NO_MISSION), m_iData1(-1), m_iData2(-1), m_eFlags(NO_MOVEMENT_FLAGS),
Anyway, humans may route through any territory, so not using MOVE_SAFE_TERRITORY is fine. The assertion should probably simply be changed to:
FAssert((eFlags & MOVE_SAFE_TERRITORY) || isHuman());
On a side note, MOVE_SAFE_TERRITORY is a misleading name. It means that the unit can't enter foreign territory (not sure right now about vassals); unowned tiles are allowed. BtS uses that for most civilian moves (even for settlers; K-Mod has changed that), and I've tried to make sure that workers use it pretty much always, especially when building roads – because AI roads through human territory can be annoying for the human and harmful for the AI because the human can keep pillaging them causing several AI workers to be fruitlessly occupied. If "safety" were the main point, then I'd argue that foreign territory entered via Open Borders is quite safe (declaring war will bump the unit out).
 
I think this is just me not testing recent changes much at all other than through AI Auto Play. (Since I've just given some encouragement to use the untested GitHub version: This particular issue won't cause problems; assertions are disabled in the DLL on GitHub.) It's probably normal that human workers on a route-to mission don't use any pathfinding flag. Hm, I don't actually know where this is set in the code. I guess it's this constructor:
Code:
CvNetPushMission::CvNetPushMission() :
	CvMessageData(GAMEMESSAGE_PUSH_MISSION), m_ePlayer(NO_PLAYER), m_iUnitID(-1),
	m_eMission(NO_MISSION), m_iData1(-1), m_iData2(-1), m_eFlags(NO_MOVEMENT_FLAGS),
Anyway, humans may route through any territory, so not using MOVE_SAFE_TERRITORY is fine. The assertion should probably simply be changed to:
FAssert((eFlags & MOVE_SAFE_TERRITORY) || isHuman());
On a side note, MOVE_SAFE_TERRITORY is a misleading name. It means that the unit can't enter foreign territory (not sure right now about vassals); unowned tiles are allowed. BtS uses that for most civilian moves (even for settlers; K-Mod has changed that), and I've tried to make sure that workers use it pretty much always, especially when building roads – because AI roads through human territory can be annoying for the human and harmful for the AI because the human can keep pillaging them causing several AI workers to be fruitlessly occupied. If "safety" were the main point, then I'd argue that foreign territory entered via Open Borders is quite safe (declaring war will bump the unit out).
Thanks f1, ill add the human check.
 
hey,

small code fix for a an error that nobody will probably experience:

Python:
void CvInitCore::setCiv(PlayerTypes eID, CivilizationTypes eCiv)
{
    FAssertBounds(0, MAX_PLAYERS, eID);
    /*  advc.003w: Guard added (This way, the CvCivilization data is
        not even recomputed when reloading from within a game.) */
    //doto 115 fix -> added eCiv != NO_CIVILIZATION due to "your details click option before having 1 city
    if (m_aeCiv.get(eID) != eCiv && eCiv != NO_CIVILIZATION)
    {
        m_aeCiv.set(eID, eCiv);
        GET_PLAYER(eID).setCivilization(eCiv); // advc.003w
    }
}
 
@keldath: Not getting this error. Clicking "OK" gives me a valid eCiv in the debugger. Also don't see why having a capital should matter. Kind of strange that this function gets called at all (though I can confirm that the EXE calls it) when a player merely changes the display strings for their civ. Maybe there is a problem under more specific circumstances.
 

Attachments

  • Civ4ScreenShot0001.jpg
    Civ4ScreenShot0001.jpg
    147.9 KB · Views: 14
No, I had meant to improve it (and I guess rein it in a little) by preventing resource discoveries on unsuitable terrain. I don't think K-Mod Farms can discover resources; the iDiscoverRand values in Civ4ImprovementInfos.xml are all zero. This could be a simple way to bring a bit of the Columbian exchange into the game – if the can-discover condition were that the player already has access to the resource (through trade or a city). Well, still a pretty poor representation thereof.
Can you share this chunk of code. Perhaps I can merge it into CoM :)
 
Well, the check for valid terrain you already have – Rise of Mankind is where I took that from (and then I broke it on my own). Anyway, in this spot, in CvPlot.cpp ...
C++:
					//Afforess: check for valid terrains for this bonus before discovering it
					if (!canHaveBonus((BonusTypes)iI))
... I was thinking that CvPlayer::hasBonus could be checked instead. But I guess CvPlot::isPlotGroupConnectedBonus is the cleaner choice. That should check specifically whether the improvement plot is part of the resource's trade network (plot group); the network of the capital in the case of imported resources. Unless you want to introduce a new XML tag (complementing iDiscoverRand), a quick approach could be to something like
C++:
if ((iI == gc.getInfoTypeForString("BONUS_CORN")) ? !canHaveBonus((BonusTypes)iI) : !isPlotGroupConnectedBonus(getOwner(), (BonusTypes)iI))
	continue;
And then a normal discovery chance for Corn in XML. Not sure if I've thought this through. Hm, isPlotGroupConnectedBonus will mean that a road is usually needed for a discovery. So maybe !GET_PLAYER(getOwner()).hasBonus((BonusTypes)iI) after all.
 
@f1rpo
hey,
i think i found a critical civic mistake in advciv :
in the AI_doCivics()

there is this 3 lines:
Code:
aeBestCivic.set(eLoopCivicOption, eNewCivic); // advc.001r
int iTestAnarchy = getCivicAnarchyLength(aeBestCivic);
aeBestCivic.set(eLoopCivicOption, eOtherCivic); // advc.001r
/*  using ~30 percent as a rough estimate of revolution cost, and
                a low threshold regardless of anarchy just for a bit of inertia.
                reduced threshold if we are already going to have a revolution. */

looks like aeBestCivic is being set with the previous civic.
it interfere with the flow of the calculation.

Edit,
I also checked the ai docivics in chatgpt,
The while condition is for sure both will and want to switch are true? Not or statement?
 
Last edited:
@keldath: aeBestCivic is set to the best civic only briefly at that point, in order to determine how that will affect the anarchy length. Right after that, the previous civic, i.e. normally (always?) the one that the AI player is already running, is restored – because no decision has yet been made on the best civic, i.e. whether it is worth the (additional) anarchy. Once that has been evaluated, the best civic gets locked in (where bWillSwitch = true also gets set). This approach still looks good to me.

bWillSwitch && bWantSwitch: I guess the outer loop is to be repeated only if the AI finds both a civic that is clearly worth switching for and one that might be worth it when changing multiple civics at once. Not sure if that's the optimal way of handling this – it could also be that multiple civics are worth it as a package but none individually. But I don't think it's plainly a bug.
 
@f1rpo
i was thinking about efficiency, speed.

what if ill add all the civics types for a civicoption as an xml tag?
it would save lots of double loops of civics and civicoptions comparisons.

would you think that would have an effect?
i mean ,loops have a cost , but how much of it, lets say 100 civs X 8 options.
sometimes the loops can cycle for 800 iterations no?
do you think its worth the trouble?
 
For going through all civics that belong to a given civic category? But that wouldn't be a nested loop – just a loop over all civics and then filtering out all those that don't belong to the desired category. Sorry if I'm being a little dense here. The function just discussed also only goes through each civic category; well, maybe two or three times, but not once per civic. I rather doubt that it's significant, even if you've tripled the number of civics. Unless the loop body does something expensive on most iterations. It could be that a cache mechanism would make the loops easier to read.

@civ4-advciv-oracle-bug: I've read this last post (edit: by which I mean this one; it has now been moved), the 34 before that one I mostly have not yet read at all. I've also downloaded the latest archive with savegames and screenshots. I don't think the changes to AI city placement on the 1.12 branch are big, so probably more coincidence or a kinder, more understanding eye of the beholder, :) but it might also be noticeably better. Obviously, I won't be able to act (at all) on most of your suggestions – already because I won't have the time. So I'll try to prioritize what looks actionable.
 
Last edited:
sorry if I'm being a little dense here. The function just discussed also only goes through each civic category; well, maybe two or three times, but not once per civic
its ok, im value your opinion a super great deal.

also didnt fully explained, im rewriting the civic ai with high end attention to fit my new government civics changes.
basically, ill calculate some of the civics as groups with a total value.
so, some overdose of loops.
 
Is it normal i mean that on example 44 screenshots, i cannot build a watermill on this tile, but there is a river nearby.
Doesn't the fresh water come from the river?
Just to quickly address this (without having checked out the savegame): Watermills can't be built on river corners nor opposite of each other. I suspect that it's mostly because of the 3D model, but one could come up with further rationales, e.g. a river bend being prone to erosion and therefore undesirable for waterworks. To me, a lot of Watermills in one place would draw attention to Watermill being generally on the wrong scale to act as an alternative to Farm(-land). Or, if the position of the river is not the problem, then maybe some minimal food requirement? Either way, the main issue is probably that the improvement placement rules aren't properly documented. On that subject, I already have this post bookmarked; I mean the list toward the end. I don't think they're exactly the best ways to address all these issues, but certainly useful as a list of (minor) open issues in help text and Civilopedia. Doubtful that I'll find the time.

Would you mind if I'd ask a moderator to move most of your posts to a new thread in the AdvCiv subforum? Maybe titled "AI city placement and misc. suggestions"? Of course with a link to that thread in a recent post in this thread; it's not my intention to shove the posts aside. But so that the thread here doesn't feel inundated (especially if I reply more), which might discourage other posters.
 
Ok, if it is working as intended then it's fine, i will look into this link later.
For the suggestion to move my suggestions separately sure i don't mind (in fact even if i minded if it's more efficient i cannot object to it being done but thanks for asking i mean thanks).

I currently happen to have a lot of suggestions but i don't know if i would have many in the future. But of course i mean if i see things that i would want to be improved or talked about i would like to submit them as long as i wish/like i mean anyways whether it's here or there what matters the most to me is that they are handled xd i mean anyways.
Still, as it is indeed maybe overflowing this thread, and that currently i am indeed submitting many suggestions, i have no objection to move these to a separate thread and you may reply as you see fit there or here i mean anyways, as long as i get the reply or that the code is reviewed most importantly and ideally changes implemented regarding these suggestions then i don't mind xd i mean anyways.

Thanks,
 
Last edited:
Back
Top Bottom