Quantitative Resources

Another slightly silly question: would using this approach make it harder to add new resource yields? Suppose you wanted to implement steel and synthetics; would that require additional mods of the SDK, or would that already be done so one could simply add it in XML? ;)
 
Another slightly silly question: would using this approach make it harder to add new resource yields? Suppose you wanted to implement steel and synthetics; would that require additional mods of the SDK, or would that already be done so one could simply add it in XML? ;)

Well... the short answer is: No, you would need to do SDK work.

The reason: The yield types are predefined in the CvEnums.h file in the SDK because under the current system, the three yields are processed in different ways and thus you need to be able to refer to them up front... so, for example:

I'm not great with proper coding vocabulary, so pardon me for putting it into lay terms, but when the city calculates the food difference between what you have and what you consume, it has to get the yield rate value in the yield rate array for the food index, that index value is stored as YIELD_FOOD.

The problem is that if that enum value of YIELD_FOOD is not predefined in the SDK, you can't just stick it in there with the idea that the value will be determined later when the game is run and the XML is loaded. It simply won't let you compile if you haven't defined that value.

However... it is not beyond the realm of possibility that the code could be generalized, with a bit of work, so that you would get rid of those inherent distinctions between production, commerce and food and make everything interchangeable with the actual behaviors and properties for each being defined by modders in XML.

There is something to be said for this... in this case, you could have a general consumption rate, general yield rate and inventory per city rather than specific values for the food consumption, food difference, and stored food values. This would allow, for example, if you were to create a new yield called Power that would be able to be consumed by the population, or a Fuel/Oil yield would be able to be consumed by the population, and it would require no actual additions to the code with new functions, etc. to do this once the system is created.

I don't know that it's necessarily possible, but I think it's quite probable that it can be done. Then you'd just be able to add new yields into the XML without having to make SDK changes. The only thing that would need to be done then is changes in python to show these new new yields in the city screen, which is relatively simple although beyond my knowledge.

However, I don't know if it would provide solutions to our resource problems because yield modifiers and changes are everywhere in the code... there's dozens and dozens of instances where the yields are run through, and there are many arrays for storing yield values. For every new yield you add, that array gets larger. For every yield you add, those loops need to run through one more time... so for every yield you add, that's a tiny bit more system resources needed.

But you can also make the argument that you will need even more arrays to have quantified resources, and you would need to add in all those same modifiers for resources, and that in the end, to create a separate but virtually identical system for quantitative resources would actually consume more resources... So turning all 40+ bonuses into yields would be a bad idea because you'd be basically increasing the required memory and processing time by 10 fold (this would not be total processing time but just processing related to yields which could still double total processing time I would think). Adding the most important strategic resources, however, might work... if you keep the total number at about 15: the 3 current yields and maybe 12 strategic resources.

Is this the best route? I'm not sure... but I will say this, a separate system for quantitative resources will parallel this quite closely, and it might be better to try to get a national inventory system for yields complete and running smoothly as a dry run to a quantitative resource system... and at the very least, if the quant. resources seems like too much work or too difficult to pull off, this would provide the fallback.
 
Yeah, that's what I was worried about... it would basically be a hard-coded system that would require almost as much modification to add new resources as it did to develop it in the first place.
 
Yeah, that's what I was worried about... it would basically be a hard-coded system that would require almost as much modification to add new resources as it did to develop it in the first place.

No, that's not what I'm saying... adding new yield types is fairly simple for someone who has a moderate understanding of the SDK. However, to make it so that yields can be added into the game without SDK changes by the modder would require a lot of reworking in the SDK. But it is a change which would reap benefits beyond just the scope of the quantitative resources by making yields essentially interchangeable.
 
Ah... well, I've never dabbled in SDK before (strictly Python and XML for me ;)) however, that would give me an incentive to learn a few things. It sounds like basically a copy-and-paste issue, with a few superficial and name changes for each additional yield type.
 
I remenber the Binary display issues and I wonder if there is a way to make each yield independant i.e. getting rid of the "15" bareer ? I think also the Resource Yield would require only one display slot in the modified nif since there will be only one resource type on each plot.
Gaius, do you plan to add a Power Yield with the advent of electricity ? ( it would be something really great )
 
