Advanced Civ

Ohhh nice! Multiple people, including myself, have asked how the game chooses random leaders. I've never known if the game chooses by civilization first and then rolls again to determine the leader, OR if all leaders are weighted equally. If the first option, then leaders from multi-leader civilizations (Washington, Catherine, etc.) would be under-represented compared to single-leader civilizations (Pacal, etc.). If the second option, then multi-leader civilizations would be in play more commonly than single-leader civilizations. I've never been bothered by how the game does it, but I've always wanted to know how that works.
Well, it's mostly hidden in the EXE, but the random numbers are generated by the DLL. The number of RNG calls from the EXE strongly suggests that the algorithm is something like this (pseudocode):
Spoiler :
for each player P that no civ has been assigned to manually:
bestResult=-1
bestCiv=none
for each civ C that isn't taken yet:
randNum = RNG.get(10000) // i.e. between 0 and 9999
if randNum > bestResult:
bestResult = randNum
bestCiv = C​
assign bestCiv to P​
for each player P that no leader has been assigned to manually:
bestResult=-1
bestLeader=none
for each leader L matching the civ of P:
randNum = RNG.get(10000)
if randNum > bestResult:
bestResult = randNum
bestLeader = L​
assign bestLeader to P​
There'd be a higher number of RNG calls if a random number were generated for every leader. This algorithm also integrates manual selection (of just the civ, or of both leader and civ) with random selection in a plausibly straightforward way. If the only options were to give (a) every civ equal probability or (b) every leader, then I think (a) would be preferable because leaders of the same civ usually have pretty similar AI behavior. But a middleground seems best.
That sounds like a cool option, so I'll have to give it a shot playing with that option. Does the pre-contact score show up, once you gain enough :espionage: to see all demographics?
Yes, it should. Otherwise, to be consistent, I'd have to leave a gap in the graphs whenever the player falls behind the view-demographics threshold for a few turns; wouldn't want that. I agree with what you wrote in July – that scores shouldn't be treated as secret once they've been on public display. I've disabled part of the change by default only because I don't want players to get confused by incomplete score graphs.
You've single-handedly fixed a quality-of-life bug which has plagued this game since the beginning. That's something to be especially proud of, I'd say. Now, I don't have to worry about waking my neighbors when engaging in late-night Civ wars. :)
Thanks for the encouragement. I wouldn't depend on it being fixed just yet. I haven't tested it much, and some sounds may still not be covered. In particular, it looks like a sound played when "your units are under attack" could possibly stack up. I could probably implement a general safeguard against loud sounds by keeping track of ids of sounds that have started playing recently – but let's see if the current effort is sufficient.

Ashoka: I got used to seeing the new spelling (new in the context of the Civ 4 UI) faster than I expected.
 
I've noticed in PerfectMongoose, when selecting to start all in the old world, it doesn't happen, is it a bug? Maybe it's because I've put too many AI (14 in a large map)?

Also, is Totestra map script compatible? It seems to work fine. I really love that map, there is an option to have toroidal with ice bands (that melt with GW) which creates strategic depth!
 
I've noticed in PerfectMongoose, when selecting to start all in the old world, it doesn't happen, is it a bug? Maybe it's because I've put too many AI (14 in a large map)?
PM treats landmasses connected by shallow water as a single continent – or let's say "supercontinent" – when it comes to the Old World Starts option. If most of the land belongs to one pangaean supercontinent (which is often the case), PM tries to break it up by throwing meteors. This often falls short; in part, because I've reduced the maximal number of meteors, but, even with additional meteors, it wasn't working reliably (and lead to unpredictable land-water ratios). On the bottom line, there is often not much land that the script can reserve for the New World. High sea level should help at least a bit.

There's a clause I've added that essentially disables the New World logic when there are fewer than 100 land tiles per player in the Old World. So an unusually high player count could be a problem. Maybe 14 on a Large map with Normal sea level is already too many; hard to say. If logging is enabled, the script writes
"Second largest continent (%d tiles) reserved for New World"​
to PythonDbg.log – if it does reserve a (super-)continent.

I find the landmasses generated by PM too fine-grained. It almost(?) never generates something as bulky as Asia. Perhaps more compact landmasses would also help with the Old World Starts problem. You'd think that there'd be some sort of grain parameter in the land generator, but I haven't been able to find one and generally don't understand how it works. My best bet is to experiment with the PerfectWorld 2 land generator. That's an option in the original PM script; I tentatively disabled that option because I rather wanted to use the latest and greatest land generator and tweak it if necessary. (Also, players probably would've asked me how the PW2 and PW3 generator differ, and I don't have an answer.) Ideally, I'd like the Old World Starts option to steer the land generator toward two or more hemispheres; the meteor kludge should only be plan B.
Also, is Totestra map script compatible? It seems to work fine.
Totestra should be compatible, but the changes I've made in the DLL to the assignment and "normalization" of starting positions and to the placement of resources won't affect Totestra. All the PerfectWorld scripts have their own routines for those tasks. Which aren't bad, but, especially for starting positions, the DLL code is more sophisticated now. As a programmer, you probably won't find it too difficult to disable some of the custom code in Totestra if you want to. That's what I've done in the PM version included in the mod.

