• Civilization 7 has been announced. For more info please check the forum here .
Resource icon

C3X: EXE Mod including Bug Fixes, Stack Bombard, and Much More Release 17C

Unit limits

04-antonio-banderas-interview-gq-september-2019-093019.gif
 
Compressed manual saves are at about 1.60 MB right now but the uncompressed autosaves are at 34.3 MB (36,039,450 bytes). I haven't noticed any issues with them strangely enough.
Was worried about the units since they get enumerated and C3MT save editor cannot read any newer units past the 15bit, so I suspected the game would start either breaking right now, or after hitting 16bit (65536) value in total amount of units in the world. I find it more curious that "disband units if you can't maintain their upkeep" doesn't seem to be applying to the AIs but who knows what's up with that.
Good to know. It might be that the 32 MB limit only applies to the save decompressor. I'm not surprised that the game data is so highly compressible since it wastes so much space. For example every unit object contains 256 bytes set aside for a queued path of up to 256 tiles. Every one has 56 bytes set aside for a custom name, almost never used. The owning player ID is stored in a full 32 bit integer even though no more than 5 bits will ever be used due to the 32 player limit. Similarly, experience level and leader kind (scientific or military) are stored in 32-bit integers.

All the unit enumerations I've seen use 32-bit integers and unit IDs are always stored in 32-bit ints as well so I highly doubt there would be any problem there. Oddly, tile enumerations & tile counts use 16-bit integers for no clear reason. That's why the maximum map size is 362x362 => 65522 total tiles.

The game will only disband at most one unit per turn due to failure to pay maintenance. As long as the AI is producing at least one unit per turn it will continue to gain units even after it can't pay for them. There is a C3X option that addresses this, called aggressively_penalize_bankruptcy. If players can't pay maintenance, it will force sell unprofitable buildings, disband units, and switch cities to building wealth, as many as are necessary to clear the deficit. It might be too harsh on the AI in games like yours.
 