I have thought about quantifying power, yes. The original game that inspired me to create this topic did just that, so if you built a lot of factories and buildings which required power, you'd have to make more power plants. Otherwise, you'd get in a kind of energy crisis.

The only downside was that it also stored power in the stockpile along with the other resources. DC power aside, this isn't realistic, but we could avoid that by resetting the counter to zero each turn, as was suggested earlier.
 
Well, I suppose you could do that even with quantified power. :)
It's not that important to me either way. If we did do it, we'd probably have to remove the existing concept of power, and that might get messy. (Can't say for sure because I haven't looked at it.)
 
It's easy enough to get the city's inventory to store or not store a particular yield... you could even have a tech that could potentially unlock the ability to store the yield. This is what I'm doing for Power since I too am planning to quantify it... When you research Hydrogen Cells, it opens the ability to store some of your Power in the national pool. Maybe I'll add some kind of Integreated National Powergrid project that'll increase the upper storage limit or something...
 
I think there should always be a pool for quantified resources. Having a lower storage limit early on would simulate the inability to store much power, which can be raised with a later tech. Or, you could just as easily have the notion of "spoilage". Your power supply always loses 50% of what you had from turn to turn, until you discover a later tech.
 
There seems to be a problem with your system for food resources.

You basically become immune to having it cut off. Imagine that you had only one wheat resource, now, your enemy comes along and pillages it. What happens? Well, after having had that one tile for 100 turns, you've built up quite a stockpile. And since we've been unconcerned with using up that stockpile with any game elements (as all the game checks for is whether there is a positive stockpile) you can still maintain the benefits of that wheat tile, even though you don't have access to it.

Also, what exactly are you trading when you trade those resources to other civs? It seems like you could end up trading that resource to multiple other civs, even though you only have 1 tile with it. Not only that, but the other civs with get their own counter going up while they are trading with you, and after the trade ends, they have a positive number in that resource's counter, which means they get to maintain the benefits of that resource despite no longer trading for it.

You're going to need to reset that food counter too.
 
Could someone list what this will do exactly? The reason I would like someone to post this info is because there are +150 posts and it doesn't seem like the first post has been edited to reflect the current direction this is going.
 
Zebra 9:
As I understand it, the system we seemed to have agreed upon is the one I put forth in post #118. At least, I take the silence to mean quiet consensus. :p The question now is how we will code it, whether to use the yield types, etc. I will update the original post.


There seems to be a problem with your system for food resources...

You basically become immune to having it cut off. Imagine that you had only one wheat resource, now, your enemy comes along and pillages it. What happens? Well, after having had that one tile for 100 turns, you've built up quite a stockpile. And since we've been unconcerned with using up that stockpile with any game elements (as all the game checks for is whether there is a positive stockpile) you can still maintain the benefits of that wheat tile, even though you don't have access to it.

Not quite. Remember I said that we don't use the stockpiles for food and luxuries, so it's irrelevant. We could just reset it to zero each turn, or even better, just not even call it in the code for those types.

Also, what exactly are you trading when you trade those resources to other civs? It seems like you could end up trading that resource to multiple other civs, even though you only have 1 tile with it.

Exactly right. This is what I meant earlier when I said we need to get our heads out of the traditional Civ way of thinking. Why shouldn't you be able to trade specific quantities to multiple civs, even if you had one source? It's no longer based on how many plots you have, but on production and quantity. However, it's extremely unlikely that you'd want to trade away lots of your stockpiles if you only had one source. :)

Not only that, but the other civs with get their own counter going up while they are trading with you, and after the trade ends, they have a positive number in that resource's counter, which means they get to maintain the benefits of that resource despite no longer trading for it.

Again, exactly right. They get to maintain the benefits so long as their stockpile holds out (only for the strategic resources).

To recap for everyone:

Food will not be quantified or stockpiled. Luxuries will be quantified, but not stockpiled. Only strategic resources will be quantized and stocked. The best way to do this, it seems, is to create new yield types as Dom Pedro II suggested, and we could pretty much leave the luxuries and food alone. This has problems, though, such as how do we quantify luxuries without creating a new yield?