Since Totestra is based on PW2 and not on LunarMongoose's backport of PW3 (from Civ 5), I assume that Totestra uses the PW2 land generator. So I might as well ask you: Does Totestra generate bulkier landmasses than PM in your experience?
I really love that map, there is an option to have toroidal with ice bands (that melt with GW) which creates strategic depth!
This might not work so well because the AdvCiv game rules and AI treat water surfaces separated by Ice as separate water areas, and, once the map has been generated, those areas don't get updated. Various data get stored at CvArea objects, and the existing code for repartitioning the map into areas would discard that data. I haven't tested it, but I expect that the AI will be unaware when some Northwest Passage opens up through global warming. Preserving the CvArea data wouldn't be that difficult to do; it's somewhere on my to-do list.
 
@f1rpo: I clean-installed rc8, and now some of the sea level selectors are broken. The play now route displays as normal, but the custom game dialog (for every mapscript) usually shows the options as Random / [blank] / Medium / [blank]. I took a screenshot of the only exception I saw. I'd guess that fact that this happened for PerfectMongoose is a coincidence - it's what I usually run.
 

Attachments

  • 0.98rc8-PM-sea_level-display.png
    0.98rc8-PM-sea_level-display.png
    586.3 KB · Views: 73
i had that too, f1rpo fixed it.
you can play with this bug for now i guess, its just some text issue :)
That was a problem with the additional sea levels in the DotO mod. There seems to be another problem, unrelated to DotO, namely a dangling pointer:
Code:
wchar const* CvInfoBase::getDescriptionInternal(uint uiForm) const
{
   // ...
   return gDLL->getText(sTag);
   // Equivalent to:
   //CvWString sLocal = gDLL->getText(sTag);
   //return sLocal.c_str();
}
Updated DLL attached; @carp please let me know if that solves the problem. (Because it works on my end either way.)
 

Attachments

Exiting the city screen is done by clicking the middle mouse button. Can I rebind it to the right mouse button?
 
@eXalted: The mod already exits the city screen when the city (center) tile is right-clicked. The camera then remains centered on the city (instead of centering on a selected unit). For all other plots, the right-click behavior is as in BtS: It clears the working-city override. (I.e. if a plot is in multiple city radii and has been manually assigned to one city, then right-click re-enables automatic assignment to the nearest city.) This behavior can currently only be changed in C++ (i.e. requires recompilation of the DLL). Middle-click behavior can also be changed in C++ (but can't depend on the cursor position). Exiting by left-clicking on a tile outside the city radius can be re-enabled through CITY_SCREEN_CLICK_WILL_EXIT in AdvCiv\Assets\XML\GlobalDefines_advc.xml.

--
Unrelated: The OOS debugging posts have moved here. Thanks, keldath, for moving that last post manually. And thanks to the moderator too of course.
 
CITY_SCREEN_CLICK_WILL_EXIT is exactly what I've been looking for. And yeah, I meant the left mouse button. Thank you and sorry for taking your time with such a trivial question but I am just so used to that option.
 
Last edited:
No problem. You're not the first person to ask either. My own fault really for changing that through XML. I should've added an option on the BUG menu and left it as in BtS by default. I still intend to add that option (has been high on my to-do list for some time).
 
Yeah, this actually made me think - I never thought that there no actual "exit city screen button" in the UI itself in CIv IV.

Hmm, it seems the Terra script is crashing for me. Here is the PythonDbg.log - https://pastebin.com/XsfUVhr0

I'm using the latest github commit.
 
Hmm, it seems the Terra script is crashing for me. Here is the PythonDbg.log - [...]
I'm using the latest github commit.
I'm not keeping the DLL on GitHub up to date, so, unless you compile the DLL yourself, the latest files on GitHub aren't generally usable. The current DLL on GitHub is still the one from v0.98rc1, so the crash is probably caused by this bug ...
can anyone start a game with archipelago and snaky continents and get a crash?
... which is fixed in v0.98rc2. Please find that version attached to this post (or just the DLL; your other files should be good as they are).
Yeah, this actually made me think - I never thought that there no actual "exit city screen button" in the UI itself in CIv IV.
Instead they put a flashing "Press <Esc> to return" message in place. :hmm: I'm not going to add one, but I guess near the city cycling arrows would be a sensible spot for an exit button.
 
Back
Top Bottom