Resource icon

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

Here are just the changes from R21 Preview 2 to the final version:
  • Allow stack limit to be set separately for land, sea, and air units
  • Prevent rebasing from violating the stack limit
  • Group foreign units on the right-click menu based only on their surface characteristics
    • Hopefully this fixes the issue reported here . I haven't checked whether it does but this change is worth doing anyway. Previously, if you were to put a stack of 10 AI riflemen on a tile in the scenario editor then load up the game and right click on that tile, you'd see two groups of rifleman units listed. That's because those riflemen were randomly assigned the offense or defense AI strategy, which made them different as far as the right-click menu grouping was concerned. Not anymore, the grouping logic now ignores properties of foreign units that wouldn't matter to other players, like movement, current job, AI strategy, etc.
  • Fix double despawn of barb unit entering city after hit by lethal ZoC
    • If lethal ZoC was turned on, barb units could get despawned twice if they got hit by ZoC while they were moving into a city. That's because they were getting despawned after looting the city and then despawned again by the lethal ZoC mod logic, which incorrectly detected that they'd been killed by ZoC. This could cause odd game data corruption that only showed up when loading a save.
  • Fix incorrect ETAs shown for one tile paths when railroad movement is limited
    • Fixes the issue reported here
  • Turn exclude_cities_from_units_per_tile_limit off by default

There are still some more issues I intend to look into (how perfume affects wonders granting free improvs, if it's possible to apply perfume to the AI's "panicked" production choices, applying stack limits to unloading one by one, ...) but I don't want to delay R21. Also that nasty bug related to zone of control ought to be stomped out sooner rather than later.

R22 will include an option to expand the workable radius of cities. I've already starting working on that. Ideally, I'll be able to make it so that the radius can vary based on improvements, technologies, governments, (Lua scripts...), but I'm not sure that's practical. It might just be a single config setting that applies to all cities.


A special case is the Treasury earns 5% given to "Wall Street", but is limited to a maximum earning of 50 gold.
I just looked over the logic for adding interest and it's unfortunately not easy to modify. Presumably there was originally a single function that determined a player's net income but it's been inlined in several places, which means I can't make just one modification to remove the cap. I'd have to hunt down and modify all the locations where interest applies. I've already found where that is for actually granting the gold but I don't know where it is for the interface. Another issue is that the maximum amount of 50 is stored inside an instruction in a single byte. That means it's not possible to overwrite it where it is with a value greater than 255. It's still possible to increase the cap on interest and modify the rate too, just annoyingly difficult.

If you're still actively keeping your list with suggestions, I hope you'll add it.
Sure, I'll add this to the latest list. I have so many lists now. I stopped updating the list on the GitHub and instead put suggestions in a mod to-do list I keep on my desktop. Every time the list gets too large, I push it down and start a new one. I've done that several times already.

Isn't this something that's actually already partially happening? When war breaks out, it is common to lose active trades such as resources of luxury for money, which will inherently affect happiness in cities. In fact, the very act of war at the beginning will affect the happiness in cities and you don't even need to have an active trade to lose. I mean, I'm assuming that the game is already doing some checks the moment the diplomatic status between civilizations changes. Likewise, checks are made due to the change of ownership, becoming obsolete, or destruction of the city in which the wonder is located or to which the free improvement is given. So recalculations of the city economy also happen during such situations. I'm not quite sure what kind of WEIRD RULES you're referring to?
I'm not sure what gets recomputed when wars break out. I remember having trouble with resource generation from buildings not being updated when trade agreements got broken by wars or other means. There were issues like you can't know a trade agreement is broken until you update all resource access because losing access to one resource can break an export agreement that loses a player access to a different resource that was traded as part of the same agreement. In the end, I wasn't able to find a good place to trigger an update around the time when access to some resource was lost, instead I made it so the mod remembers that resource generation info might be obsolete and only updates it when the human player looks, for example by zooming to a city.

There's also the issue that some parts of the city economy are cached. I know that tile yields and maintenance are and maybe some other things are too. So if you have a wonder that places a building with a maintenance cost in enemy cities, the game might go ahead and recompute happiness when war is declared, but I doubt it would recompute maintenance. In fact, there's already a bug in the base game where city maintenance isn't kept properly up to date.