Good to know. It might be that the 32 MB limit only applies to the save decompressor. I'm not surprised that the game data is so highly compressible since it wastes so much space. For example every unit object contains 256 bytes set aside for a queued path of up to 256 tiles. Every one has 56 bytes set aside for a custom name, almost never used. The owning player ID is stored in a full 32 bit integer even though no more than 5 bits will ever be used due to the 32 player limit. Similarly, experience level and leader kind (scientific or military) are stored in 32-bit integers.
Either that or the botched no city limit patch (from https://forums.civfanatics.com/resources/no-more-city-limit-for-c3c-editor.13028/ ) has undocumented features addressing 32 MB limit. :D
I've ran the game originally without it, just with C3X, until I've reached 512 cities limit (decompressed file size at that time was around 20MB) - 31 AIs on 500x262 map sure do hit the limit cap in no time. Found out renaming modded no city limit executable to civ3conquests and applying your C3X patcher over it does in fact work, only to get disappointed later on that the limit modification is flawed and works reliably only up to 550 cities, with breaking completely at exactly 556th and 557th cities, but hey additional 38 cities are nothing to sniff at so I take those.
If you wanna poke around the save files I can upload them right now. Or rather would've if the post wasn't stuck waiting for a mod review. Even linking to civfanatics own address flags the posts for a manual review, this is just ridiculous.
 
Last edited:
Since another player report that problem, I will make a detailed post about this problem.

What is the problem:
When the uncompressed save file exceeds 32-37 MB of space, saves get corrupted.

You will only know you have the problem when you try to save after the 32-37 MB mark.

You can normally continue play the game, everything works fine, but when you try to save ... BAM. No save.

That means you lose the progress you have made.

Buuuuuut:
You can normally save again if you can drop that save file size when you make a couple of huge wars so the data of the world decrease.

I have done that. At the 750ish turn this bug occured. I made war with 2 easy opponents and after 100 turns (that took me a full day on a monstrocity map marathon edition) I could make safe saves again.

What I have noticed:
The size of the file that start bugging out is not fixed.
When I dont set a windows swap file (I have 32 GB of ram) the size start bugging at 32 MB.

But if I set a windows swap file, that file size increases to 35-36 MB.

If I also set the executable to run as windows 7 application that limit increases to 37-38 MB.

How you get that problem:
Huge maps that civilizations are not fighting much produce a lot of data developing buildings, units, etc.

The monstrocity map is more keen to produce this bug, but only if civilizations do not make any wars.

I uploaded a save file that produces this problem at the next turn.
The map is a monstrocity map marathon edition 2 years old (I think version 1.03 or 1.04).

If it does not produce the bug on the next turn, play a few turns until it bugs out (remember, you will know you bugged when you try to save your game, the error it pops up says: The save file is corrupted).
 

Attachments

  • trash45-before-bugged3.SAV
    4.8 MB · Views: 1
Very cool concept this unit limit, especially that they also apply to auto-production from wonders. I'm already thinking about a wonder that could produce only a couple of powerful units and cannot produce more until one or more have been destroyed. I wonder how does this apply to units that have been attached to an army, I assume those will also count towards the limits?
 
@Flintlock What is the current technical unit limit? I've been keeping tabs on amount of units in the world in my ongoing marathon monstrosity map game, via c3mt editor since it shows numbered list of them, and I've just found out few turns ago I got past the magic 15bit number of 32767, on turn 202. Should I be afraid of some kind of value size overflow or am I good to keep on playing? If I don't do anything the AIs will just keep producing units ad infinite and they don't seem very kin on starting wars against each other.
Thanks for pointing out this bug.

That means I am not the only one who experienced this abnormality.

I could not use the c3mt editor to see the number of units.

Do you know if limits apply to maps and scenarios? (I try to load the monstrocity map with 1000 turns gameplay and does not load up).
 
Good to know. It might be that the 32 MB limit only applies to the save decompressor. I'm not surprised that the game data is so highly compressible since it wastes so much space. For example every unit object contains 256 bytes set aside for a queued path of up to 256 tiles. Every one has 56 bytes set aside for a custom name, almost never used. The owning player ID is stored in a full 32 bit integer even though no more than 5 bits will ever be used due to the 32 player limit. Similarly, experience level and leader kind (scientific or military) are stored in 32-bit integers.

All the unit enumerations I've seen use 32-bit integers and unit IDs are always stored in 32-bit ints as well so I highly doubt there would be any problem there. Oddly, tile enumerations & tile counts use 16-bit integers for no clear reason. That's why the maximum map size is 362x362 => 65522 total tiles.

The game will only disband at most one unit per turn due to failure to pay maintenance. As long as the AI is producing at least one unit per turn it will continue to gain units even after it can't pay for them. There is a C3X option that addresses this, called aggressively_penalize_bankruptcy. If players can't pay maintenance, it will force sell unprofitable buildings, disband units, and switch cities to building wealth, as many as are necessary to clear the deficit. It might be too harsh on the AI in games like yours.
Once again ... this is gold.

Activating this functionality will probably eliminate this 32 MB save limit bug. I have to make some tests.

In a few weeks I will report back on this.
 
Once again ... this is gold.

Activating this functionality will probably eliminate this 32 MB save limit bug. I have to make some tests.

In a few weeks I will report back on this.
aggressively_penalize_bankruptcy wont work well for your monstrosity marathon map unfortunately, nor even regular one for that matter - because of 512 cities cap most AIs end up in ballpark of owning 8 to 14 cities, with only few very expansionist civs reaching about 20-26. If you fully limit the AIs to what they can monetarily support, they wont have larger forces than 50 to 100 units. Which is obviously no fun, too little to offer resistance against a player who through very rapid expansion and conquests rakes up a total sum of over 100 cities for himself.

I would suggest rather finding a way to make AIs more likely to go to war against each other, especially in Marathon version, at turn 204 all the AIs are still in despotism and just keep on stacking spearmen, archers, swordmen, horsemen/chariots without ever putting them to any use. I suspect it might be partially because AI sees there is still free space around it to plant more cities (despite not trying to do so anymore - 512 limit reached) so it doesn't rank expansion through conquest very highly - that it would in case of having no more space left to plant cities and having only option to go to war against each other. Only time I've witnessed AI on AI combat was when French (18~20 cities empire) were taking over poor Dutch (4~5 cities), they wouldn't bother to attack even mildly more sized Spain or Celts. Other factor is not having techs for military alliances/gold for estabilishment of embassies so only I could open up diplomacy with AIs and convince them to do some wars via MA but knowing civ3 AI they will just most likely declare peace to each other after few turns or so.
The AI there doesn't care about combat to such degree that Babylonians consisting of 6 cities are living free from any war despite being squeezed between 20 cities strong Ottomans, 14 cities tall Sumeria and 16 cities of Persian empire. Way too peaceful for them given how much of an easy conquest they'd be, so imagine how passive towards each other larger/similarly sized empires are.
By the way, are you planning to update Marathon map past the 1.0 version? There are some rules bugs/oversights I could report on in the maps thread if you are looking for feedback.
 
aggressively_penalize_bankruptcy wont work well for your monstrosity marathon map unfortunately, nor even regular one for that matter - because of 512 cities cap most AIs end up in ballpark of owning 8 to 14 cities, with only few very expansionist civs reaching about 20-26. If you fully limit the AIs to what they can monetarily support, they wont have larger forces than 50 to 100 units. Which is obviously no fun, too little to offer resistance against a player who through very rapid expansion and conquests rakes up a total sum of over 100 cities for himself.

I would suggest rather finding a way to make AIs more likely to go to war against each other, especially in Marathon version, at turn 204 all the AIs are still in despotism and just keep on stacking spearmen, archers, swordmen, horsemen/chariots without ever putting them to any use. I suspect it might be partially because AI sees there is still free space around it to plant more cities (despite not trying to do so anymore - 512 limit reached) so it doesn't rank expansion through conquest very highly - that it would in case of having no more space left to plant cities and having only option to go to war against each other. Only time I've witnessed AI on AI combat was when French (18~20 cities empire) were taking over poor Dutch (4~5 cities), they wouldn't bother to attack even mildly more sized Spain or Celts. Other factor is not having techs for military alliances/gold for estabilishment of embassies so only I could open up diplomacy with AIs and convince them to do some wars via MA but knowing civ3 AI they will just most likely declare peace to each other after few turns or so.
The AI there doesn't care about combat to such degree that Babylonians consisting of 6 cities are living free from any war despite being squeezed between 20 cities strong Ottomans, 14 cities tall Sumeria and 16 cities of Persian empire. Way too peaceful for them given how much of an easy conquest they'd be, so imagine how passive towards each other larger/similarly sized empires are.
By the way, are you planning to update Marathon map past the 1.0 version? There are some rules bugs/oversights I could report on in the maps thread if you are looking for feedback.
The past 2 months I beta test exactly this fact, civilizations go to war easier.

I lowered the tech advances so the total game time take place max 1500 turns (so, when I adapt the RARR version, the max turns will be about 6000-7000).

Combine that with 3 min tiles distance between cities and you have some very very powerfull empires.

My current beta test, I am forth behind Turks, Indians and Spain.

The save file size is 22-25 MB (about 500 turns), which is good (there are wars all the time and currently 3 civs already eliminated).

These three civs always have money to trade and not huge stack of units. Turks largest stack is 150 artilleries and 150-250 defensive and offensive units that cooperate extremely well and actually conquering cities. They are lethal (thanks to the magician with his C3X mod).

As far as the unit limit you refer to (AI not having much money to build larger army), I agree. The only way to smooth this out is to give luxuries more gold so AI civs have at least double the available gold.

But I have to test that option to see if works (I have a hunch that it will work).

Keep in mind that there are limitations with this game and we rapidly reach them.

The economy in this game, in todays standards is extremely poor and not much can be done).

