Resource icon

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

What the AI can't do however, is move a "Tactical Nuke" AI strat unit out of an INLAND city to the coast to be loaded into a "Missile Carrier" like the human can. Their inland nukes are stuck uselessly.

Have you tested this for the AI when even the rebase flag for the nuke was tickled ? I have tested this - but only for the human player - and here it is working for rebasing the nuke to subs even from inland cities.
 
Last edited:
Can you consider fixing this ai behviour while defending, they just dont defend their cities and keep their defense oriented units outside the assaulted city
For sure I can at least consider it. I haven't looked at the defensive AI much so far. I have looked over the offensive AI, and am thinking of ways to tweak it to improve its behavior, but I haven't gotten around to even trying that yet. I'll keep the defensive AI in mind too.
Another matter conisidering the long turns when playing huge maps and modpacks,I wonder if is it possible to change some code in the game so it run smooth in modern strong computers, I think I hv heard that civ 3 and old games run only on one core of the cpu, if true maybe it can be fixed, have a good day all
Reducing turn times would be challenging. First I'd have to figure out why turns take so long to begin with. I've heard it blamed on the trade network calculations but based on what I've seen they only take up ~20% of the late game turn time. I suspect the biggest factor is the unit AI based on what I've read of the decompiled code. There are a lot of "N^2" loops in the unit AI, in other words, cases where the unit AI processes each unit in the game. This is N^2 since the game has to process AI for each unit to begin with, then each unit processes again each one, so the amount of processing is proportional to the square of the number of units on the map. For example, when a unit searches for a transport to load into, it checks every unit on the map. Same when it searches for an army to join. It would be tough but possible to optimize that by modifying the code to instead identify candidate transports and armies once for all units instead of repeatedly for each unit. Though I'm not even sure that that's causing the slowdown, I'd have to inspect the program as it runs to verify.

About using multiple cores, that's again very difficult. In general it's difficult to modify a program that's been written with one core in mind to take advantage of many, and that's with access to the source code, which I don't have. If I manage to modify Civ 3 to use multiple cores, it will either be because I got lucky and some aspect of the program just so happens to be easy to parallelize, or because I've overhauled it, e.g. if I replace large parts of the unit AI I could use that opportunity to parallelize it as well.
 
For sure I can at least consider it. I haven't looked at the defensive AI much so far. I have looked over the offensive AI, and am thinking of ways to tweak it to improve its behavior, but I haven't gotten around to even trying that yet. I'll keep the defensive AI in mind too.

Reducing turn times would be challenging. First I'd have to figure out why turns take so long to begin with. I've heard it blamed on the trade network calculations but based on what I've seen they only take up ~20% of the late game turn time. I suspect the biggest factor is the unit AI based on what I've read of the decompiled code. There are a lot of "N^2" loops in the unit AI, in other words, cases where the unit AI processes each unit in the game. This is N^2 since the game has to process AI for each unit to begin with, then each unit processes again each one, so the amount of processing is proportional to the square of the number of units on the map. For example, when a unit searches for a transport to load into, it checks every unit on the map. Same when it searches for an army to join. It would be tough but possible to optimize that by modifying the code to instead identify candidate transports and armies once for all units instead of repeatedly for each unit. Though I'm not even sure that that's causing the slowdown, I'd have to inspect the program as it runs to verify.

About using multiple cores, that's again very difficult. In general it's difficult to modify a program that's been written with one core in mind to take advantage of many, and that's with access to the source code, which I don't have. If I manage to modify Civ 3 to use multiple cores, it will either be because I got lucky and some aspect of the program just so happens to be easy to parallelize, or because I've overhauled it, e.g. if I replace large parts of the unit AI I could use that opportunity to parallelize it as well.
Regarding the no tresspassing its a huge addon to the game, but for ccm for example there are hidden nationality units andcan we let them tresspass , the invisible units too, in the next version if possible.

Good luck my friend you are doing a great job, have a good day
 