By "weird rules" I was thinking of a request I got a while back to make it possible for units to grant a building to cities by standing on the city's tile. Specifically, the requester wanted an army or general type unit to give a special defensive building to any city the unit's in. The simplest way to make that happen would be to modify the has_improvement function to check units on the city's tile but that would be very inefficient. In order to do it efficiently you'd have to know whenever a unit of that special type entered or left a tile with a city on it, which honestly shouldn't be too difficult.
 
R21 should be fun and I won't have to edit the config file much (still working through unit limits).

However, I still suffer from phantom units - ones that a civ should not be able to build but somehow my opponents acquire - not played in debug mode to see where they are created yet, probably a good idea I guess. Seems to be a small set of creatures that appear, so far. I suspect it is still the unit limit that is causing it somehow, although I've no proof. I've set these very low for nearly all the higher era units so you hit them pretty quickly. I am running R20. Units that have reached their unit limit still appear as build options. They only disappear if you exceed it (by losing cities). It also still offers the same units as an alternative option when the limit is reached.

Anybody know what's going on or suffer the same glitch?
 
However, I still suffer from phantom units - ones that a civ should not be able to build but somehow my opponents acquire - not played in debug mode to see where they are created yet, probably a good idea I guess. Seems to be a small set of creatures that appear, so far. I suspect it is still the unit limit that is causing it somehow, although I've no proof. I've set these very low for nearly all the higher era units so you hit them pretty quickly. I am running R20.
Are you setting building prereqs for units too? I fixed a bug where building prereqs could interfere with unit limits, making it so the limits didn't apply. That's in R21, actually it was first in R21 Preview 1.
 
Prevent rebasing from violating the stack limit
Just out of curiosity, what technical solution did you use? Because I remember you saying last time that there was no way to effectively limit it.

how perfume affects wonders granting free improvs
:thumbsup:

R22 will include an option to expand the workable radius of cities.
:thumbsup:

I just looked over the logic for adding interest and it's unfortunately not easy to modify. Presumably there was originally a single function that determined a player's net income but it's been inlined in several places, which means I can't make just one modification to remove the cap. I'd have to hunt down and modify all the locations where interest applies. I've already found where that is for actually granting the gold but I don't know where it is for the interface. Another issue is that the maximum amount of 50 is stored inside an instruction in a single byte. That means it's not possible to overwrite it where it is with a value greater than 255. It's still possible to increase the cap on interest and modify the rate too, just annoyingly difficult.
That's very unfortunate. It's really unpleasant to find that something that looks simple on the outside is this internally complex. So if you can, add it to your list with some very low priority. If I were to focus on the positives, I would say:
- The ability to use the full 255 is still 5.1 better than the current 50.
- The ability to move interest around would also still be priceless.
If 255 is a hard cap with no tricks to get around it, I can imagine going with interest at say 0.5% to make it make sense to build something like investment banks in large numbers while taking a long time for the limits to take effect.

I would like to clarify a few things though:
- Just so, are we talking in units or tens of units about the amount of places that would need modification? Let us know how much of a pain it would be and how much we should praise you for it.
- Is this single byte where the result of the calculation is stored or is it where the restriction itself is stored? Because if it's the former, couldn't this be solved similarly to the other 255 limitation problem with improvements that you successfully solved? And if it's the latter, couldn't it simply be ignored/skipped?
- So I guess any more complex formulas for controlling/influencing the economy are completely out of the question at this stage?
- Is it far simpler then to wait for Lua that can handle all these and any more complex calculations with interest rates moving depending on other factors?

Sure, I'll add this to the latest list. I have so many lists now. I stopped updating the list on the GitHub and instead put suggestions in a mod to-do list I keep on my desktop. Every time the list gets too large, I push it down and start a new one. I've done that several times already.
However, the list of achievements must also be incredibly large by now. Lots of incredible things have been accomplished, and the amount of them undoubtedly exceeds the remaining wishes. I'm surprised there isn't someone in the community with a similar level of technical savviness to work with so that this doesn't weigh so heavily on your shoulders.