Economy govern decision (expansion, army, government and status of the nation [go to war, conquer, etc]).

In a few weeks I will know how these tweaks play out and I will report back.
 
Unit limits (and esp based on number of cities )are great. The biggest issue so far with auto production is that it highly rewards the player for sparing rump state civs that can then still have a viable military due to auto production and serve as a vassal.
 
I've ran the game originally without it, just with C3X, until I've reached 512 cities limit (decompressed file size at that time was around 20MB) - 31 AIs on 500x262 map sure do hit the limit cap in no time. Found out renaming modded no city limit executable to civ3conquests and applying your C3X patcher over it does in fact work, only to get disappointed later on that the limit modification is flawed and works reliably only up to 550 cities, with breaking completely at exactly 556th and 557th cities, but hey additional 38 cities are nothing to sniff at so I take those.
I'm still planning to do a proper no city limit patch at some point. It's an interesting challenge, pretty difficult but it should be doable with enough effort and/or cleverness. But I'll need to address the 32 MB save limit first, otherwise there's not much point.

Since another player report that problem, I will make a detailed post about this problem.
...
Thanks for posting this. I'll look into it soon, when I get a chance.

Any chance that the unit limits could also be conditional on the type of government?
That would be possible, though it would be awkward. In particular, I'm thinking of how such a rule would be specified in the config file. The simplest way would be something like [Swordsman (Despotism): 5, Swordsman (Monarchy): 10] but then what should be limit be for players in neither of those governments? It could either be zero or unlimited and I'm not sure what's more convenient. This is another case where I wish I had Lua integrated into the program. That way the mod could call out to a Lua script to determine the limits so they could depend on anything you want, government, wonders, techs, traits, whatever.