Last edited:
For artillery, I discovered that the game already includes a half decent unit AI except it's never activated in the base game because AI artillery is unable to get an escort unit and without an escort it will never leave its city. I never even had to figure out why the escort finding process is broken, I simply injected a bit of code that allows artillery to grab a defender from the city it's in as an escort.
This does seem to cause the AI to send out its bombard-units in a 1:1 ratio with the escort-defenders, though, and hence (because it then decides it must replace the town's "lost" defender) put too many shields into defenders, relative to attackers.

Would it be possible to further tweak this code (or the .ini file?) so that the AI's unit-build-priorities aim (in addition to the "build 2 defenders in every town"-rule!) for a specified attack-stack ratio, e.g. 3:2:1 bombard:attack:defence?

Or that an escort-defender would only be grabbed if a newly built bombard-unit couldn't reach a safe/escorted location (e.g. any tile out of reach of current enemy unit-positions, or another garrisoned town, or a nearby M=1 unit-stack) within, say, 1 turn of movement?
 
Reducing turn times would be challenging. First I'd have to figure out why turns take so long to begin with. ... Though I'm not even sure that that's causing the slowdown, I'd have to inspect the program as it runs to verify.
You (or any of us) could also test it in practice: build a very computationally complex scenario, and time the same turns while removing various things: air and sea trade, roads, unit strategies, units themselves by type, cropped empty tiles, and so on. That's not going to pinpoint specific code obviously, but may help narrow down what to profile.
 
I believe the slow downs have a great deal to do with the number of Units and types... takes time to compute each concerning what they should do and where they should go... not to mention using Ships and Airports along with it all.
 
I'd like to collect some real measurements about turn times so we don't have to guess. Maybe I'll do that soon, or maybe not, I don't want to promise since I might get distracted. I'll try using gprof (or an equivalent) first, which should work, although those tools typically assume you have the program source available. Failing that, it would be possible for me to use C3X to stub out, for example, the offensive unit AI, then time the interturn with vs without it stubbed out.
Regarding the no tresspassing its a huge addon to the game, but for ccm for example there are hidden nationality units andcan we let them tresspass , the invisible units too, in the next version if possible.
Sure, that's an easy change to make. It makes sense that invisible units should ignore border restrictions, I'm not so sure about hidden nationality units but I'll make it totally configurable. By the way, if you've been playing with trespassing prevention turned on, has it been working OK? I still consider that feature semi-experimental since I never got around to comprehensively testing it. In particular I'm concerned the AI might not cope with it in all circumstances.
Good luck my friend you are doing a great job, have a good day
Thanks, you too.
Would it be possible to further tweak this code (or the .ini file?) so that the AI's unit-build-priorities aim (in addition to the "build 2 defenders in every town"-rule!) for a specified attack-stack ratio, e.g. 3:2:1 bombard:attack:defence?
Or that an escort-defender would only be grabbed if a newly built bombard-unit couldn't reach a safe/escorted location (e.g. any tile out of reach of current enemy unit-positions, or another garrisoned town, or a nearby M=1 unit-stack) within, say, 1 turn of movement?
Unfortunately these changes would be difficult. For example, units can have multiple escorters but only one escortee, so it's difficult to have anything above a 1/1 ratio of artillery to defenders escorting them. I could try something funky like assigning one artillery as the escort of another, but I doubt that would work out well. The AI doesn't have any concept of a unit stack that I've seen. As far as I can tell, it forms artillery stacks only because all artillery+escort pairs independently decide to do the same thing. So altering its "stack" composition is tough. One idea I have is to encourage offensive units to stay near the artillery. That doesn't solve the problem but it would make it less likely that artillery is bombarding uselessly while the attackers are somewhere else. Though I'm not sure if even that's practical.

There are other awkward things about the unit AI, like the fact that there's a separate routine for units that have been assigned as escorts. So using offensive units to escort artillery to battle would work for getting them into position, but then the problem would be getting them to attack as they wouldn't be running the normal offensive unit AI any more. Another awkward thing about the separate escorter AI is that it's responsible for getting artillery to the battlefield. So I can't simply let artillery move on its own unguarded, its own movement logic only works for moving to targets in its immediate vicinity.
 
One of the things that slows the game is trade routes. Reduce the number of ports as was done in CCM and that has an impact. On very large maps you see how long it takes to calculate the trade routes by planting a town. I would have to wait maybe two minute as the settler animation would have the settler do its squat and then pause for that long. If you remove a lot of harbors, the town is settled faster.
 
I'd like to collect some real measurements about turn times so we don't have to guess. Maybe I'll do that soon, or maybe not, I don't want to promise since I might get distracted. I'll try using gprof (or an equivalent) first, which should work, although those tools typically assume you have the program source available. Failing that, it would be possible for me to use C3X to stub out, for example, the offensive unit AI, then time the interturn with vs without it stubbed out.

Sure, that's an easy change to make. It makes sense that invisible units should ignore border restrictions, I'm not so sure about hidden nationality units but I'll make it totally configurable. By the way, if you've been playing with trespassing prevention turned on, has it been working OK? I still consider that feature semi-experimental since I never got around to comprehensively testing it. In particular I'm concerned the AI might not cope with it in all circumstances.

Yes it is working and it is a huge step forward in the gameplay of civ3, but i enbaled in the middle of my game where there are wars already and MPPs so not sure about the AI responding to it, I ll have to test it by running a new game from the beginning that I ll do gladly soon. In addition to that I changed railroad movement limit to 6, and it working too
 
Last edited:
It makes sense that invisible units should ignore border restrictions, I'm not so sure about hidden nationality units but I'll make it totally configurable.
Seems to me,that forcing Invisible and/or HN units to respect foreign borders pretty much defeats the purpose of both those flags, though!

It would certainly (further) break the Firaxis Middle Ages and Sengoku scenarios. Regicide-mode is activated in both, and therefore both scenarios also include Invisible+HN units ("Assassins" and "Ninjas", respectively) to stealth-attack enemy Kings — which will by definition require crossing borders (AFAIK, the AI doesn't ever move a 'King-strategy' unit from its starting position).

And (@Hazem), restricting the mobility of Invisible+HN units may/will similarly damage the fundamental game-design of CCM, where Slaves from the "Enslavers" and later the sacrificial units (for instant Cultural expansion) produced by "Holy Men" and "Lawyers", are intended to compensate for the deliberately limited Worker- and Settler-(auto)production.
 
Seems to me,that forcing Invisible and/or HN units to respect foreign borders pretty much defeats the purpose of both those flags, though!

It would certainly (further) break the Firaxis Middle Ages and Sengoku scenarios. Regicide-mode is activated in both, and therefore both scenarios also include Invisible+HN units ("Assassins" and "Ninjas", respectively) to stealth-attack enemy Kings — which will by definition require crossing borders (AFAIK, the AI doesn't ever move a 'King-strategy' unit from its starting position).

And (@Hazem), restricting the mobility of Invisible+HN units may/will similarly damage the fundamental game-design of CCM, where Slaves from the "Enslavers" and later the sacrificial units (for instant Cultural expansion) produced by "Holy Men" and "Lawyers", are intended to compensate for the deliberately limited Worker- and Settler-(auto)production.

I said the same as you, we have to let them trespass
 
Sure, that's an easy change to make. It makes sense that invisible units should ignore border restrictions, I'm not so sure about hidden nationality units but I'll make it totally configurable. By the way, if you've been playing with trespassing prevention turned on, has it been working OK? I still consider that feature semi-experimental since I never got around to comprehensively testing it. In particular I'm concerned the AI might not cope with it in all circumstances.
I have experienced something interesting with the disallow tressspassing enabled on ccm, Units including HN units(enslaver, lawers) can attack the rival units that are on the edge of their territories and the declare war popup shows or for the HN units they can enslave them without entering the borders, at least i can enslave some workers hehe.

Concerning the long turns i hv noticed that occupying cities make turns abti longer so when there are alot of wars turns take longer hope this is soemthing that can be fixed
 
Last edited:
Yes it is working and it is a huge step forward in the gameplay of civ3, but i enbaled in the middle of my game where there are wars already and MPPs so not sure about the AI responding to it, I ll have to test it by running a new game from the beginning that I ll do gladly soon. In addition to that I changed railroad movement limit to 6, and it working too
Sounds good.
Seems to me,that forcing Invisible and/or HN units to respect foreign borders pretty much defeats the purpose of both those flags, though!
I haven't played many mods, even the ones that come with the game, so I don't have a good idea of what the purpose of the HN ability actually is. When I think of HN, I think of privateers, which are almost completely pointless units. Preventing them from trespassing shouldn't hurt them much since they still have all the open ocean to operate on. However if mods use HN units in a way that it makes sense for them to be able to trespass then I'll make that the rule and won't bother with another config option. I'll turn the question around, and this is for anyone who wants to chime in, is there any reason not to do this? Is there any reason HN units should not be allowed to trespass?
Concerning the long turns i hv noticed that occupying cities make turns abti longer so when there are alot of wars turns take longer hope this is soemthing that can be fixed
That's consistent with my thinking that the unit AI is responsible for much of the slowdown. I can't say if it's fixable though until I've looked into it.
 
I said the same as you, we have to let them trespass
Then I misunderstood your post: I thought you were asking for HN/Invisible units to be blocked. My apologies.
I don't have a good idea of what the purpose of the HN ability actually is.
Simply put, HN units can attack an opponent's units without that opponent declaring war in response.
When I think of HN, I think of privateers, which are almost completely pointless units. Preventing them from trespassing shouldn't hurt them much since they still have all the open ocean to operate on.
It's true that Privateers are weaker on defence than Frigates, but victorious Privateers can enslave new Privateers, so someone who reaches Magnetism early enough, and starts building a steady supply of Privateers, can potentially clear opponents' ships off the map pretty quickly.

If piracy is the aim, the usual tactic would be to build a small number of Frigates, and hide each Privateer-stack under a single Frigate.
I'll turn the question around, and this is for anyone who wants to chime in, is there any reason not to do this? Is there any reason HN units should not be allowed to trespass?
One possible answer to that is that the AI can use HN land-units to attack and possibly even capture an opponent's town while at peace. This may actually be a bug, since the human player is disallowed from doing it.

Another answer is that the HN-flag is (too?) highly valued by the AI, so it will tend to prefer to build units with that flag, rather than units without it (even if the HN-unit has substantially lower A/D/M-values).
 
About the "no-trespasses-option" for CCM 2.50:

Trespasses when playing with the mod CCM 2.50 are very welcome. This not only concerns the autoproduced HN (and invisible) units (enslavers, holy men and lawyers) but also normal units, that are trespassing the borders of another civ. These trespassing normal units are ideal targets for persuading them to become slaves, monks and later great artists, providing a great benefit for the civ whose borders were violated. Those holy men, lawyers and enslavers are the best game option I know for dealing with the problem of violating borders.

Unfortunately Firaxis, even in later versions of the civ series never had that idea and therefore those later versions have to deal with the not so fun-providing solution of closed borders. In my eyes there is no reason to adapt those closed borders-option to Civ 3.

The argument, that the AI tends to build HN-units in my eyes is true, but of course it has no value, if these HN-units are only autoproduced by some buildings and are not available by normal production. The HN-landunits are working like poison. In a great dosis they are deadly, but in a small dosis (as in CCM) they are working like medicine for the game.
 
I suspect the biggest factor is the unit AI based on what I've read of the decompiled code.

I believe the slow downs have a great deal to do with the number of Units and types... takes time to compute each concerning what they should do and where they should go... not to mention using Ships and Airports along with it all.

Yes, this is my observation, too. The worst factor in causing the delays in the interturns of the game is the number of units placed on the map. More than a decade ago when creating the SOE scenario, this scenario had a regimental setting for units and astronomic high interturn times. When reducing the units on the map by giving the starting units a divisional setting, these interturn delays (and of course the risk of running into the MUA) was reduced massively, so the interturn units still are very high when starting that scenario.

Even the AI diplomacy part here seems to be a bigger factor. After two turns when playing SOE, the interturn times are significantly decreasing. The number of units on the map did not massively decrease as the killed units were in big numbers replaced by new produced units, but the diplomatic actions were nearly all done.
 
What the AI can't do however, is move a "Tactical Nuke" AI strat unit out of an INLAND city to the coast to be loaded into a "Missile Carrier" like the human can. Their inland nukes are stuck uselessly.

I did a short test in Debug mode about rebasing a preplaced Polaris tactical missile with the rebase flag in the mod CCM 2.50 to a preplaced "nuclear" sub, in this case to a SSNB of the George Washington class in that mod. What was no problem for the human player (as I have tested this many years ago), did not work for the AI. The AI did not rebase the tactical nuke to the submarine in the thousand years of the game this test was running (4000 BC to 3000 BC).

So Predator145, I think you are right by mentioning, that the tactical nuke here has a big problem for the AI in its settings. :thumbsup:

As a consequence I will set all tactical nukes to be upgraded to ICBMs so no unused tactical nukes with a range of only a few tiles will stay in their inland cities for the complete game and additionally I consider to give them the airlift flag, so they can be moved by the AI at least to coastal towns that are containing airports and from here can be loaded into "nuclear" subs who are located in the same coastal town (or one tile beneath that town if the immobile flag is skipped).
 
I did a short test in Debug mode about rebasing a preplaced Polaris tactical missile with the rebase flag in the mod CCM 2.50 to a preplaced "nuclear" sub, in this case to a SSNB of the George Washington class in that mod. What was no problem for the human player (as I have tested this many years ago), did not work for the AI. The AI did not rebase the tactical nuke to the submarine in the thousand years of the game this test was running (4000 BC to 3000 BC).

So Predator145, I think you are right by mentioning, that the tactical nuke here has a big problem for the AI in its settings. :thumbsup:

As a consequence I will set all tactical nukes to be upgraded to ICBMs so no unused tactical nukes with a range of only a few tiles will stay in their inland cities for the complete game and additionally I consider to give them the airlift flag, so they can be moved by the AI at least to coastal towns that are containing airports and from here can be loaded into "nuclear" subs who are located in the same coastal town (or one tile beneath that town if the immobile flag is skipped).

The AI has the same problem with the "Cruise Missile" AI strat.

It seems by not having any operational range but just the rebase command option would give a unit infinite rebase range.

The AI seems to only know how to use the rebase command if it's tagged as an Air Bombard, Air Defense or Air Transport unit. And it will do so regardless of operational range and being given the rebase command option or not.

Does the AI know how to use airlift?

A bit of testing of mine also showed that any unit can successfully perform "Precision Strike" BY THE HUMAN if you give it the command option and operational range (bombard range won't be used for it, only bombard strength).

I've given artillery precision strike and collateral dmg. But I haven't seen any collateral dmg happening on both normal bombardment and precision strike. My artillery also got shot down by a fighter despite being a land unit while performing a precision strike.

The AI didn't perform any precision strike with its artillery. I also gave all aircrafts precision strike. But with aircrafts I couldn't tell if the AI ever used that option because the animation was the same as normal bombing.

Just as with rebase, I highly suspect the AI only knows how to use precision strike with Air Bombard AI strat units.

C3C bombard code means that only air units can go after pop and improvements before defenders have been redlined. "Bombing" with a land unit is the same as bombard.

The only way to make artillery target pop and improvement before redlining defenders is to make them into stealth wheeled air units and make coastal terrain impassable to wheeled. Drawback is they can be lethally bombed by aircraft and other air unit artillery even though you have a defender guarding it as well as being shot down by fighters if stealth mission isn't set at 0% chance of interception. They also can't provide defensive bombard. But worst is that they're all destroyed if your defenders fall.
 

Attachments

  • Screenshot (20).png
    Screenshot (20).png
    62.1 KB · Views: 22
Last edited:
The problem with the AI handling tactical nukes, precision strikes, cruise missiles, airlifting etc. is, that they appear very lately in the game in a phase when most normal epic games are still finished and therefore not so much observations about the handling of those concepts by the AI in real game play are done and when having a look at those settings by creating a "laboratory environment" with the editor, it is not sure if the AI is behaving like that in the real game.

Until now I have not experimented with Civ 3 land artillery units. The land artillery in CCM and SOE works different to normal Civ 3 land artillery. The collateral damage flag was introduced for land units with the C3C conquest "Fall of Rome" as an additional flag for normal land units (not artillery). So at least it should work for attacks by normal land units with that additional flag.

The screenshot of bombarding Rheims and simultaneously taking out two buildings of a city by a combination of precision strike and collateral damage, was done many years ago, showing the bombardment of a city by an air unit (strategic bomber) done by me and not by the AI.

C3C bombard code means that only air units can go after pop and improvements before defenders have been redlined. "Bombing" with a land unit is the same as bombard.

Yes, the bombing of cities by air units is in accordance with the observations in the German Civ 3 Wikipedia, based on a test in 2013. Air bombardment at first destroys planes and citizens of a city, if there are no planes in the city, ships, citizens and buildings of the city will be destroyed. If there are neither planes nor ships in the city, according to that article units, citizens or buildings will be destroyed. You can find that article here. So the article is in German, I think the Google translator will do its job in translating it well to the English language. The article holds many more observations about different kinds of bombardment in C3C.
 
Last edited:
I wonder if it's possible to change the enslavement code with EXE modding, making some units have a 100% chance of enslavement or make it so certain units have a flag that prevents them from being enslaved like a vehicle.
 
Top Bottom