One other thing I forgot to mention: Dom had a good idea to revamp the the way resources are related to other game features, especially techs. So now there will be a tech bonus modifier, for example if you have access to lots of copper, the cost of Bronze Working is reduced.

If there is anything I left out please correct me. :)
 
Ah, thanks Gaius, that cleared up some stuff for me.

I was rereading some of the thread and I came across this notion of making things like hammers and food quantitative also. It inspired a new idea, that of quantitative power (or electricity). You could follow the same system you've already planned for three existing resource types, but add another counter for power. This one is not increased by mere connection to natural resources, it's a counter for refined resources, and acts in much the same way that you have luxury resources setup in your current plan.

Different buildings can be built which turn various natural resources into power counters. These counters go into the the stockpile for the whole nation and are used to first power the biggest and most important cities, so a power plant out in the boonies of your empire will send it's power off to the big cities first, until it's turn comes around.

This ensures that your primary cities will always be powered, like would be the case in the real world. If New York's primary power stations were damaged in some way, it would simply import it's power from other parts of the country, it wouldn't wait for a new one to be built before electronics can start working again.

It also encourages the use of a variety of power sources, from oil to coal, to nuclear.

You would also be able to import or export your power to other civs if you have an excess or shortage. You could alternatively import the goods needed to produce the power or export the goods needed to produce the power.

I would actually like to see it be a sort of resource that individual tiles can produce (like food, hammers and commerce), so that you can build things like solar power plants in deserts which would add to your total. This would make deserts a VERY important land type in the late game if you're finding yourself short on power. You would thus have two sources of counters for your power stockpile, the improvements to land tiles like deserts, and buildings like power plants.

The stockpile would, of course, be reset at the end (or beginning) of every turn as you really can't store it. This would also encourage civs to trade any excess as it would otherwise go to waste.


I don't know how well the AI would handle this though.

What do y'all think of adding this stockpile at some point?
 
I was thinking of doing exactly what you describe... basically to the letter. I've always wanted to put desert tiles to good use, and a solar plant would be very realistic. I also planned a Wind Power Plant (which I requested in the graphics section, but no one seems to want to do it) that you could build to increase your power, which has no resource prereq.

The idea is that if you don't have enough, you have to build different types of power plants (or more of the same kind).

One issue: currently, only one power plant in a city "works." The others are redundant. Hence, if you have a dirty power source (coal) and you build a hydro plant, the unhealthiness is automatically nullified. We have to get rid of this, since we're talking about quantity now.
 
Well, you'd have to change the way cities determine if they're powered. Different sized cities would, presumably, require different amounts of power. The game just checks to see if it has enough of this resource (which we are calling power) to determine if that city is powered. It basically treats the question, "Am I powered?" like it would, "Do I get a happiness bonus from pearls?" Power plants no longer actually serve to power their individual cities, they merely produce a resource (which we call power) which goes into the central bank of power.

So, one way of doing this is to simply change the buildings which boost your production to look to this resource we're looking to create, this mod created resource, rather than the existing game's notion of power.

It's similar to how the game determines if you get the bonus from Iron Works. You get a productivity bonus if your city is connected to Iron by 50%, and another 50% bonus is given if you also have coal. So, instead of looking at the status of the city's power, it looks to see if the city has been alloted power by the rules of power distribution (which, as I said earlier, is much like that of luxury resources).

Since this also divorces it from the traditional power notion already contained in the game, it frees it from the limitations on pollution that accompany it. Instead, it treats any unhealthiness penalties like it would a forge or research lab. They become additive. You can thus build multiple power stations in one city (as each one just produces it's power resource and puts it into the power bank) while having all the unhealthiness that comes with it. If you have a nuclear plant, a coal plant, and a dam, you get the power from each (which we'll say is 1 unit for simplicity's sake) for a total of 3 units, but you also get 1 unit of unhealthiness and the possibility of a melt down.

As for your wind power plant, couldn't you just use the existing graphic for a modern age windmill?
 
Again, with power stations that stay active even when outdated, having the ability to disband a building would be almost a necessity. If I know that I can build a coal plant now, but that I'll be stuck with it for the rest of the game while it produces pollution and unhealthiness, I'm just going to wait for something better. If I can later get rid of it when I have something better, then I'll probably go ahead and build one.
 
Back
Top Bottom