There's also the issue that some parts of the city economy are cached. I know that tile yields and maintenance are and maybe some other things are too. So if you have a wonder that places a building with a maintenance cost in enemy cities, the game might go ahead and recompute happiness when war is declared, but I doubt it would recompute maintenance.
So just to be clear, the problem would be that buildings that should be free because they are given by the Wonder to enemy cities would not be free and would require maintenance? And the moment peace was made, those hostile buildings would disappear, but internally they would still be paid for, and likewise for friendly buildings that should be maintenance free, but internally they would also still be paid for?


I'd like to come back to something that was mentioned.
The "Sea Oil" should be a seperate strategic resource. All harbours or whatever would produce the resource "Sea Oil", which would allow the cities with both harbours and sea oil in the radius to build oil rigs, which produce oil. Remember - for the "requires resources in the city radius" flag, the resources in the radius don't actually have to be connected by road themselves, so long as the city has access to those resources from elsewhere.
I see. So even if all harbors produce "sea oil", you'd still need to have an actual sea oil in the city radius for the mechanism to kick in. But the sea oil production solves the problem of not having a road connected.
This solution is obviously workable, but the remaining cities without "sea oil" in their reach will have a mysterious useless source of "sea oil" that they will never be able to use in any meaningful way.
The "sea oil" on the water also has no way of being depleted because it is not practically part of the trade network, which is also a limitation that would be useful to address.
By the way, did you know that luxury resources, for some reason unknown to me, don't reappear somewhere on the map after depletion?
So, for me, WATER Tiles would definitely need an EXCEPTION allowing Luxuries or Strategic Resources to be part of the trade network if they are part of the TERRITORY.