I wonder how does this apply to units that have been attached to an army, I assume those will also count towards the limits?
They will. Under the hood, the game treats units loaded into armies similarly to units loaded into transports, so they're still in the game, on tiles, in the master list of units, etc., even though you can't select or unload them.

@Flintlock Is there a chance of an option to make settlers, empty armies, and great leaders airliftable in the next release?
You can do this through the editor, no?
 
That would be possible, though it would be awkward. In particular, I'm thinking of how such a rule would be specified in the config file. The simplest way would be something like [Swordsman (Despotism): 5, Swordsman (Monarchy): 10] but then what should be limit be for players in neither of those governments? It could either be zero or unlimited and I'm not sure what's more convenient.
I guess it could default to infinite, but there could also be a [Swordsman (DEFAULT GOVT): x] setting to override this, perhaps. Could also use -1 for instances where you may explicitly want no limit, e.g. [Swordsman (Feudalism): -1] would allow Feudalist governments to build an unlimited supply.
 
@Flintlock Is there a chance of an option to make settlers, empty armies, and great leaders airliftable in the next release?
This can easily be changed in the Editor.
 
That would be possible, though it would be awkward. In particular, I'm thinking of how such a rule would be specified in the config file. The simplest way would be something like [Swordsman (Despotism): 5, Swordsman (Monarchy): 10] but then what should be limit be for players in neither of those governments? It could either be zero or unlimited and I'm not sure what's more convenient. This is another case where I wish I had Lua integrated into the program. That way the mod could call out to a Lua script to determine the limits so they could depend on anything you want, government, wonders, techs, traits, whatever.
I like that. It's what I recently thought about: to restrict units to specific government.
For example democratic government doesn't allow to build combat engineers, but authoritarian does. But quantity doesn't really mean a thing to me. So it may look like this:

["Combat Engineer" (Fascism): -1, "Combat Engineer" (Communism): -1]

Despotism and Feudalism (and maybe Monarchy) are too backward to build such complicated stuff, and Democratic and Republican politicians are just against building heavy weapons, however they won't mind if you created it before switching to more liberal government.
It opens a lot of interesting opportunities!
 
@Flintlock Has anyone asked yet about the possibility of mitigating the accumulation of War-Weariness points? With the AI's increased fielding of bombard-capable units under the patch, WWP can now mount up far quicker than in the stock game, due to the hardcoded +1 WWP for every attack on a friendly unit (of any kind, regardless of whether it results in a kill -- and even if the attacking unit dies), or tile-bombardment.

It would be preferable (IMHO, obviously!) if WWP would only accrue based on actual losses of tile-improvements, units and towns.

(And it might be even better if negative WWP -- so-called "War Happiness" -- could be credited to the victor in the event of (re)capturing towns currently held by the enemy)
 
WW seems to accumulate very quickly when cities are attacked by ground units (no bombarded, attacked directly), even though the attacks are successfully repelled. Tile and city bombardment doesn't seem to do it as quickly or at all. Strategic and terror bombardment ought have an effect on civilian morale.
 
The simplest way would be something like [Swordsman (Despotism): 5, Swordsman (Monarchy): 10] but then what should be limit be for players in neither of those governments? It could either be zero or unlimited and I'm not sure what's more convenient.
I think the default should be unlimited, but that's probably more for people who have hundreds to thousands of types of units in their mods to comment on.

