Good discussion material here.
The code is very straight forward at the moment. Cities are not considered at all. It is all at the national level. It just uses the capital to store the information.
I suspected that was the case at the moment and had intended to highlight the limitations with that simple question. Which apparently has done its job.
If it is made city based then there needs to be some way of saying "send all this city produces to my military city" for example. Plus the code for the AI to do this also, although it would probably be something similar to the contract system in that a city requests it and other cities send them the goods.
The contract system is something I'd find very difficult to duplicate or clone in any manner but I could setup something that would work and should work efficiently. It's noteworthy though that such a project would be pretty intense and would be challenging to make extremely streamlined for both processing time and data. Not to say it can't or shouldn't be done but just to say it's, as you point out, rather complex.
I would like to utilize the basic trade function to help with this. It really could create a major reshaping of how trade works entirely as the profits from such trade would be largely a calculation of supply and demand rather than straightforward yields if done optimally.
I'd LOVE what this could do for making unit based trade extremely fun. If you've ever played some of the trading games like some of Sid Meier's other selections involving pirates and railroads and such, you would have an idea of what I'd love to see. Ideally the player could look into cities and get an idea of the value of a product where the merchant currently is, looking for valuable products being offered to the unit far beneath the average price due to an abundancy of the product there, and find where its value is at a premium for sale. Pick up a shipment and take it to the place where they will profit the most from it. One could use such units to both play a miniature game of profit for that specific unit as well as use them to help distribute bonuses across the nation in the way most beneficial for the empire as a whole. Those players that like the option but don't want to get too micro into it could then just automate such units to generally perform 'best practices' as the AI would be using.
Having such merchant functionality would add another layer of importance to the criminal/ruffian side of things as well.
Currently the definition of what is produced is held in an array in the Python (Source Bonus, Number Produced, Every x turns, Manufactured Bonus).
That array is going to end up being a very problematic data hog I fear. It works... but the data efficiency would be an issue as this grows out further. Nothing against the programmer(s) involved... for a simpler mod this wouldn't be an issue.
And all the moreso when we would want to track by city... On a national level of tracking, this won't be all that helpful for representing the difficulties of getting resources where they are needed in space exploration and other frontiers we're looking to get into more depth with. But it is a good way to start a system at first if we're just looking at a 'proof of concept' so to speak.
If we go beyond strategic bonuses used for units to resources used for population you need to make decisions about the order something is used. In your gems case how much is used for population happiness and how much used by the jeweler to make jewellery.
This is true. And perhaps buildings themselves could then be relegated to the role of providing the happiness that is normally currently just an automatic benefit. Not sure what benefit gems and gold would provide people if there weren't gems and gold crafters and retail outlets for such products. This would then mean that they would use a maximum amount of the bonus material and get a benefit per bonus material that would equate to +x (whatever benefit is being provided) per population. This would probably need to be a severely decimalized system so we can account for cities between 0 and 400 in size and many of them while the number of sources can be quite limited.
On the other side it could make many of the so called useless manufactured bonuses more important. Eg carcass

. In that case people would first consume the raw and dried meat and then the carcass if there is not enough meat, so the buildings would consume first then the people.
Absolutely could make resources and trade agreements FAR more important! For many reasons.
Probably would need to find the city working the plot first, but if outside any working city plot, find the nearest city to be delivered to first and then if there is a tie to the nearest, go with the city with the larger population and if there is a tie, there, the city that has seniority in when it was founded. There will never be a tie there, even if it was the same round - it's the 'city cycle' order you'd be accessing for that.
This would need to be severely cached and checked as infrequently as possible.
improved and connected but not worked near a city
Not worked should give some minimal benefit perhaps but minimal indeed. This is where such a basic system as getting one per source per round is not really going to be nearly granular enough to represent things very well.
]near multiple cities
worked or not-worked
I think I touched on this above.
effects of buildings in a city eg Stable
Similar thinking to the ideas project will need to be implemented. Buildings should go inactive if they don't have ENOUGH access to the resources they need. In some cases the most minimal access is enough and then buildings from there, as suggested above, could start having improved effects with more access (but limit this so that a building cannot itself soak up all the available materials.)
I think setting it up for the strategic resources first as a proof of concept is the best idea as I think that would be what we want at that level.
Then if we want some other resources at a city level I can set up a new proof of concept for that later.
Yeah, I cannot see how the ultimate vision for this project could possibly be fit into a reasonable enough project time to include it for this version or even the next or possibly even the next.
But its not a bad thing to be plotting out concepts for its implementation now. The more we think about it and test things and so on the more it becomes a likely reality. I really think it would be a super cool evolution for our mod that could make for a lot of neat
strategic implications and not so much an overwhelming degree of required micromanagement. It would certainly give the player ways to get clever but if the system primarily runs itself nearly as well as it can for optimization for any given player, it shouldn't be too bad to implement.
I just worry about the massive amount of potential data and time consumption but thanks to having AIAndy and Koshling and Alberts2 here, they've shown me a lot of great ways to keep things streamlined. Hopefully I would be able to design something that doesn't cost us too much to make it worthwhile.