If it was even a somewhat CONDITIONAL exception (We have 3 types of water terrain (+ LMs), so the question is when to attach which one?), territorial Coastal tiles would be connected to the trade network in cities after an improvement with an "Allows Water Trade" flag is built.
Territorial Sea tiles would be connected after inventing a technology with the "Enables Trade Over Sea Tiles" flag.
Territorial Ocean tiles (Not common, but I've seen them in scenarios) would be connected after inventing a technology with the "Enables Trade Over Ocean Tiles" flag.
After some light thought, both "Enables Trade Over Sea Tiles" and "Enables Trade Over Ocean Tiles" should include Territorial Coastal tiles, since not all cities reaching water tiles necessarily have the ability to build an improvement giving "Allow Water Trade".
If anyone has a better idea for the minimum standard conditions/rules for connecting water tiles or if they think it's all stupid and pointless, please feel free to comment.

Getting an AI to build something like roads or colonies on water is, if I understand correctly, a trickier problem than giving a water territory an exemption.
But if this problem is solved sometime in the future, the variously managed water terrain would generally need its own look as well.
Of course, it would be great if there was a water worker AI (fishing boats/construction ships capable of performing the same role as land workers) or a land/water trade AI (trading ships in the manner of the caravans from other Civilization games, which, in our case, would seek out foreign cities and give the player a lump sum of gold upon entering them based on the distance between the caravan owner's capital and the destination), but thinking of how much overall work would be involved, I'm guessing anything like that is completely out of sight. Although, after the successes with Artillery AI and Army AI Strategies, how hard would it be to use the existing code for Terraform AI, Explore AI and Flag Unit AI Strategies and create Naval Terraform, Naval Trade and (Land) Trade?

This, and also for consideration: it would be nice if the defensive Combat Values for improvements could be cumulative.
I very much agree! I once tested giving defensive bonuses to many improvements, and then cities were basically unconquerable, which implied they were cumulative, but I guess I was wrong.

The percentage on the explanatory notes measures how much of a percentage of the unhappy population are unhappy due to that reason, and this should always add up to 100%. It doesn't measure how much of the population of the city are unhappy vs not unhappy, nor does each reason necessarily have to be represented by a proportional amount of popheads - if only one popheads' worth of citizens is unhappy, but there are 3 reasons to be unhappy in that city, then 3 reasons of varying percentages will be given.
Of course, I probably should have mentioned that the "It's just way too crowded." reason for the unrest simultaneously dropped, and the resulting reasons in sum gave 100%. The reasons for unhappiness and the sheer number of unhappy citizens are two different things that are only somewhat related.
Although the actions of the draft or forced labor will cause happiness in the city to TEMPORARILY drop below the number of citizens born content. Therefore, it seems natural to me that the buildings causing unhappiness, which manifest themselves as reasons for unhappiness, also manifest themselves on the citizens themselves with the possibility of breaking that barrier called citizens born content.
 
I very much agree! I once tested giving defensive bonuses to many improvements, and then cities were basically unconquerable, which implied they were cumulative, but I guess I was wrong.

This is what I'm going on, FWIW
 
So, I noticed something in diplomacy. I was asking for a peace treaty (surrender). I asked for one city, fine, acceptable. I asked for another, "we are close to a deal". Then no matter what I sweeten the pot with, I get "They would never accept such a deal". Seems to me as if something is broke here. I suspect that I was never close to a deal and the wrong dialog came up.
 
No, this is the base game logic working as intended. You can't "buy" towns (i.e. offer something in exchange), you can only demand them outright.

So if they'll 'almost' accept, the only way to force them to concede additional towns is to put more hurt on them.
 
Don't forget about animations!
animations (as in replacing sprites at regular intervals) are no problem for my code. what i have not implemented yet is also making the sprite move off the usual grid alignment, but should be possible.
re-implementing the UI on the other hand would be massive work requiring time that i dont have. maybe it would be possible to disable world rendering and rendering rather than to the screen to a separate buffer and copying that behind the UI
 
A suggestion : While I looked it up in this thread, you might want to consider adding a note to the C3X Release thread telling users to use "wine install.bat" when installing on Linux.
 
When will AI be changed? I am waiting that.:)
While we'll stuck with the same AI there are ways which C3X can improve its performance. The obvious stuff is the ability to use artillery and armies. There's also a perfume function for you to emphasize what the AI should build. I've managed to make the AI far more formidable in the industrial age onwards using that.
 
While we'll stuck with the same AI there are ways which C3X can improve its performance. The obvious stuff is the ability to use artillery and armies. There's also a perfume function for you to emphasize what the AI should build. I've managed to make the AI far more formidable in the industrial age onwards using that.
I can play with one town all 540 turns and I will survive. AI is very passive to player.

 
A suggestion : While I looked it up in this thread, you might want to consider adding a note to the C3X Release thread telling users to use "wine install.bat" when installing on Linux.
Or run it through Proton as a "non-steam game"

@sirati97 if you're not aware, you may also be interested in the project C7 linked in my signature
 
Just out of curiosity, what technical solution did you use? Because I remember you saying last time that there was no way to effectively limit it.
I was mistaken about that. The AI doesn't have any function that checks if a rebase target is valid. There is a function like that but it's only used for the human player. However, the AI still checks through function calls if its rebase target is within the unit's operational range, so I redirected those calls so they'll return false if the target tile is at the stack limit. In the end, preventing the AI from rebasing turned out not to be especially difficult.

- Just so, are we talking in units or tens of units about the amount of places that would need modification? Let us know how much of a pain it would be and how much we should praise you for it.
- Is this single byte where the result of the calculation is stored or is it where the restriction itself is stored? Because if it's the former, couldn't this be solved similarly to the other 255 limitation problem with improvements that you successfully solved? And if it's the latter, couldn't it simply be ignored/skipped?
- So I guess any more complex formulas for controlling/influencing the economy are completely out of the question at this stage?
- Is it far simpler then to wait for Lua that can handle all these and any more complex calculations with interest rates moving depending on other factors?
- I'd be surprised if there were more than 10 places that needed modification. I've already found three and expect to find a few more, like one for the income shown in the bottom right on the map, another for the domestic advisor screen, and maybe another for trading. I just hope there aren't a lot more hidden inside the AI's logic.

- It's the restriction itself. The code is basically:
C++:
int interest_amount = number_of_interest_generating_wonders * (player_treasury / 20);
if (interest_amount > 50)
    interest_amount = 50;
That comparison inside the if got compiled to a three-byte instruction. The instruction itself is also very simple: the first byte instructs the processor to do a comparison, the second byte specifies the first argument (in this case a register), and the third byte specifies the value 50. Yes, to remove the cap on interest I could delete the instructions corresponding to that if statement, but I think that rule would be very exploitable by human players. As an interesting little aside, in the AI's logic for hurrying production, I remember seeing a check of whether doing so would reduce the AI's treasury enough to reduce its income from interest. So the AI is at least slightly aware of the interest mechanic.
The full solution to this problem would be to overwrite the instructions I mentioned above with a detour into the mod's own logic. Then I could make the cap work however I want, in the extreme case have it call out to a Lua function to determine the cap. I try not to do that since it's more work than just modifying functions like I normally do, but it's not *that* much work. I've already done it more than a few times when there wasn't any alternative.

- I think complex formulas ought to be written in Lua. As for how difficult it would be to modify the game's econ logic, that really depends on the specific piece of logic. For example, if the game always computed player interest through some Leader::get_interest_income function, it would be easy to swap that out with different logic. It could have had such a function, it just doesn't because either the original devs never wrote one or the compiler inlined it away.

So just to be clear, the problem would be that buildings that should be free because they are given by the Wonder to enemy cities would not be free and would require maintenance? And the moment peace was made, those hostile buildings would disappear, but internally they would still be paid for, and likewise for friendly buildings that should be maintenance free, but internally they would also still be paid for?
Yes, though I guess that wasn't a good example since buildings granted by wonders are maintenance free. That hypothetical only works if I were also to add the option to make them cost maintenance, which is not the craziest idea for buildings intended to hinder your enemies.

This solution is obviously workable, but the remaining cities without "sea oil" in their reach will have a mysterious useless source of "sea oil" that they will never be able to use in any meaningful way.
The "sea oil" on the water also has no way of being depleted because it is not practically part of the trade network, which is also a limitation that would be useful to address.
By the way, did you know that luxury resources, for some reason unknown to me, don't reappear somewhere on the map after depletion?
So, for me, WATER Tiles would definitely need an EXCEPTION allowing Luxuries or Strategic Resources to be part of the trade network if they are part of the TERRITORY.
[...]
Although, after the successes with Artillery AI and Army AI Strategies, how hard would it be to use the existing code for Terraform AI, Explore AI and Flag Unit AI Strategies and create Naval Terraform, Naval Trade and (Land) Trade?
It's possible to stop the Sea Oil resource from cluttering up the interface by making it a bonus instead of a strategic resource. The only problem with that is that the Firaxis editor doesn't let you set a bonus resource as a requirement for a building, but Quintillus' editor does, and it works fine in-game.

I could probably make it so that resources on coastal tiles are added to the trade network of the nearest city in range. The way resources normally get added to trade networks is that each tile with a road on it that is connected to a city has a trade network associated with it. Those networks get computed ahead of time by flood filling outward from all cities. Then the game loops over every strat & lux resource on the map, checking tech, borders, colonies, etc., then adding each to its tile's network. I could insert some code that runs after the trade networks are computed to put water tiles with resources on networks, too. That ought to work but I can't say for sure without trying it.

I did not know that luxuries don't reappear after depletion. I'll look into why that is, if I get around to it.

Writing new AI routines for naval units would be quite a bit of work. The existing routines for land units wouldn't be of much use. I would only use those as references for what units should be doing, so I don't forget anything, or to see how Firaxis implemented some things. The code for, for example, AI workers is not general enough to be reused. So far the only unit AI I completely replaced is for leader units. That was possible because the original code was so short, about 160 lines decompiled. For artillery, most of their behavior still comes from the base game, I only inserted some logic that allows them to grab city defenders as escorts and that allows them to load onto transports for naval invasions.

animations (as in replacing sprites at regular intervals) are no problem for my code. what i have not implemented yet is also making the sprite move off the usual grid alignment, but should be possible.
re-implementing the UI on the other hand would be massive work requiring time that i dont have. maybe it would be possible to disable world rendering and rendering rather than to the screen to a separate buffer and copying that behind the UI
That's good. Do you have text drawing working? Reimplementing the interface would be a lot of work but you could probably get away with swapping out the functions the interface logic depends on. From what I've seen, those functions are relatively simple, like load PCX texture, slice it into pieces, blit region to region on some textures, set font, draw text at a certain location, set clipping region, draw line, etc. I don't have the drawing code completely decoded, but I do have the gist of it.
 
I did not know that luxuries don't reappear after depletion. I'll look into why that is, if I get around to it.
Speculation: May be the reason is because luxury resources appear in clusters ?
 
I can play with one town all 540 turns and I will survive. AI is very passive to player.


Yeah, unless you instigate war among the AIs most of them will just develop peacefully and not start wars if you play on standard aggression and the AIs are around level 2-3 aggression. But sometimes those of lv 4 and 5 will aggressively start wars, esp if you're weaker than them. If I start next to Bismarck I'd have to change my build order to not die to his 4 archers early on.

Things like the UN and spaceship components can be heavily perfumed along with factories so that the AI will put the player on a timer even if there are no wars. After all, with no wars, the AI will tech much faster. The AI will now very actively work towards a diplo or space victory.
 
It appears as if the game does not deal with fractional worker progress. That is, if one worker, after all appropriate bonuses (e.g., government) is strength 1 and another is strength 1.5, they will complete, for example, building a rail road at the same time, since the mechanics cannot deal with fractional progress.

Is this observation correct?

If so, is there anything that can be done to accumulate fractional progress?
 
Speculation: May be the reason is because luxury resources appear in clusters ?
I thought too it might be some issue with how luxury resources are spawned, but after looking into it, turns out it's not. The code simply checks if a depleted resource is strategic before respawning it, so it was a deliberate choice by the original developers not to respawn luxuries for whatever reason. The good news is it's trivial to change that rule.

It appears as if the game does not deal with fractional worker progress. That is, if one worker, after all appropriate bonuses (e.g., government) is strength 1 and another is strength 1.5, they will complete, for example, building a rail road at the same time, since the mechanics cannot deal with fractional progress.
Is this observation correct?
If so, is there anything that can be done to accumulate fractional progress?
The game tracks fractional worker progress but the numbers involved are usually pretty low and get rounded off to integers, so that might be why it's not making any difference in your case. The way it works is each worker stores their own progress toward the job they're doing, in points. The total number of points needed to complete a job equals the "turns to complete" set in the editor times the movement cost of the terrain. A typical worker contributes 2 points per turn (= worker rate of 2 in Republic times 100% worker strength on the unit type). If the job requires 4 points to complete, there will be no difference between that worker and one that contributes 3 points per turn.
 
On lunching the installation of C3X: EXE Mod in windows xp, it gives this error:


"ttc.exe is not a valid win32 application"


Is there a way to install C3X: EXE Mod in windows xp?
 
Today it's going to be very niche. I apologize to everyone for it. This would probably look ugly graphically (?), but would it be possible for ships to be able to sail along tiles with rivers? A river tile is one that has a river on its edge.
With the help of options to limit the number of units per tile to avoid the problem of direct attack between land and naval units, NAVAL units on RIVER tiles outside the city would be able to block enemy LAND units from accessing those occupied river tiles and vice versa (LAND units on RIVER tiles outside the city would be able to block enemy NAVAL units from accessing those occupied river tiles).
As for sharing RIVER tiles outside the city simultaneously by Land and Naval units, enemy Land or Naval units could only directly attack a given occupied river tile as long as there is a valid target for the corresponding group, but they could NOT enter it after a battle is won if there is a target on the tile they cannot fight (I know, it's a bit overexplained). If this were a problem, river tiles COULD NOT be occupied by Land and Naval units simultaneously.
As for land units without defenses like workers or artillery, I don't have a very clear opinion here, but I'm more inclined to allow them to be captured by ships capable of fighting on RIVER tiles. If this were a problem, let them function as a block just like other land units with defenses.
I'll only slightly raise questions about building ships or even coastal improvements in cities on RIVER tiles leading to oceans, which should be able to do so thanks to the said modification (sail along tiles with rivers).

Yes, to remove the cap on interest I could delete the instructions corresponding to that if statement, but I think that rule would be very exploitable by human players.
That's exactly why I tried to include other models like REGRESSION or VARIABILITY/INSTABILITY and NOT just Unlimited GROWTH. I'd like to incorporate real-world economic mechanisms in the simplest and most accessible way possible under the current constrained conditions for late-game economic development.
When the game calculates a bunch of demographic stats (F11) for you like Approval rating, Population, GNP, Mfg. Goods, Land Area, Literacy, Disease, Pollution, Life Expectancy, Family Size, Military Service, Annual Income, Productivity (with some formulas being obvious and others not at all), add other useful elements that could, for example, calculate the stability of world markets based on the amount of trade between civilizations and the number of wars in the world. The stability of the world market would be reflected in the stability or strength of the own national market, which could set variable interest rates. Overall, more usefulness of demographic data would be appreciated. I'm basically very open to any ideas here, as I can't even know what all the game itself tracks and therefore could potentially use.
Another totally missed concept is the possibility of national debt through government borrowing (but not from other civilizations). In a situation where a nation is running out/needs a lot of money and has a building representing a national bank, having the option of various loans of X (1000; 2000; 2500; 10000 gold), which it will gradually pay back in successive Y turns (20; 40; 15; 60 turns), with each turn at interest rates R (5%; 4%; 6%; 2.5%) paying back Z (80; 101; 257; 323 gold = X*R*(1+R)^Y/(((1+R)^Y)-1)). Yes, the AI would probably not be able to use that option (?), and it would also take some restrictions predicated precisely on the strength of the national economy preventing it from borrowing endlessly to risk being in a real national debt spiral.
Any prospect of expansion in this economic direction? Or do you think this is definitely not reasonable or beneficial? Outright insane?

Sidenote: Any chance of having both options for hurrying production available at once for specific government types?

As an interesting little aside, in the AI's logic for hurrying production, I remember seeing a check of whether doing so would reduce the AI's treasury enough to reduce its income from interest. So the AI is at least slightly aware of the interest mechanic.
In the sense that a given purchase that would get the AI below 1000 gold would never be executed, or would some other rule evaluate the execution of the purchase?

Yes, though I guess that wasn't a good example since buildings granted by wonders are maintenance free. That hypothetical only works if I were also to add the option to make them cost maintenance, which is not the craziest idea for buildings intended to hinder your enemies.
I assumed that if I wanted to represent maintenance for buildings granted by wonders, I would do it through generating a resource giving negative trade, but doing it directly through maintenance would understandably be more elegant.

Just for the record, I think these are standard features for buildings granted by wonders: (correct me if I'm wrong)
1. They require no maintenance.
2. They can't be sold manually.
3. They can't be automatically sold when money is running low.
4. They can't be destroyed by any kind of bombing.

I mention this only because making an exception for the first point makes sense. I'm not sure about the others.

Sidenote: Does the AI have any routine that would decide to sell a building (without running out of money) based on the following:
1a) This building is only doing harm. (unhappiness, maintenance, pollution, negative culture)
1b) This building is doing more harm than good. (Based on more complex civilization preferences, example: I'm a Scientific, so this building adding +50% research output, high maintenance, high unhappiness, and pollution is worth having, but I'm not Commercial, so this building adding +50% tax output, high maintenance, high unhappiness, and pollution is NOT worth having.)
2) Its existence is not necessary for the construction of any other available building in the near future (same Era), so there is no point in maintaining it and therefore sell it?