It's also possible to combine the flat and city-dependent limits with a plus sign like so:
unit_limits = ["Heavy Tank": 5 + 3 cities-per]
I have an additional question. Is it possible to combine it with the minus sign?
- 5 + 3 cities-per (Meaning 18 cities would allow 1 unit of a given type, 21 cities would allow 2 units of a given type, etc.)
5 - 3 cities-per (Meaning that from 15 cities onwards, a given unit would no longer be allowed to be built. This would be very practical for limiting setler production in despotism, for example.)
 
I guess it could default to infinite, but there could also be a [Swordsman (DEFAULT GOVT): x] setting to override this, perhaps. Could also use -1 for instances where you may explicitly want no limit, e.g. [Swordsman (Feudalism): -1] would allow Feudalist governments to build an unlimited supply.
I like that. It's what I recently thought about: to restrict units to specific government.
For example democratic government doesn't allow to build combat engineers, but authoritarian does. But quantity doesn't really mean a thing to me. So it may look like this:
["Combat Engineer" (Fascism): -1, "Combat Engineer" (Communism): -1]
Despotism and Feudalism (and maybe Monarchy) are too backward to build such complicated stuff, and Democratic and Republican politicians are just against building heavy weapons, however they won't mind if you created it before switching to more liberal government.
I think defaulting to no limit makes the most sense since that's already how it works, as in a unit that's not listed at all has no limit. That way if you wanted to limit a unit to a particular government you'd have to set a limit of zero in every other government. That shouldn't be too bad unless you have a lot of governments and a lot of units you want to limit. There are other ways to accomplish this sort of thing. You could add a government-limited building that produces a special resource that's required to produce the unit types you want to limit to that gov't. That's already possible. The only downside is players would have to know to build the special building after switching gov'ts.

I thought of another way to specify the government limits, like so:
[Swordsman: 5 in Despotism + 10 in Monarchy]
What I like about this is that there's only one entry for the Swordsman. The problem is that it doesn't let you mix per-city and government limits unless I were to allow for something crazy like:
[Swordsman: (2 + 2 cities-per) in Despotism + (5 + 1 per-city) in Monarchy]
If I go down this route, I'm sure I'll get more requests to add more conditions to the limits. I'll end up building up a little ad hoc scripting language to specify the limits. It would be much better to use Lua in the first place.

@Flintlock Has anyone asked yet about the possibility of mitigating the accumulation of War-Weariness points? With the AI's increased fielding of bombard-capable units under the patch, WWP can now mount up far quicker than in the stock game, due to the hardcoded +1 WWP for every attack on a friendly unit (of any kind, regardless of whether it results in a kill -- and even if the attacking unit dies), or tile-bombardment.
It would be preferable (IMHO, obviously!) if WWP would only accrue based on actual losses of tile-improvements, units and towns.
(And it might be even better if negative WWP -- so-called "War Happiness" -- could be credited to the victor in the event of (re)capturing towns currently held by the enemy)
I don't think anyone's asked for that specifically. I looked into the logic for war weariness a while back when someone asked about a related bug. (Ultimately I wasn't able to get a clear picture of what the bug even was, never mind fix it.) It would be possible to modify the logic so war weariness is only added when units die not when they are damaged. It's awkward since the WW gets added before the outcome of the battle has been determined, but what I could do is subtract it back off afterward if the unit didn't die. It should also be possible to remove WW when players liberate their cities. I don't now what that would involve exactly, but it would require some care to make sure it's not exploitable.

Speaking of war weariness, I could easily power up the WW reduction effect of wonders like Universal Suffrage. The way that effect is implemented is the game counts how many wonders the player has with that effect then subtracts that many unhappy faces due to WW. I could modify the result of the count, say multiply it by 3, so each wonder cancels out more than just one unhappiness. That would make Uni Suffrage actually worth building.

I have an additional question. Is it possible to combine it with the minus sign?
- 5 + 3 cities-per (Meaning 18 cities would allow 1 unit of a given type, 21 cities would allow 2 units of a given type, etc.)
5 - 3 cities-per (Meaning that from 15 cities onwards, a given unit would no longer be allowed to be built. This would be very practical for limiting setler production in despotism, for example.)
You can't combine limits with a minus sign but negative numbers will work. In your examples, -5 + 3 cities-per and 5 + -3 cities-per would work and do what you expect. The reason a minus sign won't work to combine is that the mod sees the "+" sign as a bit of text that separates the limits, it doesn't treat the whole thing like one mathematical expression.
 
Top Bottom