One more aesthetic note: It would probably be useful to have buildings granted by wonders be graphically distinguished in the list of improvements in the city, so that they are noticeable at first glance. An open question even for others is whether that distinction should be color, bolding, or italicization of text? Or maybe something else entirely?

Writing new AI routines for naval units would be quite a bit of work. The existing routines for land units wouldn't be of much use. I would only use those as references for what units should be doing, so I don't forget anything, or to see how Firaxis implemented some things. The code for, for example, AI workers is not general enough to be reused. So far the only unit AI I completely replaced is for leader units. That was possible because the original code was so short, about 160 lines decompiled. For artillery, most of their behavior still comes from the base game, I only inserted some logic that allows them to grab city defenders as escorts and that allows them to load onto transports for naval invasions.
Is Lua a solution that will give everyone the ability to write what AI they need themselves, or will any potential new universal AI routines eventually have to be written by you or someone like you with a broader access?

I thought too it might be some issue with how luxury resources are spawned, but after looking into it, turns out it's not. The code simply checks if a depleted resource is strategic before respawning it, so it was a deliberate choice by the original developers not to respawn luxuries for whatever reason. The good news is it's trivial to change that rule.
In essence, preventing the reappearance of depleted resources is NOT such a bad idea. So being able to say, for example, "if the game turn is greater than X, resource Y cannot reappear after being depleted." would be a sufficient enhancement. Because something like this can only apply to resources that can only be found in forests at the moment. In the later stages of the game, when the forests are cleared, the resource of wood has nowhere to reappear once it is depleted.
 
Back
Top